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