Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
11.11% |
1 / 9 |
|
33.33% |
1 / 3 |
CRAP | |
0.00% |
0 / 1 |
| Date | |
11.11% |
1 / 9 |
|
33.33% |
1 / 3 |
15.24 | |
0.00% |
0 / 1 |
| value | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| structure | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| shape | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Cosray\Field; |
| 6 | |
| 7 | use Celemas\Sire\Shape; |
| 8 | use Cosray\Validation\Shapes; |
| 9 | use Cosray\Value\Date as DateValue; |
| 10 | |
| 11 | class Date extends Field |
| 12 | { |
| 13 | public function value(): DateValue |
| 14 | { |
| 15 | return new DateValue($this->owner, $this, $this->valueContext); |
| 16 | } |
| 17 | |
| 18 | public function structure(mixed $value = null): array |
| 19 | { |
| 20 | return $this->getSimpleStructure('date', $value); |
| 21 | } |
| 22 | |
| 23 | public function shape(): Shape |
| 24 | { |
| 25 | $shape = Shapes::create(); |
| 26 | $this->addType($shape); |
| 27 | |
| 28 | $value = $shape->add('value', $this->zxxShape('string', $this->validators)); |
| 29 | |
| 30 | if (!$this->isRequired()) { |
| 31 | $value->optional()->nullable(); |
| 32 | } |
| 33 | |
| 34 | $this->addMeta($shape); |
| 35 | |
| 36 | return $shape; |
| 37 | } |
| 38 | } |