@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | * @param $property |
27 | 27 | * @throws \Exception |
28 | 28 | */ |
29 | - public function __get( $property ) |
|
29 | + public function __get($property) |
|
30 | 30 | { |
31 | - throw new \Exception( "Non-existent property {$property} get in " . get_class( $this ) ); |
|
31 | + throw new \Exception("Non-existent property {$property} get in ".get_class($this)); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | * @param $value |
38 | 38 | * @throws \Exception |
39 | 39 | */ |
40 | - public function __set( $property, $value ) |
|
40 | + public function __set($property, $value) |
|
41 | 41 | { |
42 | - throw new \Exception( "Non-existent property {$property} set in " . get_class( $this ) ); |
|
42 | + throw new \Exception("Non-existent property {$property} set in ".get_class($this)); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -48,12 +48,12 @@ discard block |
||
48 | 48 | * @param bool $discardInvalidEntries If set to true, entries in $properties for which there is no corresponding class member will be discarded instead of generating an error |
49 | 49 | * @return StructClass |
50 | 50 | */ |
51 | - public static function fromArray( array $properties, $discardInvalidEntries = false ) |
|
51 | + public static function fromArray(array $properties, $discardInvalidEntries = false) |
|
52 | 52 | { |
53 | 53 | $selfClass = get_called_class(); |
54 | 54 | $obj = new $selfClass(); |
55 | - foreach( $properties as $property=>$value ){ |
|
56 | - if( (! property_exists( get_called_class(), $property ) ) && $discardInvalidEntries ){ |
|
55 | + foreach ($properties as $property=>$value) { |
|
56 | + if (( ! property_exists(get_called_class(), $property)) && $discardInvalidEntries) { |
|
57 | 57 | continue; |
58 | 58 | } |
59 | 59 | $obj->$property = $value; |
@@ -94,32 +94,32 @@ discard block |
||
94 | 94 | $validator = Validation::createValidatorBuilder()->addDefaultDoctrineAnnotationReader()->enableAnnotationMapping()->getValidator(); |
95 | 95 | $violations = $validator->validate($this); |
96 | 96 | $errs = ''; |
97 | - if( $violations->count() > 0 ){ |
|
97 | + if ($violations->count() > 0) { |
|
98 | 98 | $errs = 'Invalid properties in '.get_called_class()."\n"; |
99 | 99 | /** @var \Symfony\Component\Validator\ConstraintViolationInterface $issue */ |
100 | - foreach( $violations as $issue ){ |
|
100 | + foreach ($violations as $issue) { |
|
101 | 101 | $errs .= |
102 | 102 | $issue->getPropertyPath() |
103 | 103 | ." : " |
104 | 104 | .$issue->getMessage() |
105 | 105 | . " But got " |
106 | - . var_export( $issue->getInvalidValue(), true ); |
|
106 | + . var_export($issue->getInvalidValue(), true); |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | // Validate any properties which are StructClasses or are arrays containing StructClasses |
110 | 110 | foreach ($this as $property) { |
111 | 111 | if ($property instanceof StructClass) { |
112 | - try{ |
|
112 | + try { |
|
113 | 113 | $property->validate(); |
114 | - }catch( \Exception $e ){ |
|
114 | + }catch (\Exception $e) { |
|
115 | 115 | $errs .= $e->getMessage(); |
116 | 116 | } |
117 | - }elseif (is_array( $property )) { |
|
117 | + }elseif (is_array($property)) { |
|
118 | 118 | foreach ($property as $element) { |
119 | 119 | if ($element instanceof StructClass) { |
120 | - try{ |
|
120 | + try { |
|
121 | 121 | $element->validate(); |
122 | - }catch( \Exception $e ){ |
|
122 | + }catch (\Exception $e) { |
|
123 | 123 | $errs .= $e->getMessage(); |
124 | 124 | } |
125 | 125 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | } |
128 | 128 | } |
129 | 129 | if ($errs != '') { |
130 | - throw new \Exception( $errs ); |
|
130 | + throw new \Exception($errs); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 |