Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame^] | 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Thanks to https://github.com/flaushi for his suggestion: |
| 5 | * https://github.com/doctrine/dbal/issues/2873#issuecomment-534956358 |
| 6 | */ |
| 7 | namespace Carbon\Doctrine; |
| 8 | |
| 9 | class DateTimeDefaultPrecision |
| 10 | { |
| 11 | private static $precision = 6; |
| 12 | |
| 13 | /** |
| 14 | * Change the default Doctrine datetime and datetime_immutable precision. |
| 15 | * |
| 16 | * @param int $precision |
| 17 | */ |
| 18 | public static function set(int $precision): void |
| 19 | { |
| 20 | self::$precision = $precision; |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * Get the default Doctrine datetime and datetime_immutable precision. |
| 25 | * |
| 26 | * @return int |
| 27 | */ |
| 28 | public static function get(): int |
| 29 | { |
| 30 | return self::$precision; |
| 31 | } |
| 32 | } |