Passed
Push — master ( 5adbb2...0c1970 )
by Ross
02:40
created

ListZones::__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
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 1
1
<?php
2
declare(strict_types = 1);
3
/**
4
 *
5
 * Copyright (C) 2018  Ross Mitchell
6
 *
7
 * This file is part of RossMitchell/UpdateCloudFlare.
8
 *
9
 * RossMitchell/UpdateCloudFlare is free software: you can redistribute
10
 * it and/or modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation, either version 3 of the
12
 * License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21
 */
22
23
namespace RossMitchell\UpdateCloudFlare\Responses;
24
25
use RossMitchell\UpdateCloudFlare\Abstracts\CloudFlareResponse;
26
use RossMitchell\UpdateCloudFlare\Factories\Responses\Results\ListZoneResultsFactory;
27
use RossMitchell\UpdateCloudFlare\Responses\Results\ListZonesResult;
28
use Symfony\Component\Console\Exception\LogicException;
29
30
/**
31
 * Class ListZones
32
 * @package RossMitchell\UpdateCloudFlare\Responses
33
 */
34
class ListZones extends CloudFlareResponse
35
{
36
    /**
37
     * @var ListZonesResult[]
38
     */
39
    private $result;
40
    /**
41
     * @var ListZoneResultsFactory
42
     */
43
    private $zoneResultsFactory;
44
45
    /**
46
     * ListZones constructor.
47
     *
48
     * @param ListZoneResultsFactory $zoneResultsFactory
49
     * @param \stdClass              $rawResult
50
     *
51
     * @throws \Symfony\Component\Console\Exception\LogicException
52
     */
53 11
    public function __construct(ListZoneResultsFactory $zoneResultsFactory, \stdClass $rawResult)
54
    {
55 11
        $this->zoneResultsFactory = $zoneResultsFactory;
56 11
        parent::__construct($rawResult);
57 7
    }
58
59
    /**
60
     * @return ListZonesResult[]
61
     */
62 1
    public function getResult(): array
63
    {
64 1
        return $this->result;
65
    }
66
67
    /**
68
     * @param $result
69
     *
70
     * @throws LogicException
71
     */
72 7
    public function setResult($result)
73
    {
74 7
        $results = [];
75 7
        if (!\is_array($result)) {
76
            $this->result = $results;
77
78
            return;
79
        }
80
81 7
        foreach ($result as $data) {
82 7
            $results[] = $this->zoneResultsFactory->create($data);
83
        }
84 7
        $this->result = $results;
85 7
    }
86
}
87