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