AbstractClass::getExampleJson()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php declare(strict_types = 1);
2
/**
3
 *
4
 * Copyright (C) 2018  Ross Mitchell
5
 *
6
 * This file is part of RossMitchell/UpdateCloudFlare.
7
 *
8
 * RossMitchell/UpdateCloudFlare is free software: you can redistribute
9
 * it and/or modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation, either version 3 of the
11
 * License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
 */
21
22
namespace RossMitchell\UpdateCloudFlare\Tests\Responses\Results\ListZoneResult;
23
24
use RossMitchell\UpdateCloudFlare\Factories\Responses\Results\ListZoneResultsFactory;
25
use RossMitchell\UpdateCloudFlare\Responses\Results\ListZonesResult;
26
use RossMitchell\UpdateCloudFlare\Tests\AbstractTestClass;
27
use RossMitchell\UpdateCloudFlare\Tests\Fakes\Helpers\ListZonesResponse;
28
29
/**
30
 * Class AbstractClass
31
 * @testdox RossMitchell\UpdateCloudFlare\Responses\Results\ListZonesResult
32
 * @package RossMitchell\UpdateCloudFlare\Tests\Responses\Results\ListZoneResult
33
 */
34
class AbstractClass extends AbstractTestClass
35
{
36
    /**
37
     * @Inject
38
     * @var ListZoneResultsFactory
39
     */
40
    private $factory;
41
42
    /**
43
     * @Inject
44
     * @var ListZonesResponse
45
     */
46
    private $responseHelper;
47
48
    /**
49
     * @param \stdClass|null $json
50
     *
51
     * @return ListZonesResult
52
     */
53
    protected function createClass(\stdClass $json = null): ListZonesResult
54
    {
55
        if ($json === null) {
56
            $json = $this->getExampleJson();
57
        }
58
59
        return $this->factory->create($json);
60
    }
61
62
    /**
63
     * Taken from here https://api.cloudflare.com/#zone-list-zones
64
     * @return \stdClass
65
     */
66
    protected function getExampleJson(): \stdClass
67
    {
68
        $data = $this->responseHelper->getResultJson();
69
70
        return \json_decode($data);
71
    }
72
}
73