@@ -89,7 +89,7 @@ |
||
89 | 89 | /** |
90 | 90 | * Get the name for this component by parsing the name template. |
91 | 91 | * |
92 | - * @return type |
|
92 | + * @return string |
|
93 | 93 | */ |
94 | 94 | public function get_name() |
95 | 95 | { |
@@ -123,7 +123,7 @@ |
||
123 | 123 | /** |
124 | 124 | * |
125 | 125 | * @param type $args |
126 | - * @return type |
|
126 | + * @return AbstractComponent |
|
127 | 127 | */ |
128 | 128 | private function create_component( $args ) |
129 | 129 | { |
@@ -8,9 +8,9 @@ |
||
8 | 8 | class Component_composite |
9 | 9 | extends AbstractComponent |
10 | 10 | implements ValueComponentInterface, |
11 | - DisableableComponentInterface, |
|
12 | - FilterableComponentInterface, |
|
13 | - ValidatableComponentInterface |
|
11 | + DisableableComponentInterface, |
|
12 | + FilterableComponentInterface, |
|
13 | + ValidatableComponentInterface |
|
14 | 14 | { |
15 | 15 | /** |
16 | 16 | * The list of child components. |
@@ -23,11 +23,11 @@ discard block |
||
23 | 23 | * The __set magic method is overridden here to apply value changes to |
24 | 24 | * child components. |
25 | 25 | */ |
26 | - public function __set( $name, $value ) |
|
26 | + public function __set($name, $value) |
|
27 | 27 | { |
28 | 28 | parent::__set($name, $value); |
29 | 29 | |
30 | - if( 'value' === $name ) |
|
30 | + if ('value' === $name) |
|
31 | 31 | { |
32 | 32 | $this->set_value($value); |
33 | 33 | } |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @param array $value |
40 | 40 | */ |
41 | - public function set_value( array $value ) |
|
41 | + public function set_value(array $value) |
|
42 | 42 | { |
43 | - foreach($value as $n => $v) |
|
43 | + foreach ($value as $n => $v) |
|
44 | 44 | { |
45 | 45 | $component = $this->get_component($n); |
46 | 46 | $component->value = $v; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function required_arguments() |
71 | 71 | { |
72 | - return array('name','components','template'); |
|
72 | + return array('name', 'components', 'template'); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | */ |
88 | 88 | public function parse_template() |
89 | 89 | { |
90 | - return preg_replace_callback('/\{\{([a-zA-Z\d-_]+)\}\}/', function($a){ |
|
90 | + return preg_replace_callback('/\{\{([a-zA-Z\d-_]+)\}\}/', function($a) { |
|
91 | 91 | $component = $this->get_component($a[1]); |
92 | 92 | return $component->render(); |
93 | 93 | }, $this->model['template']); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function get_name() |
104 | 104 | { |
105 | - if('' !== $this->parent_name) |
|
105 | + if ('' !== $this->parent_name) |
|
106 | 106 | { |
107 | 107 | return "{$this->parent_name}[{$this->name}]"; |
108 | 108 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | protected function on_created() |
116 | 116 | { |
117 | - foreach( $this->model['components'] as $args ) |
|
117 | + foreach ($this->model['components'] as $args) |
|
118 | 118 | { |
119 | 119 | $this->components[$args['name']] = $this->create_component($args); |
120 | 120 | } |
@@ -125,16 +125,16 @@ discard block |
||
125 | 125 | * @param type $args |
126 | 126 | * @return type |
127 | 127 | */ |
128 | - private function create_component( $args ) |
|
128 | + private function create_component($args) |
|
129 | 129 | { |
130 | 130 | $type = $args['type']; |
131 | 131 | |
132 | - if('composite' === $type) |
|
132 | + if ('composite' === $type) |
|
133 | 133 | { |
134 | 134 | $args['parent_name'] = $this->get_name(); |
135 | 135 | } |
136 | 136 | |
137 | - $c = \Amarkal\UI\ComponentFactory::create( $type, $args ); |
|
137 | + $c = \Amarkal\UI\ComponentFactory::create($type, $args); |
|
138 | 138 | |
139 | 139 | // Apply the composite name template |
140 | 140 | $c->name_template = str_replace('{{parent_name}}', $this->get_name(), $c->composite_name_template); |
@@ -149,9 +149,9 @@ discard block |
||
149 | 149 | * @return UI\AbstractComponent |
150 | 150 | * @throws \RuntimeException If there's no child component corresponding to the given name |
151 | 151 | */ |
152 | - private function get_component( $name ) |
|
152 | + private function get_component($name) |
|
153 | 153 | { |
154 | - if(!array_key_exists($name, $this->components)) |
|
154 | + if (!array_key_exists($name, $this->components)) |
|
155 | 155 | { |
156 | 156 | throw new \RuntimeException("Composite sub-component not found with name $name"); |
157 | 157 | } |
@@ -8,7 +8,7 @@ |
||
8 | 8 | class Component_checkbox |
9 | 9 | extends AbstractComponent |
10 | 10 | implements ValueComponentInterface, |
11 | - DisableableComponentInterface |
|
11 | + DisableableComponentInterface |
|
12 | 12 | { |
13 | 13 | public $name_template = '{{name}}[]'; |
14 | 14 |
@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | 'required' => false, |
26 | 26 | 'readonly' => false, |
27 | 27 | 'default' => null, |
28 | - 'filter' => array( $this, 'filter' ), |
|
29 | - 'validation' => array( $this, 'validation' ) |
|
28 | + 'filter' => array($this, 'filter'), |
|
29 | + 'validation' => array($this, 'validation') |
|
30 | 30 | ); |
31 | 31 | } |
32 | 32 | |
@@ -35,17 +35,17 @@ discard block |
||
35 | 35 | return floatval($v); |
36 | 36 | } |
37 | 37 | |
38 | - public function validation($v,&$e) |
|
38 | + public function validation($v, &$e) |
|
39 | 39 | { |
40 | 40 | $max = $this->max; |
41 | 41 | $min = $this->min; |
42 | 42 | |
43 | - if(null !== $max && $v > $max) |
|
43 | + if (null !== $max && $v > $max) |
|
44 | 44 | { |
45 | 45 | $e = "must be less than {$max}"; |
46 | 46 | } |
47 | 47 | |
48 | - if(null !== $min && $v < $min) |
|
48 | + if (null !== $min && $v < $min) |
|
49 | 49 | { |
50 | 50 | $e = "must be greater than {$min}"; |
51 | 51 | } |