@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | */ |
15 | 15 | class JsonDecodingException extends RuntimeException |
16 | 16 | { |
17 | - public function __construct($code = JSON_ERROR_NONE, \Exception $previous = null) |
|
17 | + public function __construct( $code = JSON_ERROR_NONE, \Exception $previous = null ) |
|
18 | 18 | { |
19 | - switch ($code) { |
|
19 | + switch ( $code ) { |
|
20 | 20 | case JSON_ERROR_DEPTH: |
21 | 21 | $message = 'The maximum stack depth has been exceeded'; |
22 | 22 | break; |
@@ -35,6 +35,6 @@ discard block |
||
35 | 35 | default: |
36 | 36 | $message = 'Syntax error'; |
37 | 37 | } |
38 | - parent::__construct($message, $code, $previous); |
|
38 | + parent::__construct( $message, $code, $previous ); |
|
39 | 39 | } |
40 | 40 | } |
@@ -22,5 +22,5 @@ |
||
22 | 22 | * |
23 | 23 | * @return string Absolute URI |
24 | 24 | */ |
25 | - public function resolve($uri, $baseUri = null); |
|
25 | + public function resolve( $uri, $baseUri = null ); |
|
26 | 26 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @param string $id |
11 | 11 | * @param object $schema |
12 | 12 | */ |
13 | - public function addSchema($id, $schema = null); |
|
13 | + public function addSchema( $id, $schema = null ); |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Returns schema for given identifier, or null if it does not exist |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * |
20 | 20 | * @return object |
21 | 21 | */ |
22 | - public function getSchema($id); |
|
22 | + public function getSchema( $id ); |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * Returns schema for given reference with all sub-references resolved |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return object |
30 | 30 | */ |
31 | - public function resolveRef($ref); |
|
31 | + public function resolveRef( $ref ); |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Returns schema referenced by '$ref' property |
@@ -37,5 +37,5 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @return object |
39 | 39 | */ |
40 | - public function resolveRefSchema($refSchema); |
|
40 | + public function resolveRefSchema( $refSchema ); |
|
41 | 41 | } |
@@ -36,36 +36,36 @@ discard block |
||
36 | 36 | * |
37 | 37 | * Note that the first argument is passed by reference, so you must pass in a variable. |
38 | 38 | */ |
39 | - public function validate(&$value, $schema = null, $checkMode = null) |
|
39 | + public function validate( &$value, $schema = null, $checkMode = null ) |
|
40 | 40 | { |
41 | 41 | // make sure $schema is an object |
42 | - if (is_array($schema)) { |
|
43 | - $schema = self::arrayToObjectRecursive($schema); |
|
42 | + if ( is_array( $schema ) ) { |
|
43 | + $schema = self::arrayToObjectRecursive( $schema ); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | // set checkMode |
47 | 47 | $initialCheckMode = $this->factory->getConfig(); |
48 | - if ($checkMode !== null) { |
|
49 | - $this->factory->setConfig($checkMode); |
|
48 | + if ( $checkMode !== null ) { |
|
49 | + $this->factory->setConfig( $checkMode ); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | // add provided schema to SchemaStorage with internal URI to allow internal $ref resolution |
53 | - if (is_object($schema) && property_exists($schema, 'id')) { |
|
53 | + if ( is_object( $schema ) && property_exists( $schema, 'id' ) ) { |
|
54 | 54 | $schemaURI = $schema->id; |
55 | 55 | } else { |
56 | 56 | $schemaURI = SchemaStorage::INTERNAL_PROVIDED_SCHEMA_URI; |
57 | 57 | } |
58 | - $this->factory->getSchemaStorage()->addSchema($schemaURI, $schema); |
|
58 | + $this->factory->getSchemaStorage()->addSchema( $schemaURI, $schema ); |
|
59 | 59 | |
60 | - $validator = $this->factory->createInstanceFor('schema'); |
|
60 | + $validator = $this->factory->createInstanceFor( 'schema' ); |
|
61 | 61 | $validator->check( |
62 | 62 | $value, |
63 | - $this->factory->getSchemaStorage()->getSchema($schemaURI) |
|
63 | + $this->factory->getSchemaStorage()->getSchema( $schemaURI ) |
|
64 | 64 | ); |
65 | 65 | |
66 | - $this->factory->setConfig($initialCheckMode); |
|
66 | + $this->factory->setConfig( $initialCheckMode ); |
|
67 | 67 | |
68 | - $this->addErrors(array_unique($validator->getErrors(), SORT_REGULAR)); |
|
68 | + $this->addErrors( array_unique( $validator->getErrors(), SORT_REGULAR ) ); |
|
69 | 69 | |
70 | 70 | return $validator->getErrorMask(); |
71 | 71 | } |
@@ -73,16 +73,16 @@ discard block |
||
73 | 73 | /** |
74 | 74 | * Alias to validate(), to maintain backwards-compatibility with the previous API |
75 | 75 | */ |
76 | - public function check($value, $schema) |
|
76 | + public function check( $value, $schema ) |
|
77 | 77 | { |
78 | - return $this->validate($value, $schema); |
|
78 | + return $this->validate( $value, $schema ); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Alias to validate(), to maintain backwards-compatibility with the previous API |
83 | 83 | */ |
84 | - public function coerce(&$value, $schema) |
|
84 | + public function coerce( &$value, $schema ) |
|
85 | 85 | { |
86 | - return $this->validate($value, $schema, Constraint::CHECK_MODE_COERCE_TYPES); |
|
86 | + return $this->validate( $value, $schema, Constraint::CHECK_MODE_COERCE_TYPES ); |
|
87 | 87 | } |
88 | 88 | } |
@@ -34,16 +34,16 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @throws InvalidArgumentException when $value is not a string |
36 | 36 | */ |
37 | - public function __construct($value) |
|
37 | + public function __construct( $value ) |
|
38 | 38 | { |
39 | - if (!is_string($value)) { |
|
40 | - throw new InvalidArgumentException('Ref value must be a string'); |
|
39 | + if ( ! is_string( $value ) ) { |
|
40 | + throw new InvalidArgumentException( 'Ref value must be a string' ); |
|
41 | 41 | } |
42 | 42 | |
43 | - $splitRef = explode('#', $value, 2); |
|
44 | - $this->filename = $splitRef[0]; |
|
45 | - if (array_key_exists(1, $splitRef)) { |
|
46 | - $this->propertyPaths = $this->decodePropertyPaths($splitRef[1]); |
|
43 | + $splitRef = explode( '#', $value, 2 ); |
|
44 | + $this->filename = $splitRef[ 0 ]; |
|
45 | + if ( array_key_exists( 1, $splitRef ) ) { |
|
46 | + $this->propertyPaths = $this->decodePropertyPaths( $splitRef[ 1 ] ); |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return string[] |
54 | 54 | */ |
55 | - private function decodePropertyPaths($propertyPathString) |
|
55 | + private function decodePropertyPaths( $propertyPathString ) |
|
56 | 56 | { |
57 | 57 | $paths = array(); |
58 | - foreach (explode('/', trim($propertyPathString, '/')) as $path) { |
|
59 | - $path = $this->decodePath($path); |
|
60 | - if (is_string($path) && '' !== $path) { |
|
61 | - $paths[] = $path; |
|
58 | + foreach ( explode( '/', trim( $propertyPathString, '/' ) ) as $path ) { |
|
59 | + $path = $this->decodePath( $path ); |
|
60 | + if ( is_string( $path ) && '' !== $path ) { |
|
61 | + $paths[ ] = $path; |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | private function encodePropertyPaths() |
72 | 72 | { |
73 | 73 | return array_map( |
74 | - array($this, 'encodePath'), |
|
74 | + array( $this, 'encodePath' ), |
|
75 | 75 | $this->getPropertyPaths() |
76 | 76 | ); |
77 | 77 | } |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @return string |
83 | 83 | */ |
84 | - private function decodePath($path) |
|
84 | + private function decodePath( $path ) |
|
85 | 85 | { |
86 | - return strtr($path, array('~1' => '/', '~0' => '~', '%25' => '%')); |
|
86 | + return strtr( $path, array( '~1' => '/', '~0' => '~', '%25' => '%' ) ); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @return string |
93 | 93 | */ |
94 | - private function encodePath($path) |
|
94 | + private function encodePath( $path ) |
|
95 | 95 | { |
96 | - return strtr($path, array('/' => '~1', '~' => '~0', '%' => '%25')); |
|
96 | + return strtr( $path, array( '/' => '~1', '~' => '~0', '%' => '%25' ) ); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * |
118 | 118 | * @return JsonPointer |
119 | 119 | */ |
120 | - public function withPropertyPaths(array $propertyPaths) |
|
120 | + public function withPropertyPaths( array $propertyPaths ) |
|
121 | 121 | { |
122 | 122 | $new = clone $this; |
123 | 123 | $new->propertyPaths = $propertyPaths; |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function getPropertyPathAsString() |
132 | 132 | { |
133 | - return rtrim('#/' . implode('/', $this->encodePropertyPaths()), '/'); |
|
133 | + return rtrim( '#/' . implode( '/', $this->encodePropertyPaths() ), '/' ); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -22,5 +22,5 @@ |
||
22 | 22 | * |
23 | 23 | * @return object JSON Schema contents |
24 | 24 | */ |
25 | - public function retrieve($uri, $baseUri = null); |
|
25 | + public function retrieve( $uri, $baseUri = null ); |
|
26 | 26 | } |
@@ -4,54 +4,54 @@ discard block |
||
4 | 4 | |
5 | 5 | class LooseTypeCheck implements TypeCheckInterface |
6 | 6 | { |
7 | - public static function isObject($value) |
|
7 | + public static function isObject( $value ) |
|
8 | 8 | { |
9 | 9 | return |
10 | - is_object($value) || |
|
11 | - (is_array($value) && (count($value) == 0 || self::isAssociativeArray($value))); |
|
10 | + is_object( $value ) || |
|
11 | + ( is_array( $value ) && ( count( $value ) == 0 || self::isAssociativeArray( $value ) ) ); |
|
12 | 12 | } |
13 | 13 | |
14 | - public static function isArray($value) |
|
14 | + public static function isArray( $value ) |
|
15 | 15 | { |
16 | 16 | return |
17 | - is_array($value) && |
|
18 | - (count($value) == 0 || !self::isAssociativeArray($value)); |
|
17 | + is_array( $value ) && |
|
18 | + ( count( $value ) == 0 || ! self::isAssociativeArray( $value ) ); |
|
19 | 19 | } |
20 | 20 | |
21 | - public static function propertyGet($value, $property) |
|
21 | + public static function propertyGet( $value, $property ) |
|
22 | 22 | { |
23 | - if (is_object($value)) { |
|
23 | + if ( is_object( $value ) ) { |
|
24 | 24 | return $value->{$property}; |
25 | 25 | } |
26 | 26 | |
27 | - return $value[$property]; |
|
27 | + return $value[ $property ]; |
|
28 | 28 | } |
29 | 29 | |
30 | - public static function propertySet(&$value, $property, $data) |
|
30 | + public static function propertySet( &$value, $property, $data ) |
|
31 | 31 | { |
32 | - if (is_object($value)) { |
|
32 | + if ( is_object( $value ) ) { |
|
33 | 33 | $value->{$property} = $data; |
34 | 34 | } else { |
35 | - $value[$property] = $data; |
|
35 | + $value[ $property ] = $data; |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | - public static function propertyExists($value, $property) |
|
39 | + public static function propertyExists( $value, $property ) |
|
40 | 40 | { |
41 | - if (is_object($value)) { |
|
42 | - return property_exists($value, $property); |
|
41 | + if ( is_object( $value ) ) { |
|
42 | + return property_exists( $value, $property ); |
|
43 | 43 | } |
44 | 44 | |
45 | - return array_key_exists($property, $value); |
|
45 | + return array_key_exists( $property, $value ); |
|
46 | 46 | } |
47 | 47 | |
48 | - public static function propertyCount($value) |
|
48 | + public static function propertyCount( $value ) |
|
49 | 49 | { |
50 | - if (is_object($value)) { |
|
51 | - return count(get_object_vars($value)); |
|
50 | + if ( is_object( $value ) ) { |
|
51 | + return count( get_object_vars( $value ) ); |
|
52 | 52 | } |
53 | 53 | |
54 | - return count($value); |
|
54 | + return count( $value ); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @return bool |
63 | 63 | */ |
64 | - private static function isAssociativeArray($arr) |
|
64 | + private static function isAssociativeArray( $arr ) |
|
65 | 65 | { |
66 | - return array_keys($arr) !== range(0, count($arr) - 1); |
|
66 | + return array_keys( $arr ) !== range( 0, count( $arr ) - 1 ); |
|
67 | 67 | } |
68 | 68 | } |
@@ -4,15 +4,15 @@ |
||
4 | 4 | |
5 | 5 | interface TypeCheckInterface |
6 | 6 | { |
7 | - public static function isObject($value); |
|
7 | + public static function isObject( $value ); |
|
8 | 8 | |
9 | - public static function isArray($value); |
|
9 | + public static function isArray( $value ); |
|
10 | 10 | |
11 | - public static function propertyGet($value, $property); |
|
11 | + public static function propertyGet( $value, $property ); |
|
12 | 12 | |
13 | - public static function propertySet(&$value, $property, $data); |
|
13 | + public static function propertySet( &$value, $property, $data ); |
|
14 | 14 | |
15 | - public static function propertyExists($value, $property); |
|
15 | + public static function propertyExists( $value, $property ); |
|
16 | 16 | |
17 | - public static function propertyCount($value); |
|
17 | + public static function propertyCount( $value ); |
|
18 | 18 | } |
@@ -4,37 +4,37 @@ |
||
4 | 4 | |
5 | 5 | class StrictTypeCheck implements TypeCheckInterface |
6 | 6 | { |
7 | - public static function isObject($value) |
|
7 | + public static function isObject( $value ) |
|
8 | 8 | { |
9 | - return is_object($value); |
|
9 | + return is_object( $value ); |
|
10 | 10 | } |
11 | 11 | |
12 | - public static function isArray($value) |
|
12 | + public static function isArray( $value ) |
|
13 | 13 | { |
14 | - return is_array($value); |
|
14 | + return is_array( $value ); |
|
15 | 15 | } |
16 | 16 | |
17 | - public static function propertyGet($value, $property) |
|
17 | + public static function propertyGet( $value, $property ) |
|
18 | 18 | { |
19 | 19 | return $value->{$property}; |
20 | 20 | } |
21 | 21 | |
22 | - public static function propertySet(&$value, $property, $data) |
|
22 | + public static function propertySet( &$value, $property, $data ) |
|
23 | 23 | { |
24 | 24 | $value->{$property} = $data; |
25 | 25 | } |
26 | 26 | |
27 | - public static function propertyExists($value, $property) |
|
27 | + public static function propertyExists( $value, $property ) |
|
28 | 28 | { |
29 | - return property_exists($value, $property); |
|
29 | + return property_exists( $value, $property ); |
|
30 | 30 | } |
31 | 31 | |
32 | - public static function propertyCount($value) |
|
32 | + public static function propertyCount( $value ) |
|
33 | 33 | { |
34 | - if (!is_object($value)) { |
|
34 | + if ( ! is_object( $value ) ) { |
|
35 | 35 | return 0; |
36 | 36 | } |
37 | 37 | |
38 | - return count(get_object_vars($value)); |
|
38 | + return count( get_object_vars( $value ) ); |
|
39 | 39 | } |
40 | 40 | } |