Passed
Push — main ( bcc232...2bc5a4 )
by Vasil
03:27
created

FindSiteResponse::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VasilDakov\Speedy\Service\Location\Site;
6
7
use Doctrine\Common\Collections\ArrayCollection;
8
use VasilDakov\Speedy\Error;
9
use JMS\Serializer\Annotation as Serializer;
10
11
/**
12
 * Class FindSiteResponse
13
 *
14
 * @author    Vasil Dakov <[email protected]>
15
 * @author    Valentin Valkanov <[email protected]>
16
 * @copyright 2009-2022 Neutrino.bg
17
 * @version   1.0
18
 * @see       https://api.speedy.bg/web-api.html#href-find-site-resp
19
 * @Serializer\AccessType("public_method")
20
 */
21
class FindSiteResponse
22
{
23
    /**
24
     * @Serializer\Type("ArrayCollection<VasilDakov\Speedy\Model\Site>")
25
     */
26
    private ArrayCollection $sites;
27
28
    private ?Error $error = null;
29
30 1
    public function __construct(?Error $error = null)
31
    {
32 1
        $this->sites = new ArrayCollection();
33 1
        $this->error = $error;
34
    }
35
36
    /**
37
     * @param ArrayCollection $sites
38
     */
39
    public function setSites(ArrayCollection $sites): void
40
    {
41
        $this->sites = $sites;
42
    }
43
44
    /**
45
     * @return ArrayCollection
46
     */
47 1
    public function getSites(): ArrayCollection
48
    {
49 1
        return $this->sites;
50
    }
51
52
    /**
53
     * @return Error|null
54
     */
55 1
    public function getError(): ?Error
56
    {
57 1
        return $this->error;
58
    }
59
60
    /**
61
     * @param Error|null $error
62
     */
63 1
    public function setError(?Error $error): void
64
    {
65 1
        $this->error = $error;
66
    }
67
68 1
    public function toArray(): array
69
    {
70 1
        return [
71 1
            'sites' => $this->getSites(),
72 1
            'error' => $this->getError()
73 1
        ];
74
    }
75
}
76