1 | <?php |
||
8 | class CycleTime implements \JsonSerializable |
||
9 | { |
||
10 | /** |
||
11 | * @var string |
||
12 | */ |
||
13 | private $from; |
||
14 | /** |
||
15 | * @var string |
||
16 | */ |
||
17 | private $to; |
||
18 | /** |
||
19 | * @var float |
||
20 | */ |
||
21 | private $days; |
||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | private $name; |
||
26 | |||
27 | 5 | private function __construct(string $from, string $to, ?float $days, string $name) |
|
34 | |||
35 | 4 | public static function createFromCardHistory(HistoryCard $cardHistory): CycleTime |
|
44 | |||
45 | 2 | public static function createWithDays(string $from, string $to, float $days): CycleTime |
|
46 | { |
||
47 | 2 | $name = $from . '_' . $to; |
|
48 | |||
49 | 2 | return new self($from, $to, $days, $name); |
|
50 | } |
||
51 | |||
52 | /** |
||
53 | * @return string |
||
54 | */ |
||
55 | 3 | public function getFrom(): string |
|
59 | |||
60 | /** |
||
61 | * @return string |
||
62 | */ |
||
63 | 3 | public function getTo(): string |
|
67 | |||
68 | /** |
||
69 | * @return float |
||
70 | */ |
||
71 | 2 | public function getDays(): ?float |
|
72 | { |
||
73 | 2 | return $this->days; |
|
74 | } |
||
75 | |||
76 | public function setDays(string $days) |
||
77 | { |
||
78 | return $this->days = $days; |
||
|
|||
79 | } |
||
80 | |||
81 | /** |
||
82 | * @return string |
||
83 | */ |
||
84 | 3 | public function getName(): string |
|
88 | |||
89 | /** |
||
90 | * Specify data which should be serialized to JSON |
||
91 | * @link https://php.net/manual/en/jsonserializable.jsonserialize.php |
||
92 | * @return mixed data which can be serialized by <b>json_encode</b>, |
||
93 | * which is a value of any type other than a resource. |
||
94 | * @since 5.4.0 |
||
95 | */ |
||
96 | 1 | public function jsonSerialize() |
|
105 | } |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.