Passed
Push — main ( 6ce649...f79563 )
by Vasil
03:20
created

GetCitiesResponse::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VasilDakov\Econt\Response;
6
7
use Doctrine\Common\Collections\ArrayCollection;
8
use JMS\Serializer\Annotation as Serializer;
9
use VasilDakov\Econt\Model;
10
11
final class GetCitiesResponse
12
{
13
    #[Serializer\Type("ArrayCollection<VasilDakov\Econt\Model\City>")]
14
    private ArrayCollection $cities;
15
16 2
    public function __construct()
17
    {
18 2
        $this->cities = new ArrayCollection();
19
    }
20
21 2
    public function findById(int $id): ?Model\City
0 ignored issues
show
Bug introduced by
The type VasilDakov\Econt\Model\City 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...
22
    {
23 2
        $collection = $this->cities->filter(function (Model\City $city) use ($id) {
24 2
            return $city->id === $id;
25 2
        });
26
27 2
        return (!$collection->isEmpty()) ? $collection->first() : null;
28
    }
29
30 2
    public function findByName(string $name): ?Model\City
31
    {
32 2
        $collection = $this->cities->filter(function (Model\City $city) use ($name) {
33 2
            return $city->name === $name;
34 2
        });
35
36 2
        return (!$collection->isEmpty()) ? $collection->first() : null;
37
    }
38
}
39