Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
Time
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
4 / 4
5
100.00% covered (success)
100.00%
1 / 1
 control
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 value
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 structure
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 shape
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace Cosray\Field;
6
7use Celema\Sire\Shape;
8use Cosray\Validation\Shapes;
9use Cosray\Value\Time as TimeValue;
10use Override;
11
12class Time extends Field
13{
14    #[Override]
15    public function control(): Control
16    {
17        return Control::time();
18    }
19
20    #[Override]
21    public function value(): TimeValue
22    {
23        return new TimeValue($this->owner, $this, $this->valueContext);
24    }
25
26    #[Override]
27    public function structure(mixed $value = null): array
28    {
29        return $this->getSimpleStructure('time', $value);
30    }
31
32    #[Override]
33    public function shape(): Shape
34    {
35        $shape = Shapes::create();
36        $this->addType($shape);
37
38        $value = $shape->add('value', $this->zxxShape('string', $this->validators));
39
40        if (!$this->isRequired()) {
41            $value->optional()->nullable();
42        }
43
44        $this->addMeta($shape);
45
46        return $shape;
47    }
48}