Passed
Branch master (3f2fff)
by Alfred
01:38
created
Core/Form.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -23,26 +23,26 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public function __construct($attributes = [])
25 25
     {
26
-        if(!$attributes instanceof AttributesBuilder)
27
-            $attributes  = new AttributesBuilder($attributes);
26
+        if (!$attributes instanceof AttributesBuilder)
27
+            $attributes = new AttributesBuilder($attributes);
28 28
         $this->attributes = $attributes;
29
-        if(!$this->attributes->has('name'))
29
+        if (!$this->attributes->has('name'))
30 30
             $this->addName(date('Ymd H:i:s'));
31 31
         else
32 32
             $this->addName($this->attributes->get('name'));
33 33
 
34
-        $this->attributes->set('type','form');
34
+        $this->attributes->set('type', 'form');
35 35
 
36
-        if(!$this->attributes->has('enctype'))
37
-        $this->attributes->set('enctype','application/x-www-form-urlencoded');
36
+        if (!$this->attributes->has('enctype'))
37
+        $this->attributes->set('enctype', 'application/x-www-form-urlencoded');
38 38
 
39
-        if(!$this->attributes->has('method'))
40
-        $this->attributes->set('method','post');
39
+        if (!$this->attributes->has('method'))
40
+        $this->attributes->set('method', 'post');
41 41
 
42
-        if(!$this->attributes->has('action'))
43
-            $this->attributes->set('action',$_SERVER['REQUEST_URI']);
42
+        if (!$this->attributes->has('action'))
43
+            $this->attributes->set('action', $_SERVER['REQUEST_URI']);
44 44
 
45
-        $this->attributes->set('autocomplete','off');
45
+        $this->attributes->set('autocomplete', 'off');
46 46
 
47 47
         $this->attributes->Ignore('form');
48 48
     }
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
     public function addName($token = null)
62 62
     {
63 63
         $token .= microtime(true);
64
-        if(strpos($token,'form-')!==0)
64
+        if (strpos($token, 'form-') !== 0)
65 65
             $token = 'form-'.$token;
66
-        $this->attributes->set('name',md5($token));
66
+        $this->attributes->set('name', md5($token));
67 67
         return  $this;
68 68
     }
69 69
     /**
@@ -72,10 +72,10 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public function append($element)
74 74
     {
75
-        if($element instanceof FormElement)
75
+        if ($element instanceof FormElement)
76 76
             $this->Content .= $element->RenderHtml();
77 77
         else
78
-            $this->Content .=  $element;
78
+            $this->Content .= $element;
79 79
         return $this;
80 80
     }
81 81
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      */
85 85
     public function RenderHtml(): string
86 86
     {
87
-        if(strcasecmp($this->attributes->get('method'),'get') == 0)
87
+        if (strcasecmp($this->attributes->get('method'), 'get') == 0)
88 88
             $this->attributes->remove('enctype');
89 89
         $html  = '<form';
90 90
         $html .= $this->attributes->RenderHtml();
Please login to merge, or discard this patch.
Braces   +28 added lines, -20 removed lines patch added patch discarded remove patch
@@ -23,24 +23,29 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public function __construct($attributes = [])
25 25
     {
26
-        if(!$attributes instanceof AttributesBuilder)
27
-            $attributes  = new AttributesBuilder($attributes);
26
+        if(!$attributes instanceof AttributesBuilder) {
27
+                    $attributes  = new AttributesBuilder($attributes);
28
+        }
28 29
         $this->attributes = $attributes;
29
-        if(!$this->attributes->has('name'))
30
-            $this->addName(date('Ymd H:i:s'));
31
-        else
32
-            $this->addName($this->attributes->get('name'));
30
+        if(!$this->attributes->has('name')) {
31
+                    $this->addName(date('Ymd H:i:s'));
32
+        } else {
33
+                    $this->addName($this->attributes->get('name'));
34
+        }
33 35
 
34 36
         $this->attributes->set('type','form');
35 37
 
36
-        if(!$this->attributes->has('enctype'))
37
-        $this->attributes->set('enctype','application/x-www-form-urlencoded');
38
+        if(!$this->attributes->has('enctype')) {
39
+                $this->attributes->set('enctype','application/x-www-form-urlencoded');
40
+        }
38 41
 
39
-        if(!$this->attributes->has('method'))
40
-        $this->attributes->set('method','post');
42
+        if(!$this->attributes->has('method')) {
43
+                $this->attributes->set('method','post');
44
+        }
41 45
 
42
-        if(!$this->attributes->has('action'))
43
-            $this->attributes->set('action',$_SERVER['REQUEST_URI']);
46
+        if(!$this->attributes->has('action')) {
47
+                    $this->attributes->set('action',$_SERVER['REQUEST_URI']);
48
+        }
44 49
 
45 50
         $this->attributes->set('autocomplete','off');
46 51
 
@@ -61,8 +66,9 @@  discard block
 block discarded – undo
61 66
     public function addName($token = null)
62 67
     {
63 68
         $token .= microtime(true);
64
-        if(strpos($token,'form-')!==0)
65
-            $token = 'form-'.$token;
69
+        if(strpos($token,'form-')!==0) {
70
+                    $token = 'form-'.$token;
71
+        }
66 72
         $this->attributes->set('name',md5($token));
67 73
         return  $this;
68 74
     }
@@ -72,10 +78,11 @@  discard block
 block discarded – undo
72 78
      */
73 79
     public function append($element)
74 80
     {
75
-        if($element instanceof FormElement)
76
-            $this->Content .= $element->RenderHtml();
77
-        else
78
-            $this->Content .=  $element;
81
+        if($element instanceof FormElement) {
82
+                    $this->Content .= $element->RenderHtml();
83
+        } else {
84
+                    $this->Content .=  $element;
85
+        }
79 86
         return $this;
80 87
     }
81 88
 
@@ -84,8 +91,9 @@  discard block
 block discarded – undo
84 91
      */
85 92
     public function RenderHtml(): string
86 93
     {
87
-        if(strcasecmp($this->attributes->get('method'),'get') == 0)
88
-            $this->attributes->remove('enctype');
94
+        if(strcasecmp($this->attributes->get('method'),'get') == 0) {
95
+                    $this->attributes->remove('enctype');
96
+        }
89 97
         $html  = '<form';
90 98
         $html .= $this->attributes->RenderHtml();
91 99
         $html .= ' >';
Please login to merge, or discard this patch.
Core/Libs/AttributesBuilder.php 2 patches
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Braces   +15 added lines, -8 removed lines patch added patch discarded remove patch
@@ -51,8 +51,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.