FindOfficeResponse::setOffices()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VasilDakov\Speedy\Service\Location\Office;
6
7
use Doctrine\Common\Collections\ArrayCollection;
8
use JMS\Serializer\Annotation as Serializer;
9
use VasilDakov\Speedy\Model\Office;
10
11
/**
12
 * Class FindOfficeResponse.
13
 *
14
 * @author Vasil Dakov <[email protected]>
15
 * @copyright 2009-2022 Neutrino.bg
16
 *
17
 * @version 1.0
18
 *
19
 * @Serializer\AccessType("public_method")
20
 */
21
class FindOfficeResponse
22
{
23
    /**
24
     * @Serializer\Type("ArrayCollection<VasilDakov\Speedy\Model\Office>")
25
     */
26
    public ArrayCollection $offices;
27 1
28
    public function __construct()
29 1
    {
30
        $this->offices = new ArrayCollection();
31
    }
32 1
33
    public function getOffices(?string $type = null): ArrayCollection
34 1
    {
35
        if (!$type) {
36
            return $this->offices;
37
        }
38
39
        return $this->offices->filter(function (Office $office) use ($type) {
40
            return $office->getType() == $type;
41
        });
42
    }
43
44
    public function setOffices(ArrayCollection $offices): void
45
    {
46
        $this->offices = $offices;
47
    }
48
}
49