AbstractCloudFlareResponse   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 42
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getFullJson() 0 17 2
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\Fakes\Helpers;
23
24
/**
25
 * Class AbstractCloudFlareResponse
26
 * @package RossMitchell\UpdateCloudFlare\Tests\Fakes\Helpers
27
 */
28
abstract class AbstractCloudFlareResponse
29
{
30
    protected $resultIsArray = true;
31
32
    /**
33
     * @param string $success
34
     * @param string $errors
35
     *
36
     * @return string
37
     */
38
    public function getFullJson(string $success = 'true', string $errors = '{}'): string
39
    {
40
        $result = $this->getResultJson();
41
        if ($this->resultIsArray === true) {
42
            $result = "[ $result ]";
43
        }
44
45
        return <<<JSON
46
{
47
  "success": $success,
48
  "errors": [
49
    $errors
50
  ],
51
  "messages": [
52
    {}
53
  ],
54
  "result": $result,
55
  "result_info": {
56
    "page": 1,
57
    "per_page": 20,
58
    "count": 1,
59
    "total_count": 2000
60
  }
61
}
62
JSON;
63
64
    }
65
66
    /**
67
     * @return string
68
     */
69
    abstract public function getResultJson(): string;
70
}
71