@@ -111,45 +111,45 @@ |
||
| 111 | 111 | |
| 112 | 112 | public static function nicetime($date, array $translate = ["second", "minute", "hour", "day", "week", "month", "year", "decade"]) |
| 113 | 113 | { |
| 114 | - if(empty($date)) { |
|
| 114 | + if (empty($date)) { |
|
| 115 | 115 | return "No date provided"; |
| 116 | 116 | } |
| 117 | - if(!is_array($translate)) { |
|
| 117 | + if (!is_array($translate)) { |
|
| 118 | 118 | return "the expected value is not an array"; |
| 119 | 119 | } |
| 120 | - if( 5 > count($translate)){ |
|
| 120 | + if (5 > count($translate)) { |
|
| 121 | 121 | return "the matrix needs 5 to 8 values (second, minute, hour, day, week,month, year, decade)"; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | $periods = $translate; |
| 125 | - $lengths = array("60","60","24","7","4.35","12","10"); |
|
| 125 | + $lengths = array("60", "60", "24", "7", "4.35", "12", "10"); |
|
| 126 | 126 | |
| 127 | 127 | $now = time(); |
| 128 | - $unix_date = strtotime($date); |
|
| 128 | + $unix_date = strtotime($date); |
|
| 129 | 129 | |
| 130 | 130 | // check validity of date |
| 131 | - if(empty($unix_date)) { |
|
| 131 | + if (empty($unix_date)) { |
|
| 132 | 132 | return "Bad date"; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | // is it future date or past date |
| 136 | - if($now > $unix_date) { |
|
| 137 | - $difference = $now - $unix_date; |
|
| 138 | - $tense = "ago"; |
|
| 136 | + if ($now > $unix_date) { |
|
| 137 | + $difference = $now - $unix_date; |
|
| 138 | + $tense = "ago"; |
|
| 139 | 139 | |
| 140 | 140 | } else { |
| 141 | - $difference = $unix_date - $now; |
|
| 142 | - $tense = "from now"; |
|
| 141 | + $difference = $unix_date - $now; |
|
| 142 | + $tense = "from now"; |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) { |
|
| 145 | + for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths) - 1; $j++) { |
|
| 146 | 146 | $difference /= $lengths[$j]; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | $difference = round($difference); |
| 150 | 150 | |
| 151 | - if($difference != 1) { |
|
| 152 | - $periods[$j].= "s"; |
|
| 151 | + if ($difference != 1) { |
|
| 152 | + $periods[$j] .= "s"; |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | return "$difference $periods[$j] {$tense}"; |
@@ -69,17 +69,22 @@ |
||
| 69 | 69 | $characterDeficit = 0; //Gets incremented when an uppercase letter is encountered before $targetCharsPerWord characters have been collected since the last UC char. |
| 70 | 70 | $wordIndex = $targetWordLength; //HACK: keeps track of how many characters have been carried into the abbreviation since the last UC char |
| 71 | 71 | while ($stringIndex < strlen($strString)) { //Process the whole input string... |
| 72 | - if ($abbrevLength >= $targetLength) //...unless the abbreviation has hit the target length cap |
|
| 72 | + if ($abbrevLength >= $targetLength) { |
|
| 73 | + //...unless the abbreviation has hit the target length cap |
|
| 73 | 74 | break; |
| 75 | + } |
|
| 74 | 76 | $currentChar = $strString[$stringIndex++]; //Grab a character from the string, advance the string cursor |
| 75 | 77 | if (in_array($currentChar, $ucLetters)) { //If handling a UC char, consider it a new word |
| 76 | 78 | $characterDeficit += $targetWordLength - $wordIndex; //If UC chars are closer together than targetWordLength, keeps track of how many extra characters are required to fit the target length of the abbreviation |
| 77 | 79 | $wordIndex = 0; //Set the wordIndex to reflect a new word |
| 78 | 80 | } else if ($wordIndex >= $targetWordLength) { |
| 79 | - if ($characterDeficit == 0) //If the word is full and we're not short any characters, ignore the character |
|
| 81 | + if ($characterDeficit == 0) { |
|
| 82 | + //If the word is full and we're not short any characters, ignore the character |
|
| 80 | 83 | continue; |
| 81 | - else |
|
| 82 | - $characterDefecit--; //If we are short some characters, decrement the defecit and carry on with adding the character to the abbreviation |
|
| 84 | + } else { |
|
| 85 | + $characterDefecit--; |
|
| 86 | + } |
|
| 87 | + //If we are short some characters, decrement the defecit and carry on with adding the character to the abbreviation |
|
| 83 | 88 | } |
| 84 | 89 | $abbreviation .= $currentChar; //Add the character to the abbreviation |
| 85 | 90 | $abbrevLength++; //Increment abbreviation length |
@@ -256,8 +256,8 @@ |
||
| 256 | 256 | return $this->data['value']; |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - public function setValue($value){ |
|
| 260 | - $this->data['value']= $value; |
|
| 259 | + public function setValue($value) { |
|
| 260 | + $this->data['value'] = $value; |
|
| 261 | 261 | |
| 262 | 262 | } |
| 263 | 263 | |
@@ -18,16 +18,18 @@ discard block |
||
| 18 | 18 | private $cwd; |
| 19 | 19 | |
| 20 | 20 | public function __construct(array $i_filename_arr) { |
| 21 | - if (!is_array($i_filename_arr)) |
|
| 22 | - $i_filename_arr = array($i_filename_arr); |
|
| 21 | + if (!is_array($i_filename_arr)) { |
|
| 22 | + $i_filename_arr = array($i_filename_arr); |
|
| 23 | + } |
|
| 23 | 24 | |
| 24 | 25 | $this->filenames = $i_filename_arr; |
| 25 | 26 | $this->cwd = getcwd() . DIRECTORY_SEPARATOR; |
| 26 | 27 | |
| 27 | - if ($this->style_changed()) |
|
| 28 | - $expire = -72000; |
|
| 29 | - else |
|
| 30 | - $expire = 3200; |
|
| 28 | + if ($this->style_changed()) { |
|
| 29 | + $expire = -72000; |
|
| 30 | + } else { |
|
| 31 | + $expire = 3200; |
|
| 32 | + } |
|
| 31 | 33 | |
| 32 | 34 | header('Content-Type: text/css; charset: UTF-8'); |
| 33 | 35 | header('Cache-Control: must-revalidate'); |
@@ -37,8 +39,9 @@ discard block |
||
| 37 | 39 | public function dump_style() { |
| 38 | 40 | ob_start('ob_gzhandler'); |
| 39 | 41 | |
| 40 | - foreach ($this->filenames as $filename) |
|
| 41 | - $this->dump_cache_contents($filename); |
|
| 42 | + foreach ($this->filenames as $filename) { |
|
| 43 | + $this->dump_cache_contents($filename); |
|
| 44 | + } |
|
| 42 | 45 | |
| 43 | 46 | ob_end_flush(); |
| 44 | 47 | } |
@@ -50,9 +53,10 @@ discard block |
||
| 50 | 53 | } |
| 51 | 54 | |
| 52 | 55 | private function style_changed() { |
| 53 | - foreach ($this->filenames as $filename) |
|
| 54 | - if (!is_file($this->get_cache_name($filename))) |
|
| 56 | + foreach ($this->filenames as $filename) { |
|
| 57 | + if (!is_file($this->get_cache_name($filename))) |
|
| 55 | 58 | return TRUE; |
| 59 | + } |
|
| 56 | 60 | return FALSE; |
| 57 | 61 | } |
| 58 | 62 | |
@@ -81,9 +85,10 @@ discard block |
||
| 81 | 85 | } |
| 82 | 86 | |
| 83 | 87 | // remove any old, lingering caches for this file |
| 84 | - if ($dead_files = glob($this->get_cache_name($filename, TRUE), GLOB_NOESCAPE)) |
|
| 85 | - foreach ($dead_files as $dead_file) |
|
| 88 | + if ($dead_files = glob($this->get_cache_name($filename, TRUE), GLOB_NOESCAPE)) { |
|
| 89 | + foreach ($dead_files as $dead_file) |
|
| 86 | 90 | unlink($dead_file); |
| 91 | + } |
|
| 87 | 92 | |
| 88 | 93 | $compressed = $this->compress(file_get_contents($filename)); |
| 89 | 94 | file_put_contents($current_cache, $compressed); |
@@ -211,7 +211,7 @@ |
||
| 211 | 211 | public function has($keys) |
| 212 | 212 | { |
| 213 | 213 | $keys = (array)$keys; |
| 214 | - if ( empty($this->elements) || $keys === []) { |
|
| 214 | + if (empty($this->elements) || $keys === []) { |
|
| 215 | 215 | return false; |
| 216 | 216 | } |
| 217 | 217 | foreach ($keys as $key) { |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | $this->elements = &$items; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - /** |
|
| 35 | + /** |
|
| 36 | 36 | * Return all the stored items |
| 37 | 37 | * |
| 38 | 38 | * @return array |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | |
| 60 | - /* |
|
| 60 | + /* |
|
| 61 | 61 | * -------------------------------------------------------------- |
| 62 | 62 | * ArrayAccess interface |
| 63 | 63 | * -------------------------------------------------------------- |
@@ -127,12 +127,12 @@ discard block |
||
| 127 | 127 | return true; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - /** |
|
| 131 | - * Set a given key / value pair or pairs |
|
| 132 | - * |
|
| 133 | - * @param array|int|string $keys |
|
| 134 | - * @param mixed $value |
|
| 135 | - */ |
|
| 130 | + /** |
|
| 131 | + * Set a given key / value pair or pairs |
|
| 132 | + * |
|
| 133 | + * @param array|int|string $keys |
|
| 134 | + * @param mixed $value |
|
| 135 | + */ |
|
| 136 | 136 | public function set($keys, $value = null) |
| 137 | 137 | { |
| 138 | 138 | if (is_array($keys)) { |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | $value = array_merge($items, $this->getArrayItems($value)); |
| 188 | 188 | $this->set($key, $value); |
| 189 | 189 | } |
| 190 | - $this->elements = array_merge($this->elements, $key->all()); |
|
| 190 | + $this->elements = array_merge($this->elements, $key->all()); |
|
| 191 | 191 | |
| 192 | 192 | } |
| 193 | 193 | |
@@ -127,12 +127,12 @@ |
||
| 127 | 127 | if (!isset($offset)) { |
| 128 | 128 | $this->set($offset, $value); |
| 129 | 129 | } |
| 130 | - $this->set($offset, $value); |
|
| 130 | + $this->set($offset, $value); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | public function offsetUnset($offset) |
| 134 | 134 | { |
| 135 | - $this->remove($offset); |
|
| 135 | + $this->remove($offset); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | public function containsKey($key) |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | |
| 261 | 261 | $subsetItems = array_slice($this->elements, $start, $length); |
| 262 | 262 | |
| 263 | - if(null === $subsetItems ){ |
|
| 263 | + if (null === $subsetItems) { |
|
| 264 | 264 | return null; |
| 265 | 265 | } |
| 266 | 266 | return $this->setElementsFromTrustedSource($subsetItems); |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | public function reverse() |
| 271 | 271 | { |
| 272 | 272 | $item = array_reverse($this->elements); |
| 273 | - if(null === $item ){ |
|
| 273 | + if (null === $item) { |
|
| 274 | 274 | return null; |
| 275 | 275 | } |
| 276 | 276 | |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - private function mysqliUseResult($mode, $table, $numeric, $cols, $view, $handle){ |
|
| 161 | + private function mysqliUseResult($mode, $table, $numeric, $cols, $view, $handle) { |
|
| 162 | 162 | $this->size = 0; |
| 163 | 163 | $res = $this->connection->query("SELECT * FROM $this->delTable", MYSQLI_USE_RESULT); |
| 164 | 164 | while ($row = $res->fetch_assoc()) { |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | fwrite($handle, "\n"); |
| 191 | 191 | |
| 192 | 192 | } |
| 193 | - private function checkSizendLen($cols, $s, $handle){ |
|
| 193 | + private function checkSizendLen($cols, $s, $handle) { |
|
| 194 | 194 | |
| 195 | 195 | if ($this->size == 0) { |
| 196 | 196 | $s = "INSERT INTO $this->delTable $cols VALUES\n$s"; |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | $this->size = 0; |
| 209 | 209 | } |
| 210 | 210 | } |
| 211 | - private function trigger($mode, $handle, $table){ |
|
| 211 | + private function trigger($mode, $handle, $table) { |
|
| 212 | 212 | if ($mode & self::TRIGGERS) { |
| 213 | 213 | $res = $this->connection->query("SHOW TRIGGERS LIKE '" . $this->connection->real_escape_string($table) . "'"); |
| 214 | 214 | if ($res->num_rows) { |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | protected function prepareDestination(Closure $destination) |
| 130 | 130 | { |
| 131 | - return function () use ($destination) { |
|
| 131 | + return function() use ($destination) { |
|
| 132 | 132 | return call_user_func_array($destination, func_get_args()); |
| 133 | 133 | }; |
| 134 | 134 | } |
@@ -140,8 +140,8 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | protected function carry() |
| 142 | 142 | { |
| 143 | - return function ($stack, $pipe) { |
|
| 144 | - return function () use ($stack, $pipe) { |
|
| 143 | + return function($stack, $pipe) { |
|
| 144 | + return function() use ($stack, $pipe) { |
|
| 145 | 145 | $passable = func_get_args(); |
| 146 | 146 | $passable[] = $stack; |
| 147 | 147 | $passable = array_merge($passable, $this->parameters); |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | // otherwise we'll resolve the pipes out of the container and call it with |
| 152 | 152 | // the appropriate method and arguments, returning the results back out. |
| 153 | 153 | return call_user_func_array($pipe, $passable); |
| 154 | - } elseif (! is_object($pipe)) { |
|
| 154 | + } elseif (!is_object($pipe)) { |
|
| 155 | 155 | list($name, $parameters) = $this->parsePipeString($pipe); |
| 156 | 156 | // If the pipe is a string we will parse the string and resolve the class out |
| 157 | 157 | // of the dependency injection container. We can then build a callable and |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | public function beforeAfter($command) |
| 100 | 100 | { |
| 101 | - if (! is_null($command)) { |
|
| 101 | + if (!is_null($command)) { |
|
| 102 | 102 | $info = $this->getMiddlewareInfo(); |
| 103 | 103 | if (is_array($command)) { |
| 104 | 104 | foreach ($command as $value) { |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | return $response; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - return $this->exception('handle() method is not found in <b>'.$command.'</b> class.'); |
|
| 124 | + return $this->exception('handle() method is not found in <b>' . $command . '</b> class.'); |
|
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | public function runRoute($command, $params = null) |
| 141 | 141 | { |
| 142 | 142 | $info = $this->getControllerInfo(); |
| 143 | - if (! is_object($command)) { |
|
| 143 | + if (!is_object($command)) { |
|
| 144 | 144 | $segments = explode('@', $command); |
| 145 | 145 | $controllerClass = str_replace([$info['namespace'], '\\', '.'], ['', '/', '/'], $segments[0]); |
| 146 | 146 | $controllerMethod = $segments[1]; |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | return; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - return $this->exception($controllerMethod . ' method is not found in '.$controllerClass.' class.'); |
|
| 154 | + return $this->exception($controllerMethod . ' method is not found in ' . $controllerClass . ' class.'); |
|
| 155 | 155 | } else { |
| 156 | 156 | echo $this->runMethodWithParams($command, $params); |
| 157 | 157 | } |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | protected function resolveClass($class, $path, $namespace) |
| 173 | 173 | { |
| 174 | 174 | $file = realpath(rtrim($path, '/') . '/' . $class . '.php'); |
| 175 | - if (! file_exists($file)) { |
|
| 175 | + if (!file_exists($file)) { |
|
| 176 | 176 | return $this->exception($class . ' class is not found. Please, check file.'); |
| 177 | 177 | } |
| 178 | 178 | |