Passed
Push — main ( 6bf038...578b82 )
by Aleksandr
03:45 queued 32s
created

IntervalsResponse::getClientType()   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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
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 DalliSDK\Responses;
6
7
use DalliSDK\Models\Interval;
8
use JMS\Serializer\Annotation as JMS;
9
10
/**
11
 * Сюда мапится ответ на запрос получение интервалов
12
 *
13
 * @see https://api.dalli-service.com/v1/doc/intervals
14
 * @JMS\XmlRoot("intervals")
15
 *
16
 * @template-implements \IteratorAggregate<int, Interval>
17
 */
18
class IntervalsResponse implements ResponseInterface, \IteratorAggregate
19
{
20
    /**
21
     * @JMS\Type("array<DalliSDK\Models\Interval>")
22
     * @JMS\XmlList(inline = true, entry = "interval")
23
     * @var Interval[]
24
     */
25
    private array $items = [];
26
27
    /**
28
     * @return \Traversable|Interval[]
29
     */
30 2
    public function getIterator(): \ArrayIterator
31
    {
32 2
        return new \ArrayIterator($this->getItems());
33
    }
34
35
    /**
36
     * @return Interval[]
37
     */
38 3
    public function getItems(): array
39
    {
40 3
        return $this->items;
41
    }
42
43 1
    public function getBasicType(): array
44
    {
45 1
        return array_filter($this->getItems(), function ($item) {
46 1
            return $item->getType() == 'basic';
47 1
        });
48
    }
49
50 1
    public function getClientType(): array
51
    {
52 1
        return array_filter($this->getItems(), function ($item) {
53 1
            return $item->getType() == 'client';
54 1
        });
55
    }
56
}
57