@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | use KeyNormalizer; |
17 | 17 | |
18 | 18 | private $attributes; |
19 | - private $ignore ; |
|
19 | + private $ignore; |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * AttributesBuilder constructor. |
@@ -28,17 +28,17 @@ discard block |
||
28 | 28 | { |
29 | 29 | $this->attributes = new Collection(); |
30 | 30 | $this->ignore = new Collection(); |
31 | - if(!empty($attributes)) |
|
31 | + if (!empty($attributes)) |
|
32 | 32 | { |
33 | 33 | is_array($attributes) or $attributes = array($attributes); |
34 | - $attributes = array_change_key_case($attributes,CASE_LOWER); |
|
35 | - $attributes = $this->array_map_keys([$this,'normalize'],$attributes); |
|
34 | + $attributes = array_change_key_case($attributes, CASE_LOWER); |
|
35 | + $attributes = $this->array_map_keys([$this, 'normalize'], $attributes); |
|
36 | 36 | $this->attributes->add($attributes); |
37 | 37 | } |
38 | - if(!empty($ignore)) |
|
38 | + if (!empty($ignore)) |
|
39 | 39 | { |
40 | 40 | is_array($ignore) or $ignore = array($ignore); |
41 | - $ignore = array_map([$this,'normalize'],$ignore); |
|
41 | + $ignore = array_map([$this, 'normalize'], $ignore); |
|
42 | 42 | $this->ignore->add($ignore); |
43 | 43 | } |
44 | 44 | return $this; |
@@ -51,9 +51,9 @@ discard block |
||
51 | 51 | public function createElementID($key) |
52 | 52 | { |
53 | 53 | $key = ucfirst($this->normalize($key)); |
54 | - if(strpos($key,'input')!==0) |
|
54 | + if (strpos($key, 'input') !== 0) |
|
55 | 55 | $key = 'input'.$key; |
56 | - $this->set('id',$key); |
|
56 | + $this->set('id', $key); |
|
57 | 57 | return $this; |
58 | 58 | } |
59 | 59 | |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | { |
66 | 66 | !empty($token) or $token = microtime(true); |
67 | 67 | $token = $this->normalize($token); |
68 | - if(strpos($token,'form-')!==0) |
|
68 | + if (strpos($token, 'form-') !== 0) |
|
69 | 69 | $token = 'form-'.$token; |
70 | - $this->set('name',md5($token)); |
|
70 | + $this->set('name', md5($token)); |
|
71 | 71 | return $this; |
72 | 72 | } |
73 | 73 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | public function add(array $attributes) |
79 | 79 | { |
80 | 80 | is_array($attributes) or $attributes = array($attributes); |
81 | - $attributes = $this->array_map_keys([$this,'normalize'],$attributes); |
|
81 | + $attributes = $this->array_map_keys([$this, 'normalize'], $attributes); |
|
82 | 82 | $this->attributes->add($attributes); |
83 | 83 | return $this; |
84 | 84 | } |
@@ -88,10 +88,10 @@ discard block |
||
88 | 88 | * @param $default |
89 | 89 | * @return mixed |
90 | 90 | */ |
91 | - public function get($key,$default=null) |
|
91 | + public function get($key, $default = null) |
|
92 | 92 | { |
93 | 93 | $key = $this->normalize($key); |
94 | - return $this->attributes->get($key,$default); |
|
94 | + return $this->attributes->get($key, $default); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | public function Ignore($ignore) |
111 | 111 | { |
112 | 112 | is_array($ignore) or $ignore = array($ignore); |
113 | - $ignore = array_merge($this->ignore->all(), array_map([$this,'normalize'],$ignore)); |
|
113 | + $ignore = array_merge($this->ignore->all(), array_map([$this, 'normalize'], $ignore)); |
|
114 | 114 | $this->ignore->replace($ignore); |
115 | 115 | return $this; |
116 | 116 | } |
@@ -131,10 +131,10 @@ discard block |
||
131 | 131 | * @param mixed $value |
132 | 132 | * @return $this |
133 | 133 | */ |
134 | - public function set($key,$value) |
|
134 | + public function set($key, $value) |
|
135 | 135 | { |
136 | 136 | $key = $this->normalize($key); |
137 | - $this->attributes->set($key,$value); |
|
137 | + $this->attributes->set($key, $value); |
|
138 | 138 | return $this; |
139 | 139 | } |
140 | 140 | |
@@ -152,23 +152,23 @@ discard block |
||
152 | 152 | public function RenderHtml() |
153 | 153 | { |
154 | 154 | $output = []; |
155 | - if($attributes = $this->attributes->all()) |
|
155 | + if ($attributes = $this->attributes->all()) |
|
156 | 156 | { |
157 | 157 | AttributesMapper::filter($this); |
158 | 158 | $filtered = array_keys($attributes); |
159 | - if($ignore = $this->ignore->all()) |
|
159 | + if ($ignore = $this->ignore->all()) |
|
160 | 160 | $filtered = array_diff($filtered, $ignore); |
161 | 161 | $attributes = array_intersect_key($attributes, array_flip($filtered)); |
162 | - foreach($attributes as $key=>$value) |
|
162 | + foreach ($attributes as $key=>$value) |
|
163 | 163 | { |
164 | - if(is_array($value)): |
|
165 | - $output[]= $key.'="'.implode(' ',array_values($value)).'"'; |
|
164 | + if (is_array($value)): |
|
165 | + $output[] = $key.'="'.implode(' ', array_values($value)).'"'; |
|
166 | 166 | else: |
167 | - if(is_numeric($key)) $output[]= $value; |
|
168 | - else $output[]= $key.'="'.$value.'"'; |
|
167 | + if (is_numeric($key)) $output[] = $value; |
|
168 | + else $output[] = $key.'="'.$value.'"'; |
|
169 | 169 | endif; |
170 | 170 | } |
171 | 171 | } |
172 | - return count($output) ? ' ' . implode(' ', $output) : ''; |
|
172 | + return count($output) ? ' '.implode(' ', $output) : ''; |
|
173 | 173 | } |
174 | 174 | } |
@@ -51,8 +51,9 @@ discard block |
||
51 | 51 | public function createElementID($key) |
52 | 52 | { |
53 | 53 | $key = ucfirst($this->normalize($key)); |
54 | - if(strpos($key,'input')!==0) |
|
55 | - $key = 'input'.$key; |
|
54 | + if(strpos($key,'input')!==0) { |
|
55 | + $key = 'input'.$key; |
|
56 | + } |
|
56 | 57 | $this->set('id',$key); |
57 | 58 | return $this; |
58 | 59 | } |
@@ -65,8 +66,9 @@ discard block |
||
65 | 66 | { |
66 | 67 | !empty($token) or $token = microtime(true); |
67 | 68 | $token = $this->normalize($token); |
68 | - if(strpos($token,'form-')!==0) |
|
69 | - $token = 'form-'.$token; |
|
69 | + if(strpos($token,'form-')!==0) { |
|
70 | + $token = 'form-'.$token; |
|
71 | + } |
|
70 | 72 | $this->set('name',md5($token)); |
71 | 73 | return $this; |
72 | 74 | } |
@@ -156,16 +158,21 @@ discard block |
||
156 | 158 | { |
157 | 159 | AttributesMapper::filter($this); |
158 | 160 | $filtered = array_keys($attributes); |
159 | - if($ignore = $this->ignore->all()) |
|
160 | - $filtered = array_diff($filtered, $ignore); |
|
161 | + if($ignore = $this->ignore->all()) { |
|
162 | + $filtered = array_diff($filtered, $ignore); |
|
163 | + } |
|
161 | 164 | $attributes = array_intersect_key($attributes, array_flip($filtered)); |
162 | 165 | foreach($attributes as $key=>$value) |
163 | 166 | { |
164 | 167 | if(is_array($value)): |
165 | 168 | $output[]= $key.'="'.implode(' ',array_values($value)).'"'; |
166 | - else: |
|
169 | + else { |
|
170 | + : |
|
167 | 171 | if(is_numeric($key)) $output[]= $value; |
168 | - else $output[]= $key.'="'.$value.'"'; |
|
172 | + } |
|
173 | + else { |
|
174 | + $output[]= $key.'="'.$value.'"'; |
|
175 | + } |
|
169 | 176 | endif; |
170 | 177 | } |
171 | 178 | } |