@@ -14,13 +14,13 @@ discard block |
||
14 | 14 | { |
15 | 15 | $this->data = array_merge($this->data, $data); |
16 | 16 | |
17 | - foreach($this->data as $variable => $_){ |
|
17 | + foreach ($this->data as $variable => $_) { |
|
18 | 18 | $$variable = $_; |
19 | 19 | } |
20 | 20 | |
21 | 21 | $_ = (isset($data['_'])) ?? $data['_']; |
22 | 22 | |
23 | - if(!file_exists($require)){ |
|
23 | + if (!file_exists($require)) { |
|
24 | 24 | $require = basename($require); |
25 | 25 | throw new \RuntimeException("Importation file does not exist: {$require}"); |
26 | 26 | } |
@@ -41,13 +41,13 @@ discard block |
||
41 | 41 | $inScript = false; |
42 | 42 | $inComment = false; |
43 | 43 | |
44 | - foreach($arrayHtml as $index => $value){ |
|
44 | + foreach ($arrayHtml as $index => $value) { |
|
45 | 45 | $inScript = $this->checkInScript($inScript, $value); |
46 | 46 | |
47 | - if($inScript){ |
|
47 | + if ($inScript) { |
|
48 | 48 | $inComment = $this->checkCommentInScript($inComment, $value); |
49 | 49 | |
50 | - if(!$this->checkScriptNeed($inComment, $value)){ |
|
50 | + if (!$this->checkScriptNeed($inComment, $value)) { |
|
51 | 51 | continue; |
52 | 52 | } |
53 | 53 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | $html[$index] = ltrim($value); |
58 | 58 | } |
59 | 59 | |
60 | - return implode('',$html); |
|
60 | + return implode('', $html); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | protected function getVars(string $buffer, ?bool $treat = true): string |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | protected function replaceVars(string $buffer, array $vars, ?string $prefix = ''): string |
71 | 71 | { |
72 | 72 | foreach ($vars as $key => $value) { |
73 | - switch(gettype($value)){ |
|
73 | + switch (gettype($value)) { |
|
74 | 74 | case 'array': |
75 | 75 | $buffer = $this->replaceArray($buffer, $value, $prefix, $key); |
76 | 76 | break; |
@@ -88,9 +88,9 @@ discard block |
||
88 | 88 | |
89 | 89 | protected function replaceValue(string $buffer, $value, ?string $prefix, string $key): string |
90 | 90 | { |
91 | - if(is_scalar($value)){ |
|
92 | - while(strstr($buffer, "{{{$this->treat} \${$prefix}{$key} {$this->treat}}}")){ |
|
93 | - $buffer = str_replace("{{{$this->treat} \${$prefix}{$key} {$this->treat}}}", (($this->especial) ? htmlspecialchars($value) : $value) ,$buffer); |
|
91 | + if (is_scalar($value)) { |
|
92 | + while (strstr($buffer, "{{{$this->treat} \${$prefix}{$key} {$this->treat}}}")) { |
|
93 | + $buffer = str_replace("{{{$this->treat} \${$prefix}{$key} {$this->treat}}}", (($this->especial) ? htmlspecialchars($value) : $value), $buffer); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
@@ -99,18 +99,18 @@ discard block |
||
99 | 99 | |
100 | 100 | protected function replaceObject(string $buffer, object $obj, ?string $prefix, string $key): string |
101 | 101 | { |
102 | - $vars = method_exists($obj,'getVars') ? $obj->getVars() : []; |
|
102 | + $vars = method_exists($obj, 'getVars') ? $obj->getVars() : []; |
|
103 | 103 | $vars = array_merge($vars, get_object_vars($obj)); |
104 | 104 | |
105 | - foreach($vars as $field => $val){ |
|
106 | - $buffer = $this->replaceValue($buffer, $val, $key.'.' , $field); |
|
105 | + foreach ($vars as $field => $val) { |
|
106 | + $buffer = $this->replaceValue($buffer, $val, $key.'.', $field); |
|
107 | 107 | |
108 | 108 | |
109 | 109 | $buffer = $this->checkArray($buffer, $obj->$field, $key.'.'.$field.'.'); |
110 | - $buffer = $this->checkObject($buffer, $obj->$field, $key.'.'.$field.'.', $key.'.'.$field); |
|
110 | + $buffer = $this->checkObject($buffer, $obj->$field, $key.'.'.$field.'.', $key.'.'.$field); |
|
111 | 111 | |
112 | - while(strstr($buffer, "{{{$this->treat} \${$prefix}{$key}.{$field} {$this->treat}}}")){ |
|
113 | - $buffer = str_replace("{{{$this->treat} \${$prefix}{$key}.{$field} {$this->treat}}}", (($this->especial) ? htmlspecialchars($obj->$field) : $obj->$field) ,$buffer); |
|
112 | + while (strstr($buffer, "{{{$this->treat} \${$prefix}{$key}.{$field} {$this->treat}}}")) { |
|
113 | + $buffer = str_replace("{{{$this->treat} \${$prefix}{$key}.{$field} {$this->treat}}}", (($this->especial) ? htmlspecialchars($obj->$field) : $obj->$field), $buffer); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | private function checkArray(string $buffer, $obj, string $prefix): string |
121 | 121 | { |
122 | - if(is_array($obj)){ |
|
122 | + if (is_array($obj)) { |
|
123 | 123 | $buffer = $this->replaceVars($buffer, $obj, $prefix); |
124 | 124 | } |
125 | 125 | return $buffer; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | |
128 | 128 | private function checkObject(string $buffer, $obj, string $prefix, string $key): string |
129 | 129 | { |
130 | - if(is_object($obj)){ |
|
130 | + if (is_object($obj)) { |
|
131 | 131 | $buffer = $this->replaceObject($buffer, $obj, $prefix, $key); |
132 | 132 | } |
133 | 133 | return $buffer; |
@@ -135,11 +135,11 @@ discard block |
||
135 | 135 | |
136 | 136 | protected function replaceArray(string $buffer, array $array, ?string $prefix = '', ?string $key = ''): string |
137 | 137 | { |
138 | - foreach($array as $field => $val){ |
|
138 | + foreach ($array as $field => $val) { |
|
139 | 139 | $buffer = $this->replaceValue($buffer, $val, $key.'.', $field); |
140 | 140 | |
141 | - while(strstr($buffer, "{{{$this->treat} \${$prefix}{$key}.{$field} {$this->treat}}}")){ |
|
142 | - $buffer = str_replace("{{{$this->treat} \${$prefix}{$key}.{$field} {$this->treat}}}", (($this->especial) ? htmlspecialchars($val) : $val) ,$buffer); |
|
141 | + while (strstr($buffer, "{{{$this->treat} \${$prefix}{$key}.{$field} {$this->treat}}}")) { |
|
142 | + $buffer = str_replace("{{{$this->treat} \${$prefix}{$key}.{$field} {$this->treat}}}", (($this->especial) ? htmlspecialchars($val) : $val), $buffer); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | return $buffer; |
@@ -147,13 +147,13 @@ discard block |
||
147 | 147 | |
148 | 148 | protected function removeComments(string $buffer): string |
149 | 149 | { |
150 | - while(strstr($buffer,'<!--')){ |
|
150 | + while (strstr($buffer, '<!--')) { |
|
151 | 151 | $comment = substr( |
152 | 152 | $buffer, |
153 | - strpos($buffer,'<!--'), |
|
154 | - strpos(strstr($buffer,'<!--'),'-->')+3 |
|
153 | + strpos($buffer, '<!--'), |
|
154 | + strpos(strstr($buffer, '<!--'), '-->')+3 |
|
155 | 155 | ); |
156 | - $buffer = str_replace($comment,'',$buffer); |
|
156 | + $buffer = str_replace($comment, '', $buffer); |
|
157 | 157 | } |
158 | 158 | return $buffer; |
159 | 159 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | /** |
6 | 6 | * @property string $email |
7 | 7 | */ |
8 | -class User{ |
|
8 | +class User { |
|
9 | 9 | public string $name = 'Henri Azevedo'; |
10 | 10 | public array $values = [1 => 'param1']; |
11 | 11 | public Address $address; |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | public function getVars(): array |
23 | 23 | { |
24 | 24 | $vars = []; |
25 | - foreach($this->data as $var => $value){ |
|
25 | + foreach ($this->data as $var => $value) { |
|
26 | 26 | $vars[$var] = $value; |
27 | 27 | } |
28 | 28 | return $vars; |