File manager - Edit - /home/u816558632/domains/postills.com/public_html/public/carbonphp.tar
Back
carbon-doctrine-types/composer.json 0000644 00000001426 15002226751 0013504 0 ustar 00 { "name": "carbonphp/carbon-doctrine-types", "description": "Types to use Carbon in Doctrine", "type": "library", "keywords": [ "date", "time", "DateTime", "Carbon", "Doctrine" ], "require": { "php": "^8.1" }, "require-dev": { "doctrine/dbal": "^4.0.0", "nesbot/carbon": "^2.71.0 || ^3.0.0", "phpunit/phpunit": "^10.3" }, "conflict": { "doctrine/dbal": "<4.0.0 || >=5.0.0" }, "license": "MIT", "autoload": { "psr-4": { "Carbon\\Doctrine\\": "src/Carbon/Doctrine/" } }, "authors": [ { "name": "KyleKatarn", "email": "kylekatarnls@gmail.com" } ], "minimum-stability": "dev" } carbon-doctrine-types/README.md 0000644 00000001010 15002226751 0012226 0 ustar 00 # carbonphp/carbon-doctrine-types Types to use Carbon in Doctrine ## Documentation [Check how to use in the official Carbon documentation](https://carbon.nesbot.com/symfony/) This package is an externalization of [src/Carbon/Doctrine](https://github.com/briannesbitt/Carbon/tree/2.71.0/src/Carbon/Doctrine) from `nestbot/carbon` package. Externalization allows to better deal with different versions of dbal. With version 4.0 of dbal, it no longer sustainable to be compatible with all version using a single code. carbon-doctrine-types/LICENSE 0000644 00000002047 15002226751 0011767 0 ustar 00 MIT License Copyright (c) 2023 Carbon 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. carbon-doctrine-types/src/Carbon/Doctrine/DateTimeImmutableType.php 0000644 00000001421 15002226751 0021426 0 ustar 00 <?php declare(strict_types=1); namespace Carbon\Doctrine; use Carbon\CarbonImmutable; use DateTimeImmutable; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\VarDateTimeImmutableType; class DateTimeImmutableType extends VarDateTimeImmutableType implements CarbonDoctrineType { /** @use CarbonTypeConverter<CarbonImmutable> */ use CarbonTypeConverter; /** * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function convertToPHPValue(mixed $value, AbstractPlatform $platform): ?DateTimeImmutable { return $this->doConvertToPHPValue($value); } /** * @return class-string<CarbonImmutable> */ protected function getCarbonClassName(): string { return CarbonImmutable::class; } } carbon-doctrine-types/src/Carbon/Doctrine/CarbonDoctrineType.php 0000644 00000000614 15002226751 0020771 0 ustar 00 <?php declare(strict_types=1); namespace Carbon\Doctrine; use Doctrine\DBAL\Platforms\AbstractPlatform; interface CarbonDoctrineType { public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform); public function convertToPHPValue(mixed $value, AbstractPlatform $platform); public function convertToDatabaseValue($value, AbstractPlatform $platform); } carbon-doctrine-types/src/Carbon/Doctrine/CarbonImmutableType.php 0000644 00000000227 15002226751 0021141 0 ustar 00 <?php declare(strict_types=1); namespace Carbon\Doctrine; class CarbonImmutableType extends DateTimeImmutableType implements CarbonDoctrineType { } carbon-doctrine-types/src/Carbon/Doctrine/CarbonTypeConverter.php 0000644 00000006226 15002226751 0021176 0 ustar 00 <?php declare(strict_types=1); namespace Carbon\Doctrine; use Carbon\Carbon; use Carbon\CarbonInterface; use DateTimeInterface; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\DB2Platform; use Doctrine\DBAL\Platforms\OraclePlatform; use Doctrine\DBAL\Platforms\SQLitePlatform; use Doctrine\DBAL\Platforms\SQLServerPlatform; use Doctrine\DBAL\Types\Exception\InvalidType; use Doctrine\DBAL\Types\Exception\ValueNotConvertible; use Exception; /** * @template T of CarbonInterface */ trait CarbonTypeConverter { /** * This property differentiates types installed by carbonphp/carbon-doctrine-types * from the ones embedded previously in nesbot/carbon source directly. * * @readonly */ public bool $external = true; /** * @return class-string<T> */ protected function getCarbonClassName(): string { return Carbon::class; } public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string { $precision = min( $fieldDeclaration['precision'] ?? DateTimeDefaultPrecision::get(), $this->getMaximumPrecision($platform), ); $type = parent::getSQLDeclaration($fieldDeclaration, $platform); if (!$precision) { return $type; } if (str_contains($type, '(')) { return preg_replace('/\(\d+\)/', "($precision)", $type); } [$before, $after] = explode(' ', "$type "); return trim("$before($precision) $after"); } /** * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string { if ($value === null) { return $value; } if ($value instanceof DateTimeInterface) { return $value->format('Y-m-d H:i:s.u'); } throw InvalidType::new( $value, static::class, ['null', 'DateTime', 'Carbon'] ); } private function doConvertToPHPValue(mixed $value) { $class = $this->getCarbonClassName(); if ($value === null || is_a($value, $class)) { return $value; } if ($value instanceof DateTimeInterface) { return $class::instance($value); } $date = null; $error = null; try { $date = $class::parse($value); } catch (Exception $exception) { $error = $exception; } if (!$date) { throw ValueNotConvertible::new( $value, static::class, 'Y-m-d H:i:s.u or any format supported by '.$class.'::parse()', $error ); } return $date; } private function getMaximumPrecision(AbstractPlatform $platform): int { if ($platform instanceof DB2Platform) { return 12; } if ($platform instanceof OraclePlatform) { return 9; } if ($platform instanceof SQLServerPlatform || $platform instanceof SQLitePlatform) { return 3; } return 6; } } carbon-doctrine-types/src/Carbon/Doctrine/DateTimeDefaultPrecision.php 0000644 00000001067 15002226751 0022113 0 ustar 00 <?php declare(strict_types=1); namespace Carbon\Doctrine; class DateTimeDefaultPrecision { private static $precision = 6; /** * Change the default Doctrine datetime and datetime_immutable precision. * * @param int $precision */ public static function set(int $precision): void { self::$precision = $precision; } /** * Get the default Doctrine datetime and datetime_immutable precision. * * @return int */ public static function get(): int { return self::$precision; } } carbon-doctrine-types/src/Carbon/Doctrine/CarbonType.php 0000644 00000000205 15002226751 0017275 0 ustar 00 <?php declare(strict_types=1); namespace Carbon\Doctrine; class CarbonType extends DateTimeType implements CarbonDoctrineType { } carbon-doctrine-types/src/Carbon/Doctrine/DateTimeType.php 0000644 00000001055 15002226751 0017571 0 ustar 00 <?php declare(strict_types=1); namespace Carbon\Doctrine; use Carbon\Carbon; use DateTime; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\VarDateTimeType; class DateTimeType extends VarDateTimeType implements CarbonDoctrineType { /** @use CarbonTypeConverter<Carbon> */ use CarbonTypeConverter; /** * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function convertToPHPValue(mixed $value, AbstractPlatform $platform): ?DateTime { return $this->doConvertToPHPValue($value); } }
| ver. 1.4 |
Github
|
.
| PHP 8.2.28 | Generation time: 0 |
proxy
|
phpinfo
|
Settings