GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Base::toSchema()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 11
cts 11
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 0
crap 1
1
<?php
2
namespace Solvire\API\JSONSchema;
3
4
use Solvire\Utilities\OptionsChecker as Ch;
5
use Solvire\Application as Ev;
6
7
/**
8
 * Base of the schema
9
 * 
10
 * @author solvire <[email protected]>
11
 * @package JSONSchema
12
 * @namespace Solvire\API\JSONSchema
13
 */
14
class Base implements Schemable
15
{
16
17
    /**
18
     * basically application name
19
     * 
20
     * @var string $name
21
     */
22
    protected $name = null;
23
24
    /**
25
     *
26
     * @var string
27
     */
28
    protected $id = null;
29
30
    /**
31
     *
32
     * @var string
33
     */
34
    protected $version = null;
35
36
    /**
37
     *
38
     * @var string
39
     */
40
    protected $baseUrl = null;
41
42
    /**
43
     *
44
     * @var string
45
     */
46
    protected $basePath = null;
47
48
    /**
49
     *
50
     * @var string
51
     */
52
    protected $documentationUrl = null;
53
54
    /**
55
     *
56
     * @var string
57
     */
58
    protected $description = null;
59
60
    /**
61
     *
62
     * @var array $mandatoryFields
63
     */
64
    protected $mandatoryFields = [
65
        'id',
66
        'baseUrl',
67
        'basePath',
68
        'documentationUrl',
69
        'version',
70
        'description'
71
    ];
72
73
    /**
74
     *
75
     * @param array $options            
76
     */
77 3
    public function __construct(array $options = null)
78
    {
79 3
        if (isset($options)) {
80
            foreach ($options as $key => $value) {
81
                if (method_exists(self, $key))
82
                    $this->$key = $value;
83
            }
84
        }
85 3
    }
86
87
    /**
88
     *
89
     * @param string $name            
90
     */
91 3
    public function setName($name)
92
    {
93 3
        $this->name = $name;
94 3
    }
95
96 3
    public function setId($id)
97
    {
98 3
        $this->id = $id;
99 3
    }
100
101 3
    public function setVersion($version)
102
    {
103 3
        $this->version = $version;
104 3
    }
105
106
    /**
107
     *
108
     * @param string $baseUrl            
109
     */
110 3
    public function setBaseUrl($baseUrl)
111
    {
112 3
        $this->baseUrl = $baseUrl;
113 3
    }
114
115
    /**
116
     *
117
     * @param string $basePath            
118
     */
119 3
    public function setBasePath($basePath)
120
    {
121 3
        $this->basePath = $basePath;
122 3
    }
123
124
    /**
125
     *
126
     * @param string $documentationUrl            
127
     */
128 3
    public function setDocumentationUrl($documentationUrl)
129
    {
130 3
        $this->documentationUrl = $documentationUrl;
131 3
    }
132
133
    /**
134
     *
135
     * @param string $description            
136
     */
137 3
    public function setDescription($description)
138
    {
139 3
        $this->description = $description;
140 3
    }
141
142
    /**
143
     *
144
     *
145
     * (non-PHPdoc)
146
     * 
147
     * @see \Solvire\API\JSONSchema\Schemable::allSet()
148
     * @return s true or blows up
149
     */
150 3
    public function allSet()
151
    {
152 3
        $errors = [];
153 3
        foreach ($this->mandatoryFields as $field) {
154 3
            if (! isset($this->$field) || $this->$field === null || $this->$field === '')
155 3
                $errors[$field] = "Error the field: $field must be set in Base.";
156 3
        }
157
        
158 3
        if (count($errors))
159 3
            throw new \RuntimeException('Errors . ' . print_r($errors, 1));
160
        
161 2
        return true;
162
    }
163
164
    /**
165
     * dish it up
166
     * (non-PHPdoc)
167
     * 
168
     * @see \Solvire\API\JSONSchema\Schemable::toSchema()
169
     */
170 3
    public function toSchema()
171
    {
172 3
        $this->allSet();
173
        
174
        return [
175 2
            'id' => $this->id,
176 2
            'basePath' => $this->basePath,
177 2
            'baseUrl' => $this->baseUrl,
178 2
            'documentationUrl' => $this->documentationUrl,
179 2
            'name' => $this->name,
180 2
            '$schema' => 'http://json-schema.org/draft-04/schema#',
181 2
            'version' => $this->version,
182 2
            'description' => $this->description
183 2
        ];
184
    }
185
}
186
187