@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | /** |
24 | 24 | * @return string $field |
25 | 25 | */ |
26 | - public final function setField( $field ) |
|
26 | + public final function setField($field) |
|
27 | 27 | { |
28 | 28 | if (!is_scalar($field)) { |
29 | 29 | throw new \InvalidArgumentEXception( |
@@ -49,16 +49,16 @@ discard block |
||
49 | 49 | public final function renameField($renamings) |
50 | 50 | { |
51 | 51 | if (is_callable($renamings)) { |
52 | - $this->setField( call_user_func($renamings, $this->field) ); |
|
52 | + $this->setField(call_user_func($renamings, $this->field)); |
|
53 | 53 | } |
54 | 54 | elseif (is_array($renamings)) { |
55 | 55 | if (isset($renamings[$this->field])) |
56 | - $this->setField( $renamings[$this->field] ); |
|
56 | + $this->setField($renamings[$this->field]); |
|
57 | 57 | } |
58 | 58 | else { |
59 | 59 | throw new \InvalidArgumentException( |
60 | 60 | "\$renamings MUST be a callable or an associative array " |
61 | - ."instead of: " . var_export($renamings, true) |
|
61 | + ."instead of: ".var_export($renamings, true) |
|
62 | 62 | ); |
63 | 63 | } |
64 | 64 |
@@ -50,12 +50,11 @@ |
||
50 | 50 | { |
51 | 51 | if (is_callable($renamings)) { |
52 | 52 | $this->setField( call_user_func($renamings, $this->field) ); |
53 | - } |
|
54 | - elseif (is_array($renamings)) { |
|
55 | - if (isset($renamings[$this->field])) |
|
56 | - $this->setField( $renamings[$this->field] ); |
|
57 | - } |
|
58 | - else { |
|
53 | + } elseif (is_array($renamings)) { |
|
54 | + if (isset($renamings[$this->field])) { |
|
55 | + $this->setField( $renamings[$this->field] ); |
|
56 | + } |
|
57 | + } else { |
|
59 | 58 | throw new \InvalidArgumentException( |
60 | 59 | "\$renamings MUST be a callable or an associative array " |
61 | 60 | ."instead of: " . var_export($renamings, true) |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @return array |
23 | 23 | */ |
24 | - public function toArray(array $options=[]) |
|
24 | + public function toArray(array $options = []) |
|
25 | 25 | { |
26 | 26 | $default_options = [ |
27 | 27 | 'show_instance' => false, |
28 | 28 | ]; |
29 | 29 | foreach ($default_options as $default_option => &$default_value) { |
30 | - if (!isset($options[ $default_option ])) |
|
31 | - $options[ $default_option ] = $default_value; |
|
30 | + if (!isset($options[$default_option])) |
|
31 | + $options[$default_option] = $default_value; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | /** |
53 | 53 | */ |
54 | - public function toString(array $options=[]) |
|
54 | + public function toString(array $options = []) |
|
55 | 55 | { |
56 | 56 | if (!empty($this->cache['string'])) |
57 | 57 | return $this->cache['string']; |
@@ -27,13 +27,15 @@ discard block |
||
27 | 27 | 'show_instance' => false, |
28 | 28 | ]; |
29 | 29 | foreach ($default_options as $default_option => &$default_value) { |
30 | - if (!isset($options[ $default_option ])) |
|
31 | - $options[ $default_option ] = $default_value; |
|
30 | + if (!isset($options[ $default_option ])) { |
|
31 | + $options[ $default_option ] = $default_value; |
|
32 | + } |
|
32 | 33 | } |
33 | 34 | |
34 | 35 | |
35 | - if (!$options['show_instance'] && !empty($this->cache['array'])) |
|
36 | - return $this->cache['array']; |
|
36 | + if (!$options['show_instance'] && !empty($this->cache['array'])) { |
|
37 | + return $this->cache['array']; |
|
38 | + } |
|
37 | 39 | |
38 | 40 | $class = get_class($this); |
39 | 41 | |
@@ -43,18 +45,20 @@ discard block |
||
43 | 45 | $this->getValues(), |
44 | 46 | ]; |
45 | 47 | |
46 | - if (!$options['show_instance']) |
|
47 | - return $this->cache['array'] = $array; |
|
48 | - else |
|
49 | - return $array; |
|
48 | + if (!$options['show_instance']) { |
|
49 | + return $this->cache['array'] = $array; |
|
50 | + } else { |
|
51 | + return $array; |
|
52 | + } |
|
50 | 53 | } |
51 | 54 | |
52 | 55 | /** |
53 | 56 | */ |
54 | 57 | public function toString(array $options=[]) |
55 | 58 | { |
56 | - if (!empty($this->cache['string'])) |
|
57 | - return $this->cache['string']; |
|
59 | + if (!empty($this->cache['string'])) { |
|
60 | + return $this->cache['string']; |
|
61 | + } |
|
58 | 62 | |
59 | 63 | $class = get_class($this); |
60 | 64 | $operator = $class::operator; |
@@ -63,12 +67,13 @@ discard block |
||
63 | 67 | |
64 | 68 | $field = $this->getField(); |
65 | 69 | |
66 | - if ($field instanceof FilteredValue || $field instanceof FilteredKey) |
|
67 | - $field = "$field"; |
|
68 | - elseif ($field instanceof \Closure) |
|
69 | - throw new \Exception("Closures dump not implemented"); |
|
70 | - else |
|
71 | - $field = "'$field'"; |
|
70 | + if ($field instanceof FilteredValue || $field instanceof FilteredKey) { |
|
71 | + $field = "$field"; |
|
72 | + } elseif ($field instanceof \Closure) { |
|
73 | + throw new \Exception("Closures dump not implemented"); |
|
74 | + } else { |
|
75 | + $field = "'$field'"; |
|
76 | + } |
|
72 | 77 | |
73 | 78 | return $this->cache['string'] = "[$field, '$operator', $stringified_value]"; |
74 | 79 | } |