AbstractClass::getJson()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
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\Tests\Responses\Results\DnsRecord;
24
25
use RossMitchell\UpdateCloudFlare\Factories\Responses\Results\DnsRecordFactory;
26
use RossMitchell\UpdateCloudFlare\Responses\Results\DnsRecord;
27
use RossMitchell\UpdateCloudFlare\Tests\AbstractTestClass;
28
use RossMitchell\UpdateCloudFlare\Tests\Fakes\Helpers\DnsRecordsResponse;
29
30
/**
31
 * Class AbstractClass
32
 * @package RossMitchell\UpdateCloudFlare\Tests\Responses\Results\DnsRecord
33
 */
34
abstract class AbstractClass extends AbstractTestClass
35
{
36
    /**
37
     * @Inject
38
     * @var DnsRecordFactory
39
     */
40
    private $factory;
41
42
    /**
43
     * @Inject
44
     * @var DnsRecordsResponse
45
     */
46
    private $responseHelper;
47
48
    /**
49
     * @param \stdClass|null $json
50
     *
51
     * @return DnsRecord
52
     */
53
    public function createClass(\stdClass $json = null): DnsRecord
54
    {
55
        if ($json === null) {
56
            $json = $this->getJson();
57
        }
58
59
        return $this->factory->create($json);
60
    }
61
62
    /**
63
     * @return \stdClass
64
     */
65
    public function getJson(): \stdClass
66
    {
67
        return \json_decode($this->responseHelper->getResultJson());
68
    }
69
}
70