#13035 added Lcobucci\Clock

This commit is contained in:
Daniel Cebrian 2024-04-03 11:03:13 +02:00
parent 670829fa58
commit a3a3fa7e70
10 changed files with 234 additions and 3 deletions

View File

@ -29,7 +29,8 @@
"zircote/swagger-php": "^4.8",
"doctrine/annotations": "^2.0",
"ramsey/uuid": "^4.7",
"lcobucci/jwt": "^5.2"
"lcobucci/jwt": "^5.2",
"lcobucci/clock": "^3.2"
},
"repositories": {
"phpchartjs": {

View File

@ -44,6 +44,7 @@ return array(
'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'),
'Models\\' => array($baseDir . '/include/rest-api/models'),
'Lcobucci\\JWT\\' => array($vendorDir . '/lcobucci/jwt/src'),
'Lcobucci\\Clock\\' => array($vendorDir . '/lcobucci/clock/src'),
'Laravel\\SerializableClosure\\' => array($vendorDir . '/laravel/serializable-closure/src'),
'Laminas\\Json\\' => array($vendorDir . '/laminas/laminas-json/src'),
'Laminas\\Diactoros\\' => array($vendorDir . '/laminas/laminas-diactoros/src'),

View File

@ -115,6 +115,7 @@ class ComposerStaticInit94a17e624d873685991e8ae888e00eb9
'L' =>
array (
'Lcobucci\\JWT\\' => 13,
'Lcobucci\\Clock\\' => 15,
'Laravel\\SerializableClosure\\' => 28,
'Laminas\\Json\\' => 13,
'Laminas\\Diactoros\\' => 18,
@ -325,6 +326,10 @@ class ComposerStaticInit94a17e624d873685991e8ae888e00eb9
array (
0 => __DIR__ . '/..' . '/lcobucci/jwt/src',
),
'Lcobucci\\Clock\\' =>
array (
0 => __DIR__ . '/..' . '/lcobucci/clock/src',
),
'Laravel\\SerializableClosure\\' =>
array (
0 => __DIR__ . '/..' . '/laravel/serializable-closure/src',

View File

@ -1616,6 +1616,73 @@
},
"install-path": "../laravel/serializable-closure"
},
{
"name": "lcobucci/clock",
"version": "3.2.0",
"version_normalized": "3.2.0.0",
"source": {
"type": "git",
"url": "https://github.com/lcobucci/clock.git",
"reference": "6f28b826ea01306b07980cb8320ab30b966cd715"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/lcobucci/clock/zipball/6f28b826ea01306b07980cb8320ab30b966cd715",
"reference": "6f28b826ea01306b07980cb8320ab30b966cd715",
"shasum": ""
},
"require": {
"php": "~8.2.0 || ~8.3.0",
"psr/clock": "^1.0"
},
"provide": {
"psr/clock-implementation": "1.0"
},
"require-dev": {
"infection/infection": "^0.27",
"lcobucci/coding-standard": "^11.0.0",
"phpstan/extension-installer": "^1.3.1",
"phpstan/phpstan": "^1.10.25",
"phpstan/phpstan-deprecation-rules": "^1.1.3",
"phpstan/phpstan-phpunit": "^1.3.13",
"phpstan/phpstan-strict-rules": "^1.5.1",
"phpunit/phpunit": "^10.2.3"
},
"time": "2023-11-17T17:00:27+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"Lcobucci\\Clock\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Luís Cobucci",
"email": "lcobucci@gmail.com"
}
],
"description": "Yet another clock abstraction",
"support": {
"issues": "https://github.com/lcobucci/clock/issues",
"source": "https://github.com/lcobucci/clock/tree/3.2.0"
},
"funding": [
{
"url": "https://github.com/lcobucci",
"type": "github"
},
{
"url": "https://www.patreon.com/lcobucci",
"type": "patreon"
}
],
"install-path": "../lcobucci/clock"
},
{
"name": "lcobucci/jwt",
"version": "5.2.0",

View File

@ -5,7 +5,7 @@
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => 'fbec8c0a05f72bfcc2044c0a4857d5e31f534ad5',
'reference' => '670829fa5833a6f666ebf4c78669ca6fdac476c9',
'name' => 'pandorafms/console',
'dev' => true,
),
@ -217,6 +217,15 @@
'reference' => '3dbf8a8e914634c48d389c1234552666b3d43754',
'dev_requirement' => false,
),
'lcobucci/clock' => array(
'pretty_version' => '3.2.0',
'version' => '3.2.0.0',
'type' => 'library',
'install_path' => __DIR__ . '/../lcobucci/clock',
'aliases' => array(),
'reference' => '6f28b826ea01306b07980cb8320ab30b966cd715',
'dev_requirement' => false,
),
'lcobucci/jwt' => array(
'pretty_version' => '5.2.0',
'version' => '5.2.0.0',
@ -304,7 +313,7 @@
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => 'fbec8c0a05f72bfcc2044c0a4857d5e31f534ad5',
'reference' => '670829fa5833a6f666ebf4c78669ca6fdac476c9',
'dev_requirement' => false,
),
'paragonie/random_compat' => array(
@ -358,6 +367,12 @@
'reference' => 'e41a24703d4560fd0acb709162f73b8adfc3aa0d',
'dev_requirement' => false,
),
'psr/clock-implementation' => array(
'dev_requirement' => false,
'provided' => array(
0 => '1.0',
),
),
'psr/container' => array(
'pretty_version' => '2.0.2',
'version' => '2.0.2.0',

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 Luís Cobucci
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,48 @@
{
"name": "lcobucci/clock",
"description": "Yet another clock abstraction",
"license": "MIT",
"type": "library",
"authors": [
{
"name": "Luís Cobucci",
"email": "lcobucci@gmail.com"
}
],
"require": {
"php": "~8.2.0 || ~8.3.0",
"psr/clock": "^1.0"
},
"require-dev": {
"infection/infection": "^0.27",
"lcobucci/coding-standard": "^11.0.0",
"phpstan/extension-installer": "^1.3.1",
"phpstan/phpstan": "^1.10.25",
"phpstan/phpstan-deprecation-rules": "^1.1.3",
"phpstan/phpstan-phpunit": "^1.3.13",
"phpstan/phpstan-strict-rules": "^1.5.1",
"phpunit/phpunit": "^10.2.3"
},
"provide": {
"psr/clock-implementation": "1.0"
},
"autoload": {
"psr-4": {
"Lcobucci\\Clock\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Lcobucci\\Clock\\": "test"
}
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"infection/extension-installer": true,
"phpstan/extension-installer": true
},
"preferred-install": "dist",
"sort-packages": true
}
}

View File

@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace Lcobucci\Clock;
use DateTimeImmutable;
use Psr\Clock\ClockInterface;
interface Clock extends ClockInterface
{
public function now(): DateTimeImmutable;
}

View File

@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace Lcobucci\Clock;
use DateTimeImmutable;
use DateTimeZone;
final class FrozenClock implements Clock
{
public function __construct(private DateTimeImmutable $now)
{
}
public static function fromUTC(): self
{
return new self(new DateTimeImmutable('now', new DateTimeZone('UTC')));
}
public function setTo(DateTimeImmutable $now): void
{
$this->now = $now;
}
public function now(): DateTimeImmutable
{
return $this->now;
}
}

View File

@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace Lcobucci\Clock;
use DateTimeImmutable;
use DateTimeZone;
use function date_default_timezone_get;
/** @immutable */
final class SystemClock implements Clock
{
public function __construct(private readonly DateTimeZone $timezone)
{
}
public static function fromUTC(): self
{
return new self(new DateTimeZone('UTC'));
}
public static function fromSystemTimezone(): self
{
return new self(new DateTimeZone(date_default_timezone_get()));
}
public function now(): DateTimeImmutable
{
return new DateTimeImmutable('now', $this->timezone);
}
}