@@ -53,31 +53,31 @@ discard block |
||
53 | 53 | */ |
54 | 54 | function displayMsg($msg, $colorTxt = null, $colorBg = null, $style = 'normal') |
55 | 55 | { |
56 | - if($colorTxt == null) { |
|
56 | + if ($colorTxt == null) { |
|
57 | 57 | echo $msg."\n"; |
58 | 58 | return; |
59 | 59 | } |
60 | 60 | |
61 | 61 | //Gestion cas avec couleur |
62 | 62 | $styleNum = styleForShell($style); |
63 | - if($styleNum === false) { |
|
63 | + if ($styleNum === false) { |
|
64 | 64 | $styleNum = styleForShell('normal'); |
65 | 65 | } |
66 | 66 | |
67 | 67 | $colorTxtNum = colorForShell('white', 'txt'); |
68 | - if($colorTxt !== null) { |
|
68 | + if ($colorTxt !== null) { |
|
69 | 69 | $colorTxtNumArg = colorForShell($colorTxt, 'txt'); |
70 | 70 | |
71 | - if($colorTxtNumArg !== false) { |
|
71 | + if ($colorTxtNumArg !== false) { |
|
72 | 72 | $colorTxtNum = $colorTxtNumArg; |
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | 76 | $colorBgNum = colorForShell('black', 'bg'); |
77 | - if($colorBg !== null) { |
|
77 | + if ($colorBg !== null) { |
|
78 | 78 | $colorBgNumArg = colorForShell($colorBg, 'bg'); |
79 | 79 | |
80 | - if($colorBgNumArg !== false) { |
|
80 | + if ($colorBgNumArg !== false) { |
|
81 | 81 | $colorBgNum = $colorBgNumArg; |
82 | 82 | } |
83 | 83 | } |
@@ -109,14 +109,14 @@ discard block |
||
109 | 109 | 'white' => 7 |
110 | 110 | ]; |
111 | 111 | |
112 | - if(!in_array($color, $colorList)) { |
|
112 | + if (!in_array($color, $colorList)) { |
|
113 | 113 | throw new Exception('Color '.$color.' is not available in function.'); |
114 | 114 | } |
115 | 115 | |
116 | - if($type === 'txt') { |
|
116 | + if ($type === 'txt') { |
|
117 | 117 | return $colorList[$color] + 30; |
118 | 118 | } |
119 | - elseif($type === 'bg') { |
|
119 | + elseif ($type === 'bg') { |
|
120 | 120 | return $colorList[$color] + 40; |
121 | 121 | } |
122 | 122 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | 'not-reverse' => 27 |
141 | 141 | ]; |
142 | 142 | |
143 | - if(!in_array($style, $styleList)) { |
|
143 | + if (!in_array($style, $styleList)) { |
|
144 | 144 | return false; |
145 | 145 | } |
146 | 146 |
@@ -115,8 +115,7 @@ |
||
115 | 115 | |
116 | 116 | if($type === 'txt') { |
117 | 117 | return $colorList[$color] + 30; |
118 | - } |
|
119 | - elseif($type === 'bg') { |
|
118 | + } elseif($type === 'bg') { |
|
120 | 119 | return $colorList[$color] + 40; |
121 | 120 | } |
122 | 121 |
@@ -150,7 +150,7 @@ |
||
150 | 150 | $keywords->search, |
151 | 151 | $keywords->replace, |
152 | 152 | strtolower($match[3]) |
153 | - ); |
|
153 | + ); |
|
154 | 154 | |
155 | 155 | $dateDepart = clone $this; |
156 | 156 | parent::modify($match[1].$match[2].' '.$keyword); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | public function getZone() |
93 | 93 | { |
94 | - return parent::format('P');; |
|
94 | + return parent::format('P'); ; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | public function modify($modify) |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $dateDepart = clone $this; |
100 | 100 | parent::modify($modify); |
101 | 101 | |
102 | - if($dateDepart == $this) { |
|
102 | + if ($dateDepart == $this) { |
|
103 | 103 | return $this; |
104 | 104 | } |
105 | 105 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | $match = []; |
143 | 143 | |
144 | 144 | //Regex sur le paramètre pour récupéré le type de modification |
145 | - if(preg_match('#(\+|\-)([0-9]+) ([a-z]+)#i', $modify, $match) !== 1) { |
|
145 | + if (preg_match('#(\+|\-)([0-9]+) ([a-z]+)#i', $modify, $match) !== 1) { |
|
146 | 146 | throw new Exceptio('Date::modify pattern not match.'); |
147 | 147 | } |
148 | 148 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $dateDepart = clone $this; |
156 | 156 | parent::modify($match[1].$match[2].' '.$keyword); |
157 | 157 | |
158 | - if($dateDepart == $this) { |
|
158 | + if ($dateDepart == $this) { |
|
159 | 159 | throw new Exception('Parameter '.$match[3].' is unknown.'); |
160 | 160 | } |
161 | 161 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | $date = $this->format('Y-m-d'); |
176 | 176 | $heure = $this->format('H:i:s'); |
177 | 177 | |
178 | - if($returnArray) { |
|
178 | + if ($returnArray) { |
|
179 | 179 | return [$date, $heure]; |
180 | 180 | } |
181 | 181 | |
@@ -226,10 +226,10 @@ discard block |
||
226 | 226 | $return = []; |
227 | 227 | |
228 | 228 | $pos = false; |
229 | - foreach($lst_all as $val) { |
|
229 | + foreach ($lst_all as $val) { |
|
230 | 230 | $pos = strpos($val, $continent); |
231 | 231 | |
232 | - if($pos !== false) { |
|
232 | + if ($pos !== false) { |
|
233 | 233 | $return[] = $val; |
234 | 234 | } |
235 | 235 | } |
@@ -247,11 +247,11 @@ discard block |
||
247 | 247 | 'time' => '' |
248 | 248 | ]; |
249 | 249 | |
250 | - if($actual == $this) { |
|
250 | + if ($actual == $this) { |
|
251 | 251 | //A l'instant |
252 | 252 | |
253 | 253 | $returnTxt->date = self::$humainReadableI18n['now']; |
254 | - } elseif($actual->format('d') !== parent::format('d')) { |
|
254 | + } elseif ($actual->format('d') !== parent::format('d')) { |
|
255 | 255 | //Hier |
256 | 256 | |
257 | 257 | $returnTxt->date = self::$humainReadableI18n['yesterday']; |
@@ -260,21 +260,21 @@ discard block |
||
260 | 260 | .parent::format( |
261 | 261 | self::$humainReadableFormats['time'] |
262 | 262 | ); |
263 | - } elseif($diff->days === 0) { |
|
263 | + } elseif ($diff->days === 0) { |
|
264 | 264 | //Aujourd'hui |
265 | 265 | |
266 | 266 | $returnTxt->date = self::$humainReadableI18n['since']; |
267 | 267 | |
268 | - if($diff->h === 0 && $diff->m === 0) { |
|
268 | + if ($diff->h === 0 && $diff->m === 0) { |
|
269 | 269 | $returnTxt->date .= $diff->s.'s'; |
270 | - } elseif($diff->h === 0) { |
|
270 | + } elseif ($diff->h === 0) { |
|
271 | 271 | $returnTxt->date .= $diff->s.'min'; |
272 | 272 | } else { |
273 | 273 | $returnTxt->date .= $diff->h.'h'; |
274 | 274 | } |
275 | 275 | } else { |
276 | 276 | $dateFormat = self::$humainReadableFormats['dateDifferentYear']; |
277 | - if($actual->format('Y') === parent::format('Y')) { |
|
277 | + if ($actual->format('Y') === parent::format('Y')) { |
|
278 | 278 | $dateFormat = self::$humainReadableFormats['dateSameYear']; |
279 | 279 | } |
280 | 280 | |
@@ -291,11 +291,11 @@ discard block |
||
291 | 291 | } |
292 | 292 | |
293 | 293 | $txtReturn = $returnTxt->date; |
294 | - if($returnDateAndTime === true && $returnTxt->time !== '') { |
|
294 | + if ($returnDateAndTime === true && $returnTxt->time !== '') { |
|
295 | 295 | $txtReturn .= ' '.$returnTxt->time; |
296 | 296 | } |
297 | 297 | |
298 | - if($toLower === true) { |
|
298 | + if ($toLower === true) { |
|
299 | 299 | $txtReturn = mb_strtolower($txtReturn); |
300 | 300 | } |
301 | 301 |
@@ -19,7 +19,7 @@ |
||
19 | 19 | |
20 | 20 | protected function connectToServers() |
21 | 21 | { |
22 | - foreach($this->config['memcached']['server'] as $server) |
|
22 | + foreach ($this->config['memcached']['server'] as $server) |
|
23 | 23 | { |
24 | 24 | $this->addServer($server['host'], $server['port']); |
25 | 25 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | protected function connectToServers() |
21 | 21 | { |
22 | 22 | $addServers = []; |
23 | - foreach($this->config['memcached']['server'] as $server) |
|
23 | + foreach ($this->config['memcached']['server'] as $server) |
|
24 | 24 | { |
25 | 25 | $addServers[] = [$server['host'], $server['port']]; |
26 | 26 | } |
@@ -20,29 +20,29 @@ discard block |
||
20 | 20 | $this->loadAllConfigsFiles(); |
21 | 21 | } |
22 | 22 | |
23 | - protected function searchAllConfigsFiles($dirPath, $pathFromRoot='') |
|
23 | + protected function searchAllConfigsFiles($dirPath, $pathFromRoot = '') |
|
24 | 24 | { |
25 | - if(!file_exists($dirPath)) { |
|
25 | + if (!file_exists($dirPath)) { |
|
26 | 26 | return; |
27 | 27 | } |
28 | 28 | |
29 | 29 | $listFiles = array_diff(scandir($dirPath), ['.', '..']); |
30 | 30 | |
31 | - foreach($listFiles as $file) { |
|
31 | + foreach ($listFiles as $file) { |
|
32 | 32 | $keyFile = $pathFromRoot.$file; |
33 | 33 | $readPath = $dirPath.'/'.$file; |
34 | 34 | |
35 | - if(is_file($readPath)) { |
|
35 | + if (is_file($readPath)) { |
|
36 | 36 | $this->configFiles[$keyFile] = $readPath; |
37 | 37 | continue; |
38 | 38 | } |
39 | 39 | |
40 | - if(is_link($readPath)) { |
|
40 | + if (is_link($readPath)) { |
|
41 | 41 | $this->configFiles[$keyFile] = realpath($readPath); |
42 | 42 | continue; |
43 | 43 | } |
44 | 44 | |
45 | - if(is_dir($readPath)) { |
|
45 | + if (is_dir($readPath)) { |
|
46 | 46 | $this->searchAllConfigsFiles($readPath, $pathFromRoot.'/'); |
47 | 47 | continue; |
48 | 48 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | protected function loadAllConfigsFiles() |
53 | 53 | { |
54 | - foreach($this->configFiles as $fileKey => $filePath) |
|
54 | + foreach ($this->configFiles as $fileKey => $filePath) |
|
55 | 55 | { |
56 | 56 | $this->loadConfigFile($fileKey, $filePath); |
57 | 57 | } |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | { |
62 | 62 | $fileExtension = pathinfo($filePath, PATHINFO_EXTENSION); |
63 | 63 | |
64 | - if($fileExtension === 'json') { |
|
64 | + if ($fileExtension === 'json') { |
|
65 | 65 | $this->loadJsonConfigFile($fileKey, $filePath); |
66 | 66 | return; |
67 | 67 | } |
68 | 68 | |
69 | - if($fileExtension === 'php') { |
|
69 | + if ($fileExtension === 'php') { |
|
70 | 70 | $this->loadPhpConfigFile($fileKey, $filePath); |
71 | 71 | return; |
72 | 72 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | $json = file_get_contents($filePath); |
80 | 80 | $config = json_decode($json); |
81 | 81 | |
82 | - if($config === null) { |
|
82 | + if ($config === null) { |
|
83 | 83 | throw new Exception(json_last_error_msg()); |
84 | 84 | } |
85 | 85 | |
@@ -91,25 +91,25 @@ discard block |
||
91 | 91 | $this->config[$fileKey] = require($filePath); |
92 | 92 | } |
93 | 93 | |
94 | - public function getConfig($key, $file=null) |
|
94 | + public function getConfig($key, $file = null) |
|
95 | 95 | { |
96 | 96 | $nbConfigFile = count($this->config); |
97 | 97 | |
98 | - if($file === null && $nbConfigFile > 1) { |
|
98 | + if ($file === null && $nbConfigFile > 1) { |
|
99 | 99 | throw new Exception('Please indicate a file for get config '.$key); |
100 | 100 | } |
101 | 101 | |
102 | - if($nbConfigFile === 1) { |
|
102 | + if ($nbConfigFile === 1) { |
|
103 | 103 | $file = key($this->config); |
104 | 104 | } |
105 | 105 | |
106 | - if(!isset($this->config[$file])) { |
|
106 | + if (!isset($this->config[$file])) { |
|
107 | 107 | throw new Exception('The file '.$file.' not exist for config '.$key); |
108 | 108 | } |
109 | 109 | |
110 | 110 | $config = &$this->config[$file]; |
111 | 111 | |
112 | - if(!isset($config[$key])) { |
|
112 | + if (!isset($config[$key])) { |
|
113 | 113 | throw new Exception('The config key '.$key.' not exist in config'); |
114 | 114 | } |
115 | 115 |
@@ -16,7 +16,7 @@ |
||
16 | 16 | |
17 | 17 | public function getOption($optionKey) |
18 | 18 | { |
19 | - if(!isset($this->options[$optionKey])) { |
|
19 | + if (!isset($this->options[$optionKey])) { |
|
20 | 20 | throw new Exception('Option key '.$optionKey.' not exist.'); |
21 | 21 | } |
22 | 22 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | public static function getInstance() |
27 | 27 | { |
28 | - if(self::$instance === null) { |
|
28 | + if (self::$instance === null) { |
|
29 | 29 | self::$instance = new self; |
30 | 30 | } |
31 | 31 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | |
65 | 65 | public function getServerVar($keyName) |
66 | 66 | { |
67 | - if(!isset($_SERVER[$keyName])) { |
|
67 | + if (!isset($_SERVER[$keyName])) { |
|
68 | 68 | return ''; |
69 | 69 | } |
70 | 70 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $firstLang = explode(';', $acceptLangs[0]); |
93 | 93 | $lang = strtolower($firstLang[0]); |
94 | 94 | |
95 | - if(strpos($lang, '-') !== false) |
|
95 | + if (strpos($lang, '-') !== false) |
|
96 | 96 | { |
97 | 97 | $minLang = explode('-', $lang); |
98 | 98 | $lang = $minLang[0]; |
@@ -119,13 +119,13 @@ discard block |
||
119 | 119 | |
120 | 120 | $this->ssl = false; |
121 | 121 | |
122 | - if(!empty($serverHttps) && $serverHttps !== 'off') { |
|
122 | + if (!empty($serverHttps) && $serverHttps !== 'off') { |
|
123 | 123 | $this->ssl = true; |
124 | 124 | } |
125 | - elseif(!empty($fwdProto) && $fwdProto === 'https') { |
|
125 | + elseif (!empty($fwdProto) && $fwdProto === 'https') { |
|
126 | 126 | $this->ssl = true; |
127 | 127 | } |
128 | - elseif(!empty($fwdSsl) && $fwdSsl === 'on') { |
|
128 | + elseif (!empty($fwdSsl) && $fwdSsl === 'on') { |
|
129 | 129 | $this->ssl = true; |
130 | 130 | } |
131 | 131 | } |
@@ -121,11 +121,9 @@ |
||
121 | 121 | |
122 | 122 | if(!empty($serverHttps) && $serverHttps !== 'off') { |
123 | 123 | $this->ssl = true; |
124 | - } |
|
125 | - elseif(!empty($fwdProto) && $fwdProto === 'https') { |
|
124 | + } elseif(!empty($fwdProto) && $fwdProto === 'https') { |
|
126 | 125 | $this->ssl = true; |
127 | - } |
|
128 | - elseif(!empty($fwdSsl) && $fwdSsl === 'on') { |
|
126 | + } elseif(!empty($fwdSsl) && $fwdSsl === 'on') { |
|
129 | 127 | $this->ssl = true; |
130 | 128 | } |
131 | 129 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | { |
20 | 20 | $key = array_search($observer, $this->observers, true); |
21 | 21 | |
22 | - if($key !== false) { |
|
22 | + if ($key !== false) { |
|
23 | 23 | unset($this->observers[$key]); |
24 | 24 | } |
25 | 25 | |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | public function notify($action = '') |
30 | 30 | { |
31 | - foreach($this->observers as $observer) { |
|
31 | + foreach ($this->observers as $observer) { |
|
32 | 32 | $observer->update($this, $action); |
33 | 33 | } |
34 | 34 |
@@ -54,14 +54,14 @@ discard block |
||
54 | 54 | ]; |
55 | 55 | |
56 | 56 | $erreurType = 'Unknown'; |
57 | - if(isset($map[$errSeverity])) { |
|
57 | + if (isset($map[$errSeverity])) { |
|
58 | 58 | $erreurType = $map[$errSeverity]; |
59 | 59 | } |
60 | 60 | |
61 | 61 | $errorRenderFcts = self::errorGetRender(); |
62 | - $errorRender = $errorRenderFcts['default']; |
|
62 | + $errorRender = $errorRenderFcts['default']; |
|
63 | 63 | |
64 | - if(PHP_SAPI === 'cli') { |
|
64 | + if (PHP_SAPI === 'cli') { |
|
65 | 65 | $errorRender = $errorRenderFcts['cli']; |
66 | 66 | } |
67 | 67 | |
@@ -97,22 +97,22 @@ discard block |
||
97 | 97 | <p class="title">Niarf, a error is detected !</p> |
98 | 98 | <p class="info">'.$erreurType.' Error : <strong>'.$errMsg.'</strong> in '.$errFile.' at line '.$errLine.'</p> |
99 | 99 | <fieldset><pre>'; |
100 | - foreach($backtrace as $i => $info) { |
|
100 | + foreach ($backtrace as $i => $info) { |
|
101 | 101 | echo '#'.$i.' '.$info['function']; |
102 | 102 | |
103 | - if(isset($info['args']) && count($info['args']) > 0) { |
|
103 | + if (isset($info['args']) && count($info['args']) > 0) { |
|
104 | 104 | echo '('; |
105 | 105 | |
106 | - foreach($info['args'] as $iArgs => $args) { |
|
107 | - if($iArgs > 0) { |
|
106 | + foreach ($info['args'] as $iArgs => $args) { |
|
107 | + if ($iArgs > 0) { |
|
108 | 108 | echo ', '; |
109 | 109 | } |
110 | 110 | |
111 | - if(is_array($args) || is_object($args)) { |
|
111 | + if (is_array($args) || is_object($args)) { |
|
112 | 112 | echo gettype($args); |
113 | 113 | |
114 | 114 | } |
115 | - elseif(is_null($args)) { |
|
115 | + elseif (is_null($args)) { |
|
116 | 116 | echo 'null'; |
117 | 117 | } |
118 | 118 | else { |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | echo ')'; |
124 | 124 | } |
125 | 125 | |
126 | - if(isset($info['file'], $info['line'])) { |
|
126 | + if (isset($info['file'], $info['line'])) { |
|
127 | 127 | echo ' called at ['.$info['file'].' line '.$info['line'].']'; |
128 | 128 | } |
129 | 129 | echo "\n\n"; |
@@ -111,11 +111,9 @@ |
||
111 | 111 | if(is_array($args) || is_object($args)) { |
112 | 112 | echo gettype($args); |
113 | 113 | |
114 | - } |
|
115 | - elseif(is_null($args)) { |
|
114 | + } elseif(is_null($args)) { |
|
116 | 115 | echo 'null'; |
117 | - } |
|
118 | - else { |
|
116 | + } else { |
|
119 | 117 | echo htmlentities($args); |
120 | 118 | } |
121 | 119 | } |