@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | * The __set magic method is overridden here to apply value 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 | } |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @param array $value |
42 | 42 | */ |
43 | - public function set_value( array $value ) |
|
43 | + public function set_value(array $value) |
|
44 | 44 | { |
45 | - foreach($value as $n => $v) |
|
45 | + foreach ($value as $n => $v) |
|
46 | 46 | { |
47 | 47 | $component = $this->get_component($n); |
48 | 48 | $component->value = $v; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function required_arguments() |
73 | 73 | { |
74 | - return array('name','components','template'); |
|
74 | + return array('name', 'components', 'template'); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function parse_template() |
91 | 91 | { |
92 | - return preg_replace_callback('/\{\{([a-zA-Z\d-_]+)\}\}/', function($a){ |
|
92 | + return preg_replace_callback('/\{\{([a-zA-Z\d-_]+)\}\}/', function($a) { |
|
93 | 93 | $component = $this->get_component($a[1]); |
94 | 94 | return $component->render(); |
95 | 95 | }, $this->model['template']); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function get_name() |
106 | 106 | { |
107 | - if('' !== $this->parent_name) |
|
107 | + if ('' !== $this->parent_name) |
|
108 | 108 | { |
109 | 109 | return "{$this->parent_name}[{$this->name}]"; |
110 | 110 | } |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | |
114 | 114 | public function filter($v) |
115 | 115 | { |
116 | - foreach($this->components as $component) |
|
116 | + foreach ($this->components as $component) |
|
117 | 117 | { |
118 | - if($component instanceof FilterableComponentInterface && |
|
118 | + if ($component instanceof FilterableComponentInterface && |
|
119 | 119 | \is_callable($component->filter)) |
120 | 120 | { |
121 | 121 | $n = $component->name; |
@@ -126,15 +126,15 @@ discard block |
||
126 | 126 | return $v; |
127 | 127 | } |
128 | 128 | |
129 | - public function validation($v,&$e) |
|
129 | + public function validation($v, &$e) |
|
130 | 130 | { |
131 | - foreach($this->components as $component) |
|
131 | + foreach ($this->components as $component) |
|
132 | 132 | { |
133 | - if($component instanceof ValidatableComponentInterface && |
|
133 | + if ($component instanceof ValidatableComponentInterface && |
|
134 | 134 | \is_callable($component->validation)) |
135 | 135 | { |
136 | 136 | $n = $component->name; |
137 | - if(!$component->validation($v[$n],$e)) |
|
137 | + if (!$component->validation($v[$n], $e)) |
|
138 | 138 | { |
139 | 139 | return false; |
140 | 140 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | */ |
149 | 149 | protected function on_created() |
150 | 150 | { |
151 | - foreach( $this->model['components'] as $args ) |
|
151 | + foreach ($this->model['components'] as $args) |
|
152 | 152 | { |
153 | 153 | $this->components[$args['name']] = $this->create_component($args); |
154 | 154 | } |
@@ -159,16 +159,16 @@ discard block |
||
159 | 159 | * @param type $args |
160 | 160 | * @return type |
161 | 161 | */ |
162 | - private function create_component( $args ) |
|
162 | + private function create_component($args) |
|
163 | 163 | { |
164 | 164 | $type = $args['type']; |
165 | 165 | |
166 | - if('composite' === $type) |
|
166 | + if ('composite' === $type) |
|
167 | 167 | { |
168 | 168 | $args['parent_name'] = $this->get_name(); |
169 | 169 | } |
170 | 170 | |
171 | - $c = \Amarkal\UI\ComponentFactory::create( $type, $args ); |
|
171 | + $c = \Amarkal\UI\ComponentFactory::create($type, $args); |
|
172 | 172 | |
173 | 173 | // Apply the composite name template |
174 | 174 | $c->name_template = str_replace('{{parent_name}}', $this->get_name(), $c->composite_name_template); |
@@ -183,9 +183,9 @@ discard block |
||
183 | 183 | * @return UI\AbstractComponent |
184 | 184 | * @throws \RuntimeException If there's no child component corresponding to the given name |
185 | 185 | */ |
186 | - private function get_component( $name ) |
|
186 | + private function get_component($name) |
|
187 | 187 | { |
188 | - if(!array_key_exists($name, $this->components)) |
|
188 | + if (!array_key_exists($name, $this->components)) |
|
189 | 189 | { |
190 | 190 | throw new \RuntimeException("Composite sub-component not found with name $name"); |
191 | 191 | } |
@@ -25,13 +25,13 @@ |
||
25 | 25 | 'min' => null, |
26 | 26 | 'max' => null, |
27 | 27 | 'step' => 1, |
28 | - 'filter' => array( $this, 'filter' ) |
|
28 | + 'filter' => array($this, 'filter') |
|
29 | 29 | ); |
30 | 30 | } |
31 | 31 | |
32 | 32 | public function required_arguments() |
33 | 33 | { |
34 | - return array('name','min','max'); |
|
34 | + return array('name', 'min', 'max'); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | public function get_template_path() |