@@ -25,16 +25,16 @@ discard block |
||
| 25 | 25 | * The __set magic method is overridden here to apply value & name changes to |
| 26 | 26 | * child components. |
| 27 | 27 | */ |
| 28 | - public function __set( $name, $value ) |
|
| 28 | + public function __set($name, $value) |
|
| 29 | 29 | { |
| 30 | 30 | parent::__set($name, $value); |
| 31 | 31 | |
| 32 | - if( 'value' === $name ) |
|
| 32 | + if ('value' === $name) |
|
| 33 | 33 | { |
| 34 | 34 | $this->set_value($value); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - if( 'name' === $name ) |
|
| 37 | + if ('name' === $name) |
|
| 38 | 38 | { |
| 39 | 39 | $this->set_name($value); |
| 40 | 40 | } |
@@ -46,9 +46,9 @@ discard block |
||
| 46 | 46 | * @param array $value |
| 47 | 47 | * @return void |
| 48 | 48 | */ |
| 49 | - public function set_value( array $value ) |
|
| 49 | + public function set_value(array $value) |
|
| 50 | 50 | { |
| 51 | - foreach($value as $n => $v) |
|
| 51 | + foreach ($value as $n => $v) |
|
| 52 | 52 | { |
| 53 | 53 | $component = $this->get_component($n); |
| 54 | 54 | $component->value = $v; |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | * @param string $name |
| 62 | 62 | * @return void |
| 63 | 63 | */ |
| 64 | - public function set_name( $name ) |
|
| 64 | + public function set_name($name) |
|
| 65 | 65 | { |
| 66 | - foreach($this->components as $c) |
|
| 66 | + foreach ($this->components as $c) |
|
| 67 | 67 | { |
| 68 | 68 | $c->name_template = str_replace('{{parent_name}}', $this->get_name(), $c->composite_name_template); |
| 69 | 69 | } |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function required_arguments() |
| 94 | 94 | { |
| 95 | - return array('name','components','template'); |
|
| 95 | + return array('name', 'components', 'template'); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function get_name() |
| 128 | 128 | { |
| 129 | - if('' !== $this->parent_name) |
|
| 129 | + if ('' !== $this->parent_name) |
|
| 130 | 130 | { |
| 131 | 131 | return "{$this->parent_name}[{$this->name}]"; |
| 132 | 132 | } |
@@ -135,9 +135,9 @@ discard block |
||
| 135 | 135 | |
| 136 | 136 | public function filter($v) |
| 137 | 137 | { |
| 138 | - foreach($this->components as $component) |
|
| 138 | + foreach ($this->components as $component) |
|
| 139 | 139 | { |
| 140 | - if($component instanceof FilterableComponentInterface && |
|
| 140 | + if ($component instanceof FilterableComponentInterface && |
|
| 141 | 141 | \is_callable($component->filter)) |
| 142 | 142 | { |
| 143 | 143 | $n = $component->name; |
@@ -148,15 +148,15 @@ discard block |
||
| 148 | 148 | return $v; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - public function validation($v,&$e) |
|
| 151 | + public function validation($v, &$e) |
|
| 152 | 152 | { |
| 153 | - foreach($this->components as $component) |
|
| 153 | + foreach ($this->components as $component) |
|
| 154 | 154 | { |
| 155 | - if($component instanceof ValidatableComponentInterface && |
|
| 155 | + if ($component instanceof ValidatableComponentInterface && |
|
| 156 | 156 | \is_callable($component->validation)) |
| 157 | 157 | { |
| 158 | 158 | $n = $component->name; |
| 159 | - if(!$component->validation($v[$n],$e)) |
|
| 159 | + if (!$component->validation($v[$n], $e)) |
|
| 160 | 160 | { |
| 161 | 161 | return false; |
| 162 | 162 | } |
@@ -172,9 +172,9 @@ discard block |
||
| 172 | 172 | * @return UI\AbstractComponent |
| 173 | 173 | * @throws \RuntimeException If there's no child component corresponding to the given name |
| 174 | 174 | */ |
| 175 | - public function get_component( $name ) |
|
| 175 | + public function get_component($name) |
|
| 176 | 176 | { |
| 177 | - if(!array_key_exists($name, $this->components)) |
|
| 177 | + if (!array_key_exists($name, $this->components)) |
|
| 178 | 178 | { |
| 179 | 179 | throw new \RuntimeException("Composite sub-component not found with name $name"); |
| 180 | 180 | } |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | */ |
| 187 | 187 | protected function on_created() |
| 188 | 188 | { |
| 189 | - foreach( $this->model['components'] as $args ) |
|
| 189 | + foreach ($this->model['components'] as $args) |
|
| 190 | 190 | { |
| 191 | 191 | $this->components[$args['name']] = $this->create_component($args); |
| 192 | 192 | } |
@@ -197,16 +197,16 @@ discard block |
||
| 197 | 197 | * @param type $args |
| 198 | 198 | * @return type |
| 199 | 199 | */ |
| 200 | - private function create_component( $args ) |
|
| 200 | + private function create_component($args) |
|
| 201 | 201 | { |
| 202 | 202 | $type = $args['type']; |
| 203 | 203 | |
| 204 | - if('composite' === $type) |
|
| 204 | + if ('composite' === $type) |
|
| 205 | 205 | { |
| 206 | 206 | $args['parent_name'] = $this->get_name(); |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - $c = \Amarkal\UI\ComponentFactory::create( $type, $args ); |
|
| 209 | + $c = \Amarkal\UI\ComponentFactory::create($type, $args); |
|
| 210 | 210 | |
| 211 | 211 | // Apply the composite name template |
| 212 | 212 | $c->name_template = str_replace('{{parent_name}}', $this->get_name(), $c->composite_name_template); |