1 | <?php |
||
2 | |||
3 | namespace kalanis\simple_vin\Support; |
||
4 | |||
5 | |||
6 | final class Manufacturer implements \Stringable |
||
7 | { |
||
8 | 8 | public function __construct( |
|
9 | public readonly string $code, |
||
10 | public readonly string $brand, |
||
11 | public readonly string $types = '', |
||
12 | public readonly string $model = '', |
||
13 | public readonly string $manufacturer = '', |
||
14 | public readonly string $country = '', |
||
15 | public readonly ?int $from = null, |
||
16 | public readonly ?int $to = null, |
||
17 | public readonly string $notes = '', |
||
18 | public readonly bool $canCompareDates = false, |
||
19 | ) |
||
20 | { |
||
21 | 8 | } |
|
22 | |||
23 | 1 | public function desc(): string |
|
24 | { |
||
25 | 1 | return |
|
26 | 1 | ($this->manufacturer ? $this->manufacturer . ' - ' : '') |
|
27 | 1 | . $this->brand . ' ' . $this->model |
|
28 | 1 | . ($this->types ? (' ' . $this->types) : '') |
|
29 | 1 | . (($this->from || $this->to) ? (' (' . ($this->from ?: '') . '-' . ($this->to ?: '') . ')') : '') |
|
0 ignored issues
–
show
The expression
$this->to of type integer|null is loosely compared to true ; this is ambiguous if the integer can be 0. You might want to explicitly use !== null instead.
In PHP, under loose comparison (like For 0 == false // true
0 == null // true
123 == false // false
123 == null // false
// It is often better to use strict comparison
0 === false // false
0 === null // false
![]() |
|||
30 | 1 | . ($this->country ? ', ' . $this->country : ''); |
|
31 | } |
||
32 | |||
33 | 1 | public function __toString(): string |
|
34 | { |
||
35 | 1 | return $this->desc(); |
|
36 | } |
||
37 | } |
||
38 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
integer
values, zero is a special case, in particular the following results might be unexpected: