PickupPointList   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
eloc 10
dl 0
loc 33
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A filter() 0 12 5
A getCount() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace CdekSDK2\Dto;
6
7
use JMS\Serializer\Annotation\Type;
8
9
/**
10
 * Class PickupPointList
11
 * @package CdekSDK2\Dto
12
 */
13
class PickupPointList
14
{
15
    /**
16
     * Список ПВЗ
17
     * @Type("array<CdekSDK2\Dto\PickupPoint>")
18
     * @var PickupPoint[]
19
     */
20
    public $items = [];
21
22
    /**
23
     * @return int
24
     */
25
    public function getCount(): int
26
    {
27
        return count($this->items);
28
    }
29
30
    /**
31
     * @param array $filter
32
     * @return array
33
     */
34
    public function filter(array $filter = []): array
35
    {
36
        $filtered = [];
37
        foreach ($this->items as $pvz) {
38
            foreach ($filter as $k => $v) {
39
                if (property_exists(PickupPoint::class, $k) && mb_strtolower($pvz->$k) === mb_strtolower($v)) {
40
                    $filtered[] = $pvz;
41
                    break;
42
                }
43
            }
44
        }
45
        return $filtered;
46
    }
47
}
48