FindOfficeResponse   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 26
ccs 4
cts 6
cp 0.6667
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getOffices() 0 8 2
A __construct() 0 3 1
A setOffices() 0 3 1
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