Id   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 6
c 0
b 0
f 0
dl 0
loc 22
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A isPresent() 0 3 1
A value() 0 3 1
A undefined() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
namespace Isswp101\Persimmon\DTO;
4
5
final class Id
6
{
7
    private int|string|null $value;
0 ignored issues
show
Bug introduced by
The type Isswp101\Persimmon\DTO\null was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
    public function __construct(int|string|null $value)
10
    {
11
        $this->value = $value;
12
    }
13
14
    public function value(): int|string|null
15
    {
16
        return $this->value;
17
    }
18
19
    public function isPresent(): bool
20
    {
21
        return $this->value != null;
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing $this->value of type Isswp101\Persimmon\DTO\null|integer|string against null; this is ambiguous if the integer can be zero. Consider using a strict comparison !== instead.
Loading history...
22
    }
23
24
    public static function undefined(): Id
25
    {
26
        return new Id(null);
0 ignored issues
show
Bug introduced by
null of type null is incompatible with the type Isswp101\Persimmon\DTO\null|integer|string expected by parameter $value of Isswp101\Persimmon\DTO\Id::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

26
        return new Id(/** @scrutinizer ignore-type */ null);
Loading history...
27
    }
28
}
29