Total Complexity | 4 |
Total Lines | 50 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
16 | class DateTimeValue extends AbstractAnySimpleType |
||
17 | { |
||
18 | /** @var string */ |
||
19 | public const SCHEMA_TYPE = 'dateTime'; |
||
20 | |||
21 | /** @var string */ |
||
22 | public const DATETIME_FORMAT = 'Y-m-d\\TH:i:sP'; |
||
23 | |||
24 | |||
25 | /** |
||
26 | * Sanitize the value. |
||
27 | * |
||
28 | * @param string $value The unsanitized value |
||
29 | * @return string |
||
30 | */ |
||
31 | protected function sanitizeValue(string $value): string |
||
34 | } |
||
35 | |||
36 | |||
37 | /** |
||
38 | * Validate the value. |
||
39 | * |
||
40 | * @param string $value |
||
41 | * @throws \SimpleSAML\XMLSchema\Exception\SchemaViolationException on failure |
||
42 | * @return void |
||
43 | */ |
||
44 | protected function validateValue(string $value): void |
||
47 | } |
||
48 | |||
49 | |||
50 | /** |
||
51 | * @param \DateTimeInterface $value |
||
52 | * @return static |
||
53 | */ |
||
54 | public static function fromDateTime(DateTimeInterface $value): static |
||
55 | { |
||
56 | return new static($value->format(static::DATETIME_FORMAT)); |
||
57 | } |
||
58 | |||
59 | |||
60 | /** |
||
61 | * @return \DateTimeImmutable |
||
62 | */ |
||
63 | public function toDateTime(): DateTimeImmutable |
||
66 | } |
||
67 | } |
||
68 |