Completed
Push — master ( d43c57...4eaf6e )
by Ross
02:31
created

AbstractClass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 34
rs 10
c 0
b 0
f 0

2 Methods

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