@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | abstract class Schema |
6 | 6 | { |
7 | - const SCHEMA_TYPES = [ |
|
7 | + const SCHEMA_TYPES = [ |
|
8 | 8 | 'array', |
9 | 9 | 'boolean', |
10 | 10 | 'integer', |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @param string $path |
19 | 19 | * @return static |
20 | 20 | */ |
21 | - public static function fromFile($path) |
|
21 | + public static function fromFile($path) |
|
22 | 22 | { |
23 | 23 | return self::make(json_decode(file_get_contents($path))); |
24 | 24 | } |
@@ -26,13 +26,13 @@ discard block |
||
26 | 26 | /** |
27 | 27 | * @param object $json |
28 | 28 | */ |
29 | - public static function make($json) |
|
29 | + public static function make($json) |
|
30 | 30 | { |
31 | - if (!isset($json->type)) { |
|
31 | + if (!isset($json->type)) { |
|
32 | 32 | throw new \InvalidArgumentException('Missing schema type.'); |
33 | 33 | } |
34 | 34 | |
35 | - if (!in_array(strtolower($json->type), self::SCHEMA_TYPES)) { |
|
35 | + if (!in_array(strtolower($json->type), self::SCHEMA_TYPES)) { |
|
36 | 36 | throw new \InvalidArgumentException(sprintf( |
37 | 37 | 'No schema type available for %s.', |
38 | 38 | $json->type |
@@ -54,50 +54,50 @@ discard block |
||
54 | 54 | $this->schema = $schema; |
55 | 55 | } |
56 | 56 | |
57 | - public function type() |
|
57 | + public function type() |
|
58 | 58 | { |
59 | 59 | return $this->schema->type; |
60 | 60 | } |
61 | 61 | |
62 | - abstract public function phpType(); |
|
62 | + abstract public function phpType(); |
|
63 | 63 | |
64 | - public function isArray() |
|
64 | + public function isArray() |
|
65 | 65 | { |
66 | 66 | return $this->type() === 'array'; |
67 | 67 | } |
68 | 68 | |
69 | - public function isBoolean() |
|
69 | + public function isBoolean() |
|
70 | 70 | { |
71 | 71 | return $this->type() === 'boolean'; |
72 | 72 | } |
73 | 73 | |
74 | - public function isInteger() |
|
74 | + public function isInteger() |
|
75 | 75 | { |
76 | 76 | return $this->type() === 'integer'; |
77 | 77 | } |
78 | 78 | |
79 | - public function isNull() |
|
79 | + public function isNull() |
|
80 | 80 | { |
81 | 81 | return $this->type() === 'null'; |
82 | 82 | } |
83 | 83 | |
84 | - public function isNumber() |
|
84 | + public function isNumber() |
|
85 | 85 | { |
86 | 86 | return $this->type() === 'number'; |
87 | 87 | } |
88 | 88 | |
89 | - public function isObject() |
|
89 | + public function isObject() |
|
90 | 90 | { |
91 | 91 | return $this->type() === 'object'; |
92 | 92 | } |
93 | 93 | |
94 | - public function isString() |
|
94 | + public function isString() |
|
95 | 95 | { |
96 | 96 | return $this->type() === 'string'; |
97 | 97 | } |
98 | 98 | |
99 | - public function title() |
|
99 | + public function title() |
|
100 | 100 | { |
101 | - return $this->schema->title ? $this->schema->title : ''; |
|
101 | + return $this->schema->title ? $this->schema->title : ''; |
|
102 | 102 | } |
103 | 103 | } |