@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function __construct($name, $class) |
33 | 33 | { |
34 | - $this->name = $name; |
|
35 | - $this->class = $class; |
|
34 | + $this->name=$name; |
|
35 | + $this->class=$class; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | )); |
57 | 57 | } |
58 | 58 | |
59 | - $refClass = new \ReflectionClass($this->class); |
|
59 | + $refClass=new \ReflectionClass($this->class); |
|
60 | 60 | if (!$refClass->isInstance($value)) { |
61 | 61 | throw new Exception\InvalidArgumentException( |
62 | 62 | 'Value of the field "'.$this->name.'" must an instance of ArgumentBuilderInterface' |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | trait SortableArgumentBuilderTrait |
13 | 13 | { |
14 | - public static function buildSortDirection($value, $direction = self::SORT_ASC) |
|
14 | + public static function buildSortDirection($value, $direction=self::SORT_ASC) |
|
15 | 15 | { |
16 | 16 | return $direction.$value; |
17 | 17 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | private function validateSort($value, array $values) |
20 | 20 | { |
21 | 21 | if (0 === mb_strpos($value, self::SORT_DESC)) { |
22 | - $value = mb_substr($value, 1); |
|
22 | + $value=mb_substr($value, 1); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | return in_array($value, $values, true); |
@@ -11,6 +11,6 @@ |
||
11 | 11 | */ |
12 | 12 | interface SortableArgumentBuilderInterface |
13 | 13 | { |
14 | - const SORT_ASC = ''; |
|
15 | - const SORT_DESC = '-'; |
|
14 | + const SORT_ASC=''; |
|
15 | + const SORT_DESC='-'; |
|
16 | 16 | } |
@@ -15,15 +15,15 @@ discard block |
||
15 | 15 | */ |
16 | 16 | abstract class AbstractArgumentBuilder implements ArgumentBuilderInterface |
17 | 17 | { |
18 | - public const ARGUMENT_TYPE_MIXED = 0; |
|
19 | - public const ARGUMENT_TYPE_ARGUMENT_BUILDER = 1; |
|
20 | - public const ARGUMENT_TYPE_NUMERIC = 2; |
|
21 | - public const ARGUMENT_TYPE_ENUM = 3; |
|
22 | - public const ARGUMENT_TYPE_BOOLEAN = 4; |
|
18 | + public const ARGUMENT_TYPE_MIXED=0; |
|
19 | + public const ARGUMENT_TYPE_ARGUMENT_BUILDER=1; |
|
20 | + public const ARGUMENT_TYPE_NUMERIC=2; |
|
21 | + public const ARGUMENT_TYPE_ENUM=3; |
|
22 | + public const ARGUMENT_TYPE_BOOLEAN=4; |
|
23 | 23 | |
24 | - protected $args = array(); |
|
24 | + protected $args=array(); |
|
25 | 25 | |
26 | - protected $fields = array( |
|
26 | + protected $fields=array( |
|
27 | 27 | //'arg1' => self::ARGUMENT_TYPE_MIXED, |
28 | 28 | //'arg2' => SomeArgumentBuilder::class, |
29 | 29 | ); |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | */ |
48 | 48 | private function camelCaseToSnakeCase($str) |
49 | 49 | { |
50 | - $str[0] = strtolower($str[0]); |
|
50 | + $str[0]=strtolower($str[0]); |
|
51 | 51 | |
52 | - return preg_replace_callback('/([A-Z])/', function ($c) { |
|
52 | + return preg_replace_callback('/([A-Z])/', function($c) { |
|
53 | 53 | return '_'.strtolower($c[1]); |
54 | 54 | }, $str); |
55 | 55 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | foreach ($this->fields as $name => $field) { |
77 | 77 | // Consider string value as a class name |
78 | 78 | if (is_string($field)) { |
79 | - $this->fields[$name] = array( |
|
79 | + $this->fields[$name]=array( |
|
80 | 80 | 'type' => self::ARGUMENT_TYPE_ARGUMENT_BUILDER, |
81 | 81 | 'class' => $field, |
82 | 82 | 'validator' => new ArgumentBuilderTypeValidator($name, $field), |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | // consider numeric values as type name |
86 | 86 | } elseif (is_int($field)) { |
87 | - $this->fields[$name] = array( |
|
87 | + $this->fields[$name]=array( |
|
88 | 88 | 'type' => $field, |
89 | 89 | 'validator' => null, |
90 | 90 | ); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | return true; |
138 | 138 | } |
139 | 139 | |
140 | - $validator = $this->fields[$field]['validator']; |
|
140 | + $validator=$this->fields[$field]['validator']; |
|
141 | 141 | |
142 | 142 | if ($validator instanceof TypeValidatorInterface) { |
143 | 143 | return $validator->validate($value); |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | throw new Exception\UnmatchedCallTypeException(); |
191 | 191 | } |
192 | 192 | |
193 | - $field = lcfirst($matches[1]); |
|
194 | - $field = $this->camelCaseToSnakeCase($field); |
|
193 | + $field=lcfirst($matches[1]); |
|
194 | + $field=$this->camelCaseToSnakeCase($field); |
|
195 | 195 | |
196 | 196 | if (!array_key_exists($field, $this->fields)) { |
197 | 197 | throw new Exception\UndefinedMethodException($name); |
@@ -234,11 +234,11 @@ discard block |
||
234 | 234 | throw new Exception\UnmatchedCallTypeException(); |
235 | 235 | } |
236 | 236 | |
237 | - $field = $matches[1]; |
|
237 | + $field=$matches[1]; |
|
238 | 238 | if ($field[0] !== '-') { |
239 | - $field = lcfirst($matches[1]); |
|
239 | + $field=lcfirst($matches[1]); |
|
240 | 240 | } |
241 | - $field = $this->camelCaseToSnakeCase($field); |
|
241 | + $field=$this->camelCaseToSnakeCase($field); |
|
242 | 242 | |
243 | 243 | if (!array_key_exists($field, $this->fields)) { |
244 | 244 | throw new Exception\UndefinedMethodException($name); |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | throw new Exception\InvalidArgumentException('Method '.__CLASS__.'::'.$name.'() must take exactly 1 argument'); |
249 | 249 | } |
250 | 250 | |
251 | - $value = $arguments[0]; |
|
251 | + $value=$arguments[0]; |
|
252 | 252 | |
253 | 253 | if (self::ARGUMENT_TYPE_ARGUMENT_BUILDER === $this->fields[$field]['type'] && count($arguments) > 1) { |
254 | 254 | if (!is_string($arguments[0])) { |
@@ -257,15 +257,15 @@ discard block |
||
257 | 257 | ); |
258 | 258 | } |
259 | 259 | |
260 | - $class = $this->fields[$field]['class']; |
|
261 | - $value = isset($this->args[$field]) ? $this->args[$field] : new $class(); |
|
260 | + $class=$this->fields[$field]['class']; |
|
261 | + $value=isset($this->args[$field]) ? $this->args[$field] : new $class(); |
|
262 | 262 | |
263 | 263 | call_user_func_array(array($value, 'set'.$this->snakeCaseToCamelCase($arguments[0])), array_slice($arguments, 1)); |
264 | 264 | } elseif (!$this->validateFieldValue($field, $value)) { |
265 | 265 | throw new Exception\InvalidArgumentException(sprintf('Invalid value "%s" for field "%s"', $value, $field)); |
266 | 266 | } |
267 | 267 | |
268 | - $this->args[$field] = $value; |
|
268 | + $this->args[$field]=$value; |
|
269 | 269 | |
270 | 270 | return $this; |
271 | 271 | } |
@@ -287,11 +287,11 @@ discard block |
||
287 | 287 | throw new Exception\UnmatchedCallTypeException(); |
288 | 288 | } |
289 | 289 | |
290 | - $field = $matches[1]; |
|
290 | + $field=$matches[1]; |
|
291 | 291 | if ($field[0] !== '-') { |
292 | - $field = lcfirst($matches[1]); |
|
292 | + $field=lcfirst($matches[1]); |
|
293 | 293 | } |
294 | - $field = $this->camelCaseToSnakeCase($field); |
|
294 | + $field=$this->camelCaseToSnakeCase($field); |
|
295 | 295 | |
296 | 296 | // Check if field is defined for this ArgumentBuilder |
297 | 297 | if (!array_key_exists($field, $this->fields)) { |
@@ -348,13 +348,13 @@ discard block |
||
348 | 348 | */ |
349 | 349 | public function build() |
350 | 350 | { |
351 | - $result = array(); |
|
351 | + $result=array(); |
|
352 | 352 | |
353 | 353 | foreach ($this->args as $key => $arg) { |
354 | 354 | if ($arg instanceof ArgumentBuilderInterface) { |
355 | - $result[$key] = $arg->build(); //@todo: missing Circular Reference check |
|
355 | + $result[$key]=$arg->build(); //@todo: missing Circular Reference check |
|
356 | 356 | } else { |
357 | - $result[$key] = $this->transformValue($key, $arg); |
|
357 | + $result[$key]=$this->transformValue($key, $arg); |
|
358 | 358 | } |
359 | 359 | } |
360 | 360 |