@@ -4,7 +4,7 @@ discard block  | 
                                                    ||
| 4 | 4 | |
| 5 | 5 | // use default php error handler  | 
                                                        
| 6 | 6 | set_error_handler(  | 
                                                        
| 7 | -	function( $severity, $message, $file, $line ) { | 
                                                        |
| 7 | +	function($severity, $message, $file, $line) { | 
                                                        |
| 8 | 8 | return false;  | 
                                                        
| 9 | 9 | }  | 
                                                        
| 10 | 10 | );  | 
                                                        
@@ -12,7 +12,7 @@ discard block  | 
                                                    ||
| 12 | 12 | $code = http_response_code();  | 
                                                        
| 13 | 13 | |
| 14 | 14 | // not an error code so make it one  | 
                                                        
| 15 | -if( $code < 400 ) { | 
                                                        |
| 15 | +if ($code < 400) { | 
                                                        |
| 16 | 16 | $code = 500;  | 
                                                        
| 17 | 17 |  	headers_sent() || header("HTTP/1.0 500 Internal Server Error"); | 
                                                        
| 18 | 18 | }  | 
                                                        
@@ -83,7 +83,7 @@ discard block  | 
                                                    ||
| 83 | 83 | * @param boolean $debug  | 
                                                        
| 84 | 84 | * @return void  | 
                                                        
| 85 | 85 | */  | 
                                                        
| 86 | -	public static function setDebug( $debug = false ) { | 
                                                        |
| 86 | +	public static function setDebug($debug = false) { | 
                                                        |
| 87 | 87 | static::$debug = (bool) $debug;  | 
                                                        
| 88 | 88 | }  | 
                                                        
| 89 | 89 | |
@@ -93,9 +93,9 @@ discard block  | 
                                                    ||
| 93 | 93 | * @param string $format one of the Yolk::DUMP_* constants  | 
                                                        
| 94 | 94 | * @return void  | 
                                                        
| 95 | 95 | */  | 
                                                        
| 96 | -	public static function dump( $var, $format = null ) { | 
                                                        |
| 96 | +	public static function dump($var, $format = null) { | 
                                                        |
| 97 | 97 | |
| 98 | - if( !static::isDebug() )  | 
                                                        |
| 98 | + if (!static::isDebug())  | 
                                                        |
| 99 | 99 | return;  | 
                                                        
| 100 | 100 | |
| 101 | 101 | $dumpers = [  | 
                                                        
@@ -105,7 +105,7 @@ discard block  | 
                                                    ||
| 105 | 105 | ];  | 
                                                        
| 106 | 106 | |
| 107 | 107 | // auto-detect format if unknown or none specified  | 
                                                        
| 108 | - if( !isset($dumpers[$format]) )  | 
                                                        |
| 108 | + if (!isset($dumpers[$format]))  | 
                                                        |
| 109 | 109 | $format = static::isCLI() ? static::DUMP_TERMINAL : static::DUMP_HTML;  | 
                                                        
| 110 | 110 | |
| 111 | 111 | $dumpers[$format]::dump($var);  | 
                                                        
@@ -119,17 +119,17 @@ discard block  | 
                                                    ||
| 119 | 119 | * .e.g yolk\helpers\ArrayHelper::sum() -> yolk\Yolk::sum()  | 
                                                        
| 120 | 120 | * @param string|array $classes  | 
                                                        
| 121 | 121 | */  | 
                                                        
| 122 | -	public static function registerHelpers( $classes ) { | 
                                                        |
| 122 | +	public static function registerHelpers($classes) { | 
                                                        |
| 123 | 123 | |
| 124 | - if( !is_array($classes) )  | 
                                                        |
| 124 | + if (!is_array($classes))  | 
                                                        |
| 125 | 125 | $classes = [$classes];  | 
                                                        
| 126 | 126 | |
| 127 | -		foreach( $classes as $class ) { | 
                                                        |
| 127 | +		foreach ($classes as $class) { | 
                                                        |
| 128 | 128 | |
| 129 | 129 | $class = new \ReflectionClass($class);  | 
                                                        
| 130 | 130 | $methods = $class->getMethods(\ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_STATIC);  | 
                                                        
| 131 | 131 | |
| 132 | -			foreach( $methods as $m ) { | 
                                                        |
| 132 | +			foreach ($methods as $m) { | 
                                                        |
| 133 | 133 | static::addHelperMethod($class->name, $m->name);  | 
                                                        
| 134 | 134 | }  | 
                                                        
| 135 | 135 | |
@@ -142,13 +142,13 @@ discard block  | 
                                                    ||
| 142 | 142 | * @param string $class  | 
                                                        
| 143 | 143 | * @param string $method  | 
                                                        
| 144 | 144 | */  | 
                                                        
| 145 | -	public static function addHelperMethod( $class, $method ) { | 
                                                        |
| 145 | +	public static function addHelperMethod($class, $method) { | 
                                                        |
| 146 | 146 | |
| 147 | 147 | $k = strtolower($method);  | 
                                                        
| 148 | 148 | |
| 149 | - if( method_exists(__CLASS__, $method) )  | 
                                                        |
| 149 | + if (method_exists(__CLASS__, $method))  | 
                                                        |
| 150 | 150 |  			throw new \Exception(sprintf("Helper methods cannot override pre-defined Yolk methods - '%s' is reserved", $method)); | 
                                                        
| 151 | - elseif( isset(static::$helpers[$k]) && static::$helpers[$k][0] != $class )  | 
                                                        |
| 151 | + elseif (isset(static::$helpers[$k]) && static::$helpers[$k][0] != $class)  | 
                                                        |
| 152 | 152 |  			throw new \Exception(sprintf("Helper method '%s' already defined in class '%s', duplicate in '%s'", $method, static::$helpers[$k][0], $class)); | 
                                                        
| 153 | 153 | |
| 154 | 154 | static::$helpers[$k] = [$class, $method];  | 
                                                        
@@ -160,7 +160,7 @@ discard block  | 
                                                    ||
| 160 | 160 | * @param \Closure $callable  | 
                                                        
| 161 | 161 | * @return void  | 
                                                        
| 162 | 162 | */  | 
                                                        
| 163 | -	public static function run( Callable $callable ) { | 
                                                        |
| 163 | +	public static function run(Callable $callable) { | 
                                                        |
| 164 | 164 | |
| 165 | 165 |  		try { | 
                                                        
| 166 | 166 | |
@@ -183,7 +183,7 @@ discard block  | 
                                                    ||
| 183 | 183 | return $result;  | 
                                                        
| 184 | 184 | |
| 185 | 185 | }  | 
                                                        
| 186 | -		catch( \Exception $e ) { | 
                                                        |
| 186 | +		catch (\Exception $e) { | 
                                                        |
| 187 | 187 | static::exception($e);  | 
                                                        
| 188 | 188 | }  | 
                                                        
| 189 | 189 | |
@@ -194,7 +194,7 @@ discard block  | 
                                                    ||
| 194 | 194 | * @param callable $handler  | 
                                                        
| 195 | 195 | * @return void  | 
                                                        
| 196 | 196 | */  | 
                                                        
| 197 | -	public static function setErrorHandler( callable $handler = null ) { | 
                                                        |
| 197 | +	public static function setErrorHandler(callable $handler = null) { | 
                                                        |
| 198 | 198 | static::$error_handler = $handler ?: ['\\yolk\\exceptions\\Handler', 'error'];  | 
                                                        
| 199 | 199 | }  | 
                                                        
| 200 | 200 | |
@@ -203,7 +203,7 @@ discard block  | 
                                                    ||
| 203 | 203 | * @param callable $handler  | 
                                                        
| 204 | 204 | * @return void  | 
                                                        
| 205 | 205 | */  | 
                                                        
| 206 | -	public static function setExceptionHandler( callable $handler = null ) { | 
                                                        |
| 206 | +	public static function setExceptionHandler(callable $handler = null) { | 
                                                        |
| 207 | 207 | static::$exception_handler = $handler ?: ['\\yolk\\exceptions\\Handler', 'exception'];  | 
                                                        
| 208 | 208 | }  | 
                                                        
| 209 | 209 | |
@@ -212,11 +212,11 @@ discard block  | 
                                                    ||
| 212 | 212 | * @param \Exception $error  | 
                                                        
| 213 | 213 | * @return void  | 
                                                        
| 214 | 214 | */  | 
                                                        
| 215 | -	public static function exception( \Exception $error ) { | 
                                                        |
| 215 | +	public static function exception(\Exception $error) { | 
                                                        |
| 216 | 216 | return call_user_func(  | 
                                                        
| 217 | 217 | static::$exception_handler,  | 
                                                        
| 218 | 218 | $error,  | 
                                                        
| 219 | - static::$error_page ?: __DIR__. '/exceptions/error.php'  | 
                                                        |
| 219 | + static::$error_page ?: __DIR__.'/exceptions/error.php'  | 
                                                        |
| 220 | 220 | );  | 
                                                        
| 221 | 221 | }  | 
                                                        
| 222 | 222 | |
@@ -226,15 +226,15 @@ discard block  | 
                                                    ||
| 226 | 226 | * @param string $file  | 
                                                        
| 227 | 227 | * @return void  | 
                                                        
| 228 | 228 | */  | 
                                                        
| 229 | -	public static function setErrorPage( $file ) { | 
                                                        |
| 229 | +	public static function setErrorPage($file) { | 
                                                        |
| 230 | 230 | static::$error_page = (string) $file;  | 
                                                        
| 231 | 231 | }  | 
                                                        
| 232 | 232 | |
| 233 | -	public static function __callStatic( $method, array $args = [] ) { | 
                                                        |
| 233 | +	public static function __callStatic($method, array $args = []) { | 
                                                        |
| 234 | 234 | |
| 235 | 235 | $k = strtolower($method);  | 
                                                        
| 236 | 236 | |
| 237 | - if( !isset(static::$helpers[$k]) )  | 
                                                        |
| 237 | + if (!isset(static::$helpers[$k]))  | 
                                                        |
| 238 | 238 |  			throw new \BadMethodCallException("Unknown helper method '$method'"); | 
                                                        
| 239 | 239 | |
| 240 | 240 | return call_user_func_array(static::$helpers[$k], $args);  | 
                                                        
@@ -95,8 +95,9 @@ discard block  | 
                                                    ||
| 95 | 95 | */  | 
                                                        
| 96 | 96 |  	public static function dump( $var, $format = null ) { | 
                                                        
| 97 | 97 | |
| 98 | - if( !static::isDebug() )  | 
                                                        |
| 99 | - return;  | 
                                                        |
| 98 | +		if( !static::isDebug() ) { | 
                                                        |
| 99 | + return;  | 
                                                        |
| 100 | + }  | 
                                                        |
| 100 | 101 | |
| 101 | 102 | $dumpers = [  | 
                                                        
| 102 | 103 | static::DUMP_HTML => '\\yolk\\debug\\HTMLDumper',  | 
                                                        
@@ -105,8 +106,9 @@ discard block  | 
                                                    ||
| 105 | 106 | ];  | 
                                                        
| 106 | 107 | |
| 107 | 108 | // auto-detect format if unknown or none specified  | 
                                                        
| 108 | - if( !isset($dumpers[$format]) )  | 
                                                        |
| 109 | - $format = static::isCLI() ? static::DUMP_TERMINAL : static::DUMP_HTML;  | 
                                                        |
| 109 | +		if( !isset($dumpers[$format]) ) { | 
                                                        |
| 110 | + $format = static::isCLI() ? static::DUMP_TERMINAL : static::DUMP_HTML;  | 
                                                        |
| 111 | + }  | 
                                                        |
| 110 | 112 | |
| 111 | 113 | $dumpers[$format]::dump($var);  | 
                                                        
| 112 | 114 | |
@@ -121,8 +123,9 @@ discard block  | 
                                                    ||
| 121 | 123 | */  | 
                                                        
| 122 | 124 |  	public static function registerHelpers( $classes ) { | 
                                                        
| 123 | 125 | |
| 124 | - if( !is_array($classes) )  | 
                                                        |
| 125 | - $classes = [$classes];  | 
                                                        |
| 126 | +		if( !is_array($classes) ) { | 
                                                        |
| 127 | + $classes = [$classes];  | 
                                                        |
| 128 | + }  | 
                                                        |
| 126 | 129 | |
| 127 | 130 |  		foreach( $classes as $class ) { | 
                                                        
| 128 | 131 | |
@@ -146,10 +149,11 @@ discard block  | 
                                                    ||
| 146 | 149 | |
| 147 | 150 | $k = strtolower($method);  | 
                                                        
| 148 | 151 | |
| 149 | - if( method_exists(__CLASS__, $method) )  | 
                                                        |
| 150 | -			throw new \Exception(sprintf("Helper methods cannot override pre-defined Yolk methods - '%s' is reserved", $method)); | 
                                                        |
| 151 | - elseif( isset(static::$helpers[$k]) && static::$helpers[$k][0] != $class )  | 
                                                        |
| 152 | -			throw new \Exception(sprintf("Helper method '%s' already defined in class '%s', duplicate in '%s'", $method, static::$helpers[$k][0], $class)); | 
                                                        |
| 152 | +		if( method_exists(__CLASS__, $method) ) { | 
                                                        |
| 153 | +					throw new \Exception(sprintf("Helper methods cannot override pre-defined Yolk methods - '%s' is reserved", $method)); | 
                                                        |
| 154 | +		} elseif( isset(static::$helpers[$k]) && static::$helpers[$k][0] != $class ) { | 
                                                        |
| 155 | +					throw new \Exception(sprintf("Helper method '%s' already defined in class '%s', duplicate in '%s'", $method, static::$helpers[$k][0], $class)); | 
                                                        |
| 156 | + }  | 
                                                        |
| 153 | 157 | |
| 154 | 158 | static::$helpers[$k] = [$class, $method];  | 
                                                        
| 155 | 159 | |
@@ -182,8 +186,7 @@ discard block  | 
                                                    ||
| 182 | 186 | |
| 183 | 187 | return $result;  | 
                                                        
| 184 | 188 | |
| 185 | - }  | 
                                                        |
| 186 | -		catch( \Exception $e ) { | 
                                                        |
| 189 | +		} catch( \Exception $e ) { | 
                                                        |
| 187 | 190 | static::exception($e);  | 
                                                        
| 188 | 191 | }  | 
                                                        
| 189 | 192 | |
@@ -234,8 +237,9 @@ discard block  | 
                                                    ||
| 234 | 237 | |
| 235 | 238 | $k = strtolower($method);  | 
                                                        
| 236 | 239 | |
| 237 | - if( !isset(static::$helpers[$k]) )  | 
                                                        |
| 238 | -			throw new \BadMethodCallException("Unknown helper method '$method'"); | 
                                                        |
| 240 | +		if( !isset(static::$helpers[$k]) ) { | 
                                                        |
| 241 | +					throw new \BadMethodCallException("Unknown helper method '$method'"); | 
                                                        |
| 242 | + }  | 
                                                        |
| 239 | 243 | |
| 240 | 244 | return call_user_func_array(static::$helpers[$k], $args);  | 
                                                        
| 241 | 245 | |
@@ -16,11 +16,11 @@ discard block  | 
                                                    ||
| 16 | 16 | const LOCK_DIR = '/tmp';  | 
                                                        
| 17 | 17 | const PS_EXEC = 'ps --no-heading -p ';  | 
                                                        
| 18 | 18 | |
| 19 | - abstract public function run( array $args );  | 
                                                        |
| 19 | + abstract public function run(array $args);  | 
                                                        |
| 20 | 20 | |
| 21 | 21 |  	public function __invoke() { | 
                                                        
| 22 | 22 | |
| 23 | - if( !$this->lock() )  | 
                                                        |
| 23 | + if (!$this->lock())  | 
                                                        |
| 24 | 24 |  			throw new \RuntimeException(sprintf('An instance of \\%s is already running', get_class($this))); | 
                                                        
| 25 | 25 | |
| 26 | 26 | $result = $this->run(  | 
                                                        
@@ -38,7 +38,7 @@ discard block  | 
                                                    ||
| 38 | 38 | * @author Patrick Fisher <[email protected]>  | 
                                                        
| 39 | 39 | * @see https://github.com/pwfisher/CommandLine.php  | 
                                                        
| 40 | 40 | */  | 
                                                        
| 41 | -	protected function parseArgs( $argv = null ) { | 
                                                        |
| 41 | +	protected function parseArgs($argv = null) { | 
                                                        |
| 42 | 42 | $argv = $argv ? $argv : $_SERVER['argv']; array_shift($argv); $o = [];  | 
                                                        
| 43 | 43 |  		for ($i = 0, $j = count($argv); $i < $j; $i++) { $a = $argv[$i]; | 
                                                        
| 44 | 44 |  			if (substr($a, 0, 2) == '--') { $eq = strpos($a, '='); | 
                                                        
@@ -60,7 +60,7 @@ discard block  | 
                                                    ||
| 60 | 60 | * @return string  | 
                                                        
| 61 | 61 | */  | 
                                                        
| 62 | 62 |  	protected function getLockFile() { | 
                                                        
| 63 | -		return rtrim(static::LOCK_DIR, '/'). '/'. strtolower(str_replace('\\', '-', get_class($this))); | 
                                                        |
| 63 | +		return rtrim(static::LOCK_DIR, '/').'/'.strtolower(str_replace('\\', '-', get_class($this))); | 
                                                        |
| 64 | 64 | }  | 
                                                        
| 65 | 65 | |
| 66 | 66 |  	protected function isLocked() { | 
                                                        
@@ -69,11 +69,11 @@ discard block  | 
                                                    ||
| 69 | 69 | $locked = file_exists($lock = $this->getLockFile());  | 
                                                        
| 70 | 70 | |
| 71 | 71 | // if it does then check the process is actually still running  | 
                                                        
| 72 | -		if( $locked ) { | 
                                                        |
| 72 | +		if ($locked) { | 
                                                        |
| 73 | 73 | $pid = file_get_contents($lock);  | 
                                                        
| 74 | - $locked = exec(static::PS_EXEC. $pid) != '';  | 
                                                        |
| 74 | + $locked = exec(static::PS_EXEC.$pid) != '';  | 
                                                        |
| 75 | 75 | // no such process so remove the lock file  | 
                                                        
| 76 | - if( !$locked )  | 
                                                        |
| 76 | + if (!$locked)  | 
                                                        |
| 77 | 77 | $this->unlock();  | 
                                                        
| 78 | 78 | }  | 
                                                        
| 79 | 79 | |
@@ -84,11 +84,11 @@ discard block  | 
                                                    ||
| 84 | 84 |  	protected function lock() { | 
                                                        
| 85 | 85 | |
| 86 | 86 | // locked by running process  | 
                                                        
| 87 | - if( $this->isLocked() )  | 
                                                        |
| 87 | + if ($this->isLocked())  | 
                                                        |
| 88 | 88 | return false;  | 
                                                        
| 89 | 89 | |
| 90 | 90 | // open the lock file only if it doesn't exist  | 
                                                        
| 91 | - if( !$fh = @fopen($this->getLockFile(), 'x') )  | 
                                                        |
| 91 | + if (!$fh = @fopen($this->getLockFile(), 'x'))  | 
                                                        |
| 92 | 92 | return false;  | 
                                                        
| 93 | 93 | |
| 94 | 94 | // clear it and write out the new PID  | 
                                                        
@@ -104,14 +104,14 @@ discard block  | 
                                                    ||
| 104 | 104 | |
| 105 | 105 | $lock = $this->getLockFile();  | 
                                                        
| 106 | 106 | |
| 107 | -		if( file_exists($lock) ) { | 
                                                        |
| 107 | +		if (file_exists($lock)) { | 
                                                        |
| 108 | 108 | |
| 109 | 109 | // PIDs don't match - ooops!  | 
                                                        
| 110 | - if( file_get_contents($lock) != getmypid() )  | 
                                                        |
| 110 | + if (file_get_contents($lock) != getmypid())  | 
                                                        |
| 111 | 111 |  				throw new \RuntimeException('Lock file contains incorrect PID'); | 
                                                        
| 112 | 112 | |
| 113 | 113 | // Delete the lock file  | 
                                                        
| 114 | - if( !unlink($lock) )  | 
                                                        |
| 114 | + if (!unlink($lock))  | 
                                                        |
| 115 | 115 |  				throw new \RuntimeException('Unable to remove lock file'); | 
                                                        
| 116 | 116 | |
| 117 | 117 | }  | 
                                                        
@@ -20,8 +20,9 @@ discard block  | 
                                                    ||
| 20 | 20 | |
| 21 | 21 |  	public function __invoke() { | 
                                                        
| 22 | 22 | |
| 23 | - if( !$this->lock() )  | 
                                                        |
| 24 | -			throw new \RuntimeException(sprintf('An instance of \\%s is already running', get_class($this))); | 
                                                        |
| 23 | +		if( !$this->lock() ) { | 
                                                        |
| 24 | +					throw new \RuntimeException(sprintf('An instance of \\%s is already running', get_class($this))); | 
                                                        |
| 25 | + }  | 
                                                        |
| 25 | 26 | |
| 26 | 27 | $result = $this->run(  | 
                                                        
| 27 | 28 | $this->parseArgs()  | 
                                                        
@@ -42,16 +43,11 @@ discard block  | 
                                                    ||
| 42 | 43 | $argv = $argv ? $argv : $_SERVER['argv']; array_shift($argv); $o = [];  | 
                                                        
| 43 | 44 |  		for ($i = 0, $j = count($argv); $i < $j; $i++) { $a = $argv[$i]; | 
                                                        
| 44 | 45 |  			if (substr($a, 0, 2) == '--') { $eq = strpos($a, '='); | 
                                                        
| 45 | -				if ($eq !== false) { $o[substr($a, 2, $eq - 2)] = substr($a, $eq + 1); } | 
                                                        |
| 46 | -				else { $k = substr($a, 2); | 
                                                        |
| 47 | -					if ($i + 1 < $j && $argv[$i + 1][0] !== '-') { $o[$k] = $argv[$i + 1]; $i++; } | 
                                                        |
| 48 | -					else if (!isset($o[$k])) { $o[$k] = true; } } } | 
                                                        |
| 49 | -			else if (substr($a, 0, 1) == '-') { | 
                                                        |
| 50 | -				if (substr($a, 2, 1) == '=') { $o[substr($a, 1, 1)] = substr($a, 3); } | 
                                                        |
| 51 | -				else { | 
                                                        |
| 46 | +				if ($eq !== false) { $o[substr($a, 2, $eq - 2)] = substr($a, $eq + 1); } else { $k = substr($a, 2); | 
                                                        |
| 47 | +					if ($i + 1 < $j && $argv[$i + 1][0] !== '-') { $o[$k] = $argv[$i + 1]; $i++; } else if (!isset($o[$k])) { $o[$k] = true; } } } else if (substr($a, 0, 1) == '-') { | 
                                                        |
| 48 | +				if (substr($a, 2, 1) == '=') { $o[substr($a, 1, 1)] = substr($a, 3); } else { | 
                                                        |
| 52 | 49 |  					foreach (str_split(substr($a, 1)) as $k) { if (!isset($o[$k])) { $o[$k] = true; } } | 
                                                        
| 53 | -					if ($i + 1 < $j && $argv[$i + 1][0] !== '-') { $o[$k] = $argv[$i + 1]; $i++; } } } | 
                                                        |
| 54 | -			else { $o[] = $a; } } | 
                                                        |
| 50 | +					if ($i + 1 < $j && $argv[$i + 1][0] !== '-') { $o[$k] = $argv[$i + 1]; $i++; } } } else { $o[] = $a; } } | 
                                                        |
| 55 | 51 | return $o;  | 
                                                        
| 56 | 52 | }  | 
                                                        
| 57 | 53 | |
@@ -73,8 +69,9 @@ discard block  | 
                                                    ||
| 73 | 69 | $pid = file_get_contents($lock);  | 
                                                        
| 74 | 70 | $locked = exec(static::PS_EXEC. $pid) != '';  | 
                                                        
| 75 | 71 | // no such process so remove the lock file  | 
                                                        
| 76 | - if( !$locked )  | 
                                                        |
| 77 | - $this->unlock();  | 
                                                        |
| 72 | +			if( !$locked ) { | 
                                                        |
| 73 | + $this->unlock();  | 
                                                        |
| 74 | + }  | 
                                                        |
| 78 | 75 | }  | 
                                                        
| 79 | 76 | |
| 80 | 77 | return $locked;  | 
                                                        
@@ -84,12 +81,14 @@ discard block  | 
                                                    ||
| 84 | 81 |  	protected function lock() { | 
                                                        
| 85 | 82 | |
| 86 | 83 | // locked by running process  | 
                                                        
| 87 | - if( $this->isLocked() )  | 
                                                        |
| 88 | - return false;  | 
                                                        |
| 84 | +		if( $this->isLocked() ) { | 
                                                        |
| 85 | + return false;  | 
                                                        |
| 86 | + }  | 
                                                        |
| 89 | 87 | |
| 90 | 88 | // open the lock file only if it doesn't exist  | 
                                                        
| 91 | - if( !$fh = @fopen($this->getLockFile(), 'x') )  | 
                                                        |
| 92 | - return false;  | 
                                                        |
| 89 | +		if( !$fh = @fopen($this->getLockFile(), 'x') ) { | 
                                                        |
| 90 | + return false;  | 
                                                        |
| 91 | + }  | 
                                                        |
| 93 | 92 | |
| 94 | 93 | // clear it and write out the new PID  | 
                                                        
| 95 | 94 | ftruncate($fh, 0);  | 
                                                        
@@ -107,12 +106,14 @@ discard block  | 
                                                    ||
| 107 | 106 |  		if( file_exists($lock) ) { | 
                                                        
| 108 | 107 | |
| 109 | 108 | // PIDs don't match - ooops!  | 
                                                        
| 110 | - if( file_get_contents($lock) != getmypid() )  | 
                                                        |
| 111 | -				throw new \RuntimeException('Lock file contains incorrect PID'); | 
                                                        |
| 109 | +			if( file_get_contents($lock) != getmypid() ) { | 
                                                        |
| 110 | +							throw new \RuntimeException('Lock file contains incorrect PID'); | 
                                                        |
| 111 | + }  | 
                                                        |
| 112 | 112 | |
| 113 | 113 | // Delete the lock file  | 
                                                        
| 114 | - if( !unlink($lock) )  | 
                                                        |
| 115 | -				throw new \RuntimeException('Unable to remove lock file'); | 
                                                        |
| 114 | +			if( !unlink($lock) ) { | 
                                                        |
| 115 | +							throw new \RuntimeException('Unable to remove lock file'); | 
                                                        |
| 116 | + }  | 
                                                        |
| 116 | 117 | |
| 117 | 118 | }  | 
                                                        
| 118 | 119 | |
@@ -92,27 +92,27 @@ discard block  | 
                                                    ||
| 92 | 92 | );  | 
                                                        
| 93 | 93 | |
| 94 | 94 | // TODO: cache results to speed up subsequent use?  | 
                                                        
| 95 | -	public static function pluralise( $string ) { | 
                                                        |
| 95 | +	public static function pluralise($string) { | 
                                                        |
| 96 | 96 | |
| 97 | 97 | // save some time in the case that singular and plural are the same  | 
                                                        
| 98 | - if ( in_array( mb_strtolower( $string ), self::$uncountable ) )  | 
                                                        |
| 98 | + if (in_array(mb_strtolower($string), self::$uncountable))  | 
                                                        |
| 99 | 99 | return $string;  | 
                                                        
| 100 | 100 | |
| 101 | 101 | |
| 102 | 102 | // check for irregular singular forms  | 
                                                        
| 103 | - foreach ( self::$irregular as $pattern => $result )  | 
                                                        |
| 103 | + foreach (self::$irregular as $pattern => $result)  | 
                                                        |
| 104 | 104 |  		{ | 
                                                        
| 105 | - $pattern = '/' . $pattern . '$/iu';  | 
                                                        |
| 105 | + $pattern = '/'.$pattern.'$/iu';  | 
                                                        |
| 106 | 106 | |
| 107 | - if ( preg_match( $pattern, $string ) )  | 
                                                        |
| 108 | - return preg_replace( $pattern, $result, $string);  | 
                                                        |
| 107 | + if (preg_match($pattern, $string))  | 
                                                        |
| 108 | + return preg_replace($pattern, $result, $string);  | 
                                                        |
| 109 | 109 | }  | 
                                                        
| 110 | 110 | |
| 111 | 111 | // check for matches using regular expressions  | 
                                                        
| 112 | - foreach ( self::$plural as $pattern => $result )  | 
                                                        |
| 112 | + foreach (self::$plural as $pattern => $result)  | 
                                                        |
| 113 | 113 |  		{ | 
                                                        
| 114 | - if ( preg_match( $pattern, $string ) )  | 
                                                        |
| 115 | - return preg_replace( $pattern, $result, $string );  | 
                                                        |
| 114 | + if (preg_match($pattern, $string))  | 
                                                        |
| 115 | + return preg_replace($pattern, $result, $string);  | 
                                                        |
| 116 | 116 | }  | 
                                                        
| 117 | 117 | |
| 118 | 118 | return $string;  | 
                                                        
@@ -120,22 +120,22 @@ discard block  | 
                                                    ||
| 120 | 120 | }  | 
                                                        
| 121 | 121 | |
| 122 | 122 | // TODO: cache results to speed up subsequent use?  | 
                                                        
| 123 | -	public static function singularise( $string ) { | 
                                                        |
| 123 | +	public static function singularise($string) { | 
                                                        |
| 124 | 124 | |
| 125 | 125 | // save some time in the case that singular and plural are the same  | 
                                                        
| 126 | - if ( in_array(mb_strtolower($string), self::$uncountable) )  | 
                                                        |
| 126 | + if (in_array(mb_strtolower($string), self::$uncountable))  | 
                                                        |
| 127 | 127 | return $string;  | 
                                                        
| 128 | 128 | |
| 129 | 129 | // check for irregular plural forms  | 
                                                        
| 130 | -		foreach( self::$irregular as $result => $pattern ) { | 
                                                        |
| 131 | - $pattern = '/' . $pattern . '$/iu';  | 
                                                        |
| 132 | - if( preg_match($pattern, $string) )  | 
                                                        |
| 130 | +		foreach (self::$irregular as $result => $pattern) { | 
                                                        |
| 131 | + $pattern = '/'.$pattern.'$/iu';  | 
                                                        |
| 132 | + if (preg_match($pattern, $string))  | 
                                                        |
| 133 | 133 | return preg_replace($pattern, $result, $string);  | 
                                                        
| 134 | 134 | }  | 
                                                        
| 135 | 135 | |
| 136 | 136 | // check for matches using regular expressions  | 
                                                        
| 137 | -		foreach( self::$singular as $pattern => $result ) { | 
                                                        |
| 138 | - if( preg_match($pattern, $string) )  | 
                                                        |
| 137 | +		foreach (self::$singular as $pattern => $result) { | 
                                                        |
| 138 | + if (preg_match($pattern, $string))  | 
                                                        |
| 139 | 139 | return preg_replace($pattern, $result, $string);  | 
                                                        
| 140 | 140 | }  | 
                                                        
| 141 | 141 | |
@@ -95,8 +95,9 @@ discard block  | 
                                                    ||
| 95 | 95 |  	public static function pluralise( $string ) { | 
                                                        
| 96 | 96 | |
| 97 | 97 | // save some time in the case that singular and plural are the same  | 
                                                        
| 98 | - if ( in_array( mb_strtolower( $string ), self::$uncountable ) )  | 
                                                        |
| 99 | - return $string;  | 
                                                        |
| 98 | +		if ( in_array( mb_strtolower( $string ), self::$uncountable ) ) { | 
                                                        |
| 99 | + return $string;  | 
                                                        |
| 100 | + }  | 
                                                        |
| 100 | 101 | |
| 101 | 102 | |
| 102 | 103 | // check for irregular singular forms  | 
                                                        
@@ -104,15 +105,17 @@ discard block  | 
                                                    ||
| 104 | 105 |  		{ | 
                                                        
| 105 | 106 | $pattern = '/' . $pattern . '$/iu';  | 
                                                        
| 106 | 107 | |
| 107 | - if ( preg_match( $pattern, $string ) )  | 
                                                        |
| 108 | - return preg_replace( $pattern, $result, $string);  | 
                                                        |
| 108 | +			if ( preg_match( $pattern, $string ) ) { | 
                                                        |
| 109 | + return preg_replace( $pattern, $result, $string);  | 
                                                        |
| 110 | + }  | 
                                                        |
| 109 | 111 | }  | 
                                                        
| 110 | 112 | |
| 111 | 113 | // check for matches using regular expressions  | 
                                                        
| 112 | 114 | foreach ( self::$plural as $pattern => $result )  | 
                                                        
| 113 | 115 |  		{ | 
                                                        
| 114 | - if ( preg_match( $pattern, $string ) )  | 
                                                        |
| 115 | - return preg_replace( $pattern, $result, $string );  | 
                                                        |
| 116 | +			if ( preg_match( $pattern, $string ) ) { | 
                                                        |
| 117 | + return preg_replace( $pattern, $result, $string );  | 
                                                        |
| 118 | + }  | 
                                                        |
| 116 | 119 | }  | 
                                                        
| 117 | 120 | |
| 118 | 121 | return $string;  | 
                                                        
@@ -123,20 +126,23 @@ discard block  | 
                                                    ||
| 123 | 126 |  	public static function singularise( $string ) { | 
                                                        
| 124 | 127 | |
| 125 | 128 | // save some time in the case that singular and plural are the same  | 
                                                        
| 126 | - if ( in_array(mb_strtolower($string), self::$uncountable) )  | 
                                                        |
| 127 | - return $string;  | 
                                                        |
| 129 | +		if ( in_array(mb_strtolower($string), self::$uncountable) ) { | 
                                                        |
| 130 | + return $string;  | 
                                                        |
| 131 | + }  | 
                                                        |
| 128 | 132 | |
| 129 | 133 | // check for irregular plural forms  | 
                                                        
| 130 | 134 |  		foreach( self::$irregular as $result => $pattern ) { | 
                                                        
| 131 | 135 | $pattern = '/' . $pattern . '$/iu';  | 
                                                        
| 132 | - if( preg_match($pattern, $string) )  | 
                                                        |
| 133 | - return preg_replace($pattern, $result, $string);  | 
                                                        |
| 136 | +			if( preg_match($pattern, $string) ) { | 
                                                        |
| 137 | + return preg_replace($pattern, $result, $string);  | 
                                                        |
| 138 | + }  | 
                                                        |
| 134 | 139 | }  | 
                                                        
| 135 | 140 | |
| 136 | 141 | // check for matches using regular expressions  | 
                                                        
| 137 | 142 |  		foreach( self::$singular as $pattern => $result ) { | 
                                                        
| 138 | - if( preg_match($pattern, $string) )  | 
                                                        |
| 139 | - return preg_replace($pattern, $result, $string);  | 
                                                        |
| 143 | +			if( preg_match($pattern, $string) ) { | 
                                                        |
| 144 | + return preg_replace($pattern, $result, $string);  | 
                                                        |
| 145 | + }  | 
                                                        |
| 140 | 146 | }  | 
                                                        
| 141 | 147 | |
| 142 | 148 | return $string;  | 
                                                        
@@ -24,7 +24,7 @@ discard block  | 
                                                    ||
| 24 | 24 | * @param mixed $var  | 
                                                        
| 25 | 25 | * @return array  | 
                                                        
| 26 | 26 | */  | 
                                                        
| 27 | -	public static function uniqueIntegers( $var ) { | 
                                                        |
| 27 | +	public static function uniqueIntegers($var) { | 
                                                        |
| 28 | 28 | return array_unique(  | 
                                                        
| 29 | 29 | array_map(  | 
                                                        
| 30 | 30 | 'intval',  | 
                                                        
@@ -38,7 +38,7 @@ discard block  | 
                                                    ||
| 38 | 38 | * @param mixed $var  | 
                                                        
| 39 | 39 | * @return boolean  | 
                                                        
| 40 | 40 | */  | 
                                                        
| 41 | -	public static function isTraversable( $var ) { | 
                                                        |
| 41 | +	public static function isTraversable($var) { | 
                                                        |
| 42 | 42 | return is_array($var) || ($var instanceof \Traversable);  | 
                                                        
| 43 | 43 | }  | 
                                                        
| 44 | 44 | |
@@ -49,7 +49,7 @@ discard block  | 
                                                    ||
| 49 | 49 | * @param array $var  | 
                                                        
| 50 | 50 | * @return bool  | 
                                                        
| 51 | 51 | */  | 
                                                        
| 52 | -	public static function isAssoc( $var ) { | 
                                                        |
| 52 | +	public static function isAssoc($var) { | 
                                                        |
| 53 | 53 | return (bool) count(  | 
                                                        
| 54 | 54 | array_filter(  | 
                                                        
| 55 | 55 | array_keys($var),  | 
                                                        
@@ -65,12 +65,12 @@ discard block  | 
                                                    ||
| 65 | 65 | * @param string $class The class that items should be an instance of  | 
                                                        
| 66 | 66 | * @return array  | 
                                                        
| 67 | 67 | */  | 
                                                        
| 68 | -	public static function filterObjects( $var, $class ) { | 
                                                        |
| 69 | - if( !is_array($var) )  | 
                                                        |
| 68 | +	public static function filterObjects($var, $class) { | 
                                                        |
| 69 | + if (!is_array($var))  | 
                                                        |
| 70 | 70 | $var = array($var);  | 
                                                        
| 71 | 71 | return array_filter(  | 
                                                        
| 72 | 72 | $var,  | 
                                                        
| 73 | -			function( $item ) use ($class) { | 
                                                        |
| 73 | +			function($item) use ($class) { | 
                                                        |
| 74 | 74 | return ($item instanceof $class);  | 
                                                        
| 75 | 75 | }  | 
                                                        
| 76 | 76 | );  | 
                                                        
@@ -83,13 +83,13 @@ discard block  | 
                                                    ||
| 83 | 83 | * @param mixed $default  | 
                                                        
| 84 | 84 | * @return mixed  | 
                                                        
| 85 | 85 | */  | 
                                                        
| 86 | -	public static function get( $var, $key, $default = null ) { | 
                                                        |
| 86 | +	public static function get($var, $key, $default = null) { | 
                                                        |
| 87 | 87 | |
| 88 | - if( $key === null )  | 
                                                        |
| 88 | + if ($key === null)  | 
                                                        |
| 89 | 89 | return $var;  | 
                                                        
| 90 | - elseif( isset($var->$key) )  | 
                                                        |
| 90 | + elseif (isset($var->$key))  | 
                                                        |
| 91 | 91 | return $var->$key;  | 
                                                        
| 92 | - elseif( isset($var[$key]) )  | 
                                                        |
| 92 | + elseif (isset($var[$key]))  | 
                                                        |
| 93 | 93 | return $var[$key];  | 
                                                        
| 94 | 94 | else  | 
                                                        
| 95 | 95 | return $default;  | 
                                                        
@@ -101,8 +101,8 @@ discard block  | 
                                                    ||
| 101 | 101 | * @param array $var  | 
                                                        
| 102 | 102 | * @return array  | 
                                                        
| 103 | 103 | */  | 
                                                        
| 104 | -	public static function getNullItems( $var ) { | 
                                                        |
| 105 | -		return array_filter($var, function( $a ) { return $a === null; }); | 
                                                        |
| 104 | +	public static function getNullItems($var) { | 
                                                        |
| 105 | +		return array_filter($var, function($a) { return $a === null; }); | 
                                                        |
| 106 | 106 | }  | 
                                                        
| 107 | 107 | |
| 108 | 108 | /**  | 
                                                        
@@ -113,9 +113,9 @@ discard block  | 
                                                    ||
| 113 | 113 | * @param boolean $preserve_keys Whether or not to preserve the array keys  | 
                                                        
| 114 | 114 | * @return array  | 
                                                        
| 115 | 115 | */  | 
                                                        
| 116 | -	public static function pluck( $vars, $field, $preserve_keys = true ) { | 
                                                        |
| 116 | +	public static function pluck($vars, $field, $preserve_keys = true) { | 
                                                        |
| 117 | 117 | $values = [];  | 
                                                        
| 118 | -		foreach( $vars as $k => $v ) { | 
                                                        |
| 118 | +		foreach ($vars as $k => $v) { | 
                                                        |
| 119 | 119 | $values[$k] = static::get($v, $field);  | 
                                                        
| 120 | 120 | }  | 
                                                        
| 121 | 121 | return $preserve_keys ? $values : array_values($values);  | 
                                                        
@@ -128,7 +128,7 @@ discard block  | 
                                                    ||
| 128 | 128 | * @param string $field The field to get values from  | 
                                                        
| 129 | 129 | * @return array  | 
                                                        
| 130 | 130 | */  | 
                                                        
| 131 | -	public static function sum( $vars, $field ) { | 
                                                        |
| 131 | +	public static function sum($vars, $field) { | 
                                                        |
| 132 | 132 | return array_sum(static::pluck($vars, $field));  | 
                                                        
| 133 | 133 | }  | 
                                                        
| 134 | 134 | |
@@ -139,7 +139,7 @@ discard block  | 
                                                    ||
| 139 | 139 | * @param string $field The field to get values from  | 
                                                        
| 140 | 140 | * @return array  | 
                                                        
| 141 | 141 | */  | 
                                                        
| 142 | -	public static function min( $vars, $field ) { | 
                                                        |
| 142 | +	public static function min($vars, $field) { | 
                                                        |
| 143 | 143 | return min(static::pluck($vars, $field));  | 
                                                        
| 144 | 144 | }  | 
                                                        
| 145 | 145 | |
@@ -150,7 +150,7 @@ discard block  | 
                                                    ||
| 150 | 150 | * @param string $field The field to get values from  | 
                                                        
| 151 | 151 | * @return array  | 
                                                        
| 152 | 152 | */  | 
                                                        
| 153 | -	public static function max( $vars, $field ) { | 
                                                        |
| 153 | +	public static function max($vars, $field) { | 
                                                        |
| 154 | 154 | return max(static::pluck($vars, $field));  | 
                                                        
| 155 | 155 | }  | 
                                                        
| 156 | 156 | |
@@ -163,10 +163,10 @@ discard block  | 
                                                    ||
| 163 | 163 | * @param boolean $skip_empty Should empty values be included?  | 
                                                        
| 164 | 164 | * @return string  | 
                                                        
| 165 | 165 | */  | 
                                                        
| 166 | -	public static function implodeAssoc( $var, $glue_outer = ',', $glue_inner = '=', $skip_empty = true ) { | 
                                                        |
| 166 | +	public static function implodeAssoc($var, $glue_outer = ',', $glue_inner = '=', $skip_empty = true) { | 
                                                        |
| 167 | 167 | $output = [];  | 
                                                        
| 168 | -		foreach( $var as $k => $v ) { | 
                                                        |
| 169 | -			if( !$skip_empty || !empty($v) ) { | 
                                                        |
| 168 | +		foreach ($var as $k => $v) { | 
                                                        |
| 169 | +			if (!$skip_empty || !empty($v)) { | 
                                                        |
| 170 | 170 |  				$output[] = "{$k}{$glue_inner}{$v}"; | 
                                                        
| 171 | 171 | }  | 
                                                        
| 172 | 172 | }  | 
                                                        
@@ -191,21 +191,21 @@ discard block  | 
                                                    ||
| 191 | 191 | |
| 192 | 192 | // normalize criteria up front so that the comparer finds everything tidy  | 
                                                        
| 193 | 193 | $criteria = func_get_args();  | 
                                                        
| 194 | -		foreach( $criteria as $index => $criterion ) { | 
                                                        |
| 194 | +		foreach ($criteria as $index => $criterion) { | 
                                                        |
| 195 | 195 | $criteria[$index] = is_array($criterion)  | 
                                                        
| 196 | 196 | ? array_pad($criterion, 3, null)  | 
                                                        
| 197 | 197 | : array($criterion, SORT_ASC, null);  | 
                                                        
| 198 | 198 | }  | 
                                                        
| 199 | 199 | |
| 200 | -		return function( $first, $second ) use ($criteria) { | 
                                                        |
| 201 | -			foreach( $criteria as $criterion ) { | 
                                                        |
| 200 | +		return function($first, $second) use ($criteria) { | 
                                                        |
| 201 | +			foreach ($criteria as $criterion) { | 
                                                        |
| 202 | 202 | |
| 203 | 203 | // how will we compare this round?  | 
                                                        
| 204 | 204 | list($column, $sort_order, $projection) = $criterion;  | 
                                                        
| 205 | 205 | $sort_order = $sort_order === SORT_DESC ? -1 : 1;  | 
                                                        
| 206 | 206 | |
| 207 | 207 | // if a projection was defined project the values now  | 
                                                        
| 208 | -				if( $projection ) { | 
                                                        |
| 208 | +				if ($projection) { | 
                                                        |
| 209 | 209 | $lhs = call_user_func($projection, $first[$column]);  | 
                                                        
| 210 | 210 | $rhs = call_user_func($projection, $second[$column]);  | 
                                                        
| 211 | 211 | }  | 
                                                        
@@ -215,7 +215,7 @@ discard block  | 
                                                    ||
| 215 | 215 | }  | 
                                                        
| 216 | 216 | |
| 217 | 217 | // do the actual comparison; do not return if equal, move on to the next column  | 
                                                        
| 218 | -				if( $lhs < $rhs ) { | 
                                                        |
| 218 | +				if ($lhs < $rhs) { | 
                                                        |
| 219 | 219 | return -1 * $sort_order;  | 
                                                        
| 220 | 220 | }  | 
                                                        
| 221 | 221 |  				else if ($lhs > $rhs) { | 
                                                        
@@ -66,8 +66,9 @@ discard block  | 
                                                    ||
| 66 | 66 | * @return array  | 
                                                        
| 67 | 67 | */  | 
                                                        
| 68 | 68 |  	public static function filterObjects( $var, $class ) { | 
                                                        
| 69 | - if( !is_array($var) )  | 
                                                        |
| 70 | - $var = array($var);  | 
                                                        |
| 69 | +		if( !is_array($var) ) { | 
                                                        |
| 70 | + $var = array($var);  | 
                                                        |
| 71 | + }  | 
                                                        |
| 71 | 72 | return array_filter(  | 
                                                        
| 72 | 73 | $var,  | 
                                                        
| 73 | 74 |  			function( $item ) use ($class) { | 
                                                        
@@ -85,14 +86,15 @@ discard block  | 
                                                    ||
| 85 | 86 | */  | 
                                                        
| 86 | 87 |  	public static function get( $var, $key, $default = null ) { | 
                                                        
| 87 | 88 | |
| 88 | - if( $key === null )  | 
                                                        |
| 89 | - return $var;  | 
                                                        |
| 90 | - elseif( isset($var->$key) )  | 
                                                        |
| 91 | - return $var->$key;  | 
                                                        |
| 92 | - elseif( isset($var[$key]) )  | 
                                                        |
| 93 | - return $var[$key];  | 
                                                        |
| 94 | - else  | 
                                                        |
| 95 | - return $default;  | 
                                                        |
| 89 | +		if( $key === null ) { | 
                                                        |
| 90 | + return $var;  | 
                                                        |
| 91 | +		} elseif( isset($var->$key) ) { | 
                                                        |
| 92 | + return $var->$key;  | 
                                                        |
| 93 | +		} elseif( isset($var[$key]) ) { | 
                                                        |
| 94 | + return $var[$key];  | 
                                                        |
| 95 | +		} else { | 
                                                        |
| 96 | + return $default;  | 
                                                        |
| 97 | + }  | 
                                                        |
| 96 | 98 | |
| 97 | 99 | }  | 
                                                        
| 98 | 100 | |
@@ -208,8 +210,7 @@ discard block  | 
                                                    ||
| 208 | 210 |  				if( $projection ) { | 
                                                        
| 209 | 211 | $lhs = call_user_func($projection, $first[$column]);  | 
                                                        
| 210 | 212 | $rhs = call_user_func($projection, $second[$column]);  | 
                                                        
| 211 | - }  | 
                                                        |
| 212 | -				else { | 
                                                        |
| 213 | +				} else { | 
                                                        |
| 213 | 214 | $lhs = $first[$column];  | 
                                                        
| 214 | 215 | $rhs = $second[$column];  | 
                                                        
| 215 | 216 | }  | 
                                                        
@@ -217,8 +218,7 @@ discard block  | 
                                                    ||
| 217 | 218 | // do the actual comparison; do not return if equal, move on to the next column  | 
                                                        
| 218 | 219 |  				if( $lhs < $rhs ) { | 
                                                        
| 219 | 220 | return -1 * $sort_order;  | 
                                                        
| 220 | - }  | 
                                                        |
| 221 | -				else if ($lhs > $rhs) { | 
                                                        |
| 221 | +				} else if ($lhs > $rhs) { | 
                                                        |
| 222 | 222 | return 1 * $sort_order;  | 
                                                        
| 223 | 223 | }  | 
                                                        
| 224 | 224 | |
@@ -27,14 +27,14 @@ discard block  | 
                                                    ||
| 27 | 27 | * @param array $defaults an array of default values for components  | 
                                                        
| 28 | 28 | * @return array|boolean Returns false if the URL could not be parsed  | 
                                                        
| 29 | 29 | */  | 
                                                        
| 30 | -	public static function parseURL( $url, $defaults = array() ) { | 
                                                        |
| 30 | +	public static function parseURL($url, $defaults = array()) { | 
                                                        |
| 31 | 31 | |
| 32 | 32 | $parts = is_string($url) ? \parse_url(urldecode($url)) : $url;  | 
                                                        
| 33 | 33 | |
| 34 | -		$select = function( $k ) use ( $parts, $defaults ) { | 
                                                        |
| 35 | - if( isset($parts[$k]) )  | 
                                                        |
| 34 | +		$select = function($k) use ($parts, $defaults) { | 
                                                        |
| 35 | + if (isset($parts[$k]))  | 
                                                        |
| 36 | 36 | return $parts[$k];  | 
                                                        
| 37 | - elseif( isset($defaults[$k]) )  | 
                                                        |
| 37 | + elseif (isset($defaults[$k]))  | 
                                                        |
| 38 | 38 | return $defaults[$k];  | 
                                                        
| 39 | 39 | else  | 
                                                        
| 40 | 40 | return '';  | 
                                                        
@@ -50,7 +50,7 @@ discard block  | 
                                                    ||
| 50 | 50 | 'options' => array(),  | 
                                                        
| 51 | 51 | );  | 
                                                        
| 52 | 52 | |
| 53 | - if( isset($parts['query']) )  | 
                                                        |
| 53 | + if (isset($parts['query']))  | 
                                                        |
| 54 | 54 | parse_str($parts['query'], $url['options']);  | 
                                                        
| 55 | 55 | |
| 56 | 56 | return $url;  | 
                                                        
@@ -63,7 +63,7 @@ discard block  | 
                                                    ||
| 63 | 63 | * @param integer $length length of the desired hex string  | 
                                                        
| 64 | 64 | * @return string  | 
                                                        
| 65 | 65 | */  | 
                                                        
| 66 | -	public static function randomHex( $length = 40 ) { | 
                                                        |
| 66 | +	public static function randomHex($length = 40) { | 
                                                        |
| 67 | 67 | return bin2hex(openssl_random_pseudo_bytes($length / 2));  | 
                                                        
| 68 | 68 | }  | 
                                                        
| 69 | 69 | |
@@ -75,7 +75,7 @@ discard block  | 
                                                    ||
| 75 | 75 | * @param string $allowed the characters allowed to appear in the output  | 
                                                        
| 76 | 76 | * @return string  | 
                                                        
| 77 | 77 | */  | 
                                                        
| 78 | -	public static function randomString( $length, $allowed = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ) { | 
                                                        |
| 78 | +	public static function randomString($length, $allowed = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') { | 
                                                        |
| 79 | 79 | $out = '';  | 
                                                        
| 80 | 80 | $max = strlen($allowed) - 1;  | 
                                                        
| 81 | 81 |  		for ($i = 0; $i < $length; $i++) { | 
                                                        
@@ -87,10 +87,10 @@ discard block  | 
                                                    ||
| 87 | 87 | /**  | 
                                                        
| 88 | 88 | * Convert a camel-cased string to lower case with underscores  | 
                                                        
| 89 | 89 | */  | 
                                                        
| 90 | -	public static function uncamelise( $str ) { | 
                                                        |
| 90 | +	public static function uncamelise($str) { | 
                                                        |
| 91 | 91 | return mb_strtolower(  | 
                                                        
| 92 | 92 | preg_replace(  | 
                                                        
| 93 | - '/^A-Z^a-z^0-9]+/', '_',  | 
                                                        |
| 93 | + '/^A-Z^a-z^0-9]+/', '_',  | 
                                                        |
| 94 | 94 |  				preg_replace('/([a-z\d])([A-Z])/u', '$1_$2', | 
                                                        
| 95 | 95 |  					preg_replace('/([A-Z+])([A-Z][a-z])/u', '$1_$2', $str) | 
                                                        
| 96 | 96 | )  | 
                                                        
@@ -106,7 +106,7 @@ discard block  | 
                                                    ||
| 106 | 106 | * @param string $str A string to convert to a slug  | 
                                                        
| 107 | 107 | * @return string  | 
                                                        
| 108 | 108 | */  | 
                                                        
| 109 | -	public static function slugify( $str ) { | 
                                                        |
| 109 | +	public static function slugify($str) { | 
                                                        |
| 110 | 110 |  		$chars = array('&' => '-and-', '€' => '-EUR-', '£' => '-GBP-', '$' => '-USD-'); | 
                                                        
| 111 | 111 |  		return trim(preg_replace('/([^a-z0-9]+)/u', '-', mb_strtolower(strtr(static::removeAccents($str), $chars))), '-'); | 
                                                        
| 112 | 112 | }  | 
                                                        
@@ -117,7 +117,7 @@ discard block  | 
                                                    ||
| 117 | 117 | * @param string $str A string that might contain accent characters  | 
                                                        
| 118 | 118 | * @return string  | 
                                                        
| 119 | 119 | */  | 
                                                        
| 120 | -	public static function removeAccents( $str ) { | 
                                                        |
| 120 | +	public static function removeAccents($str) { | 
                                                        |
| 121 | 121 | $chars = array(  | 
                                                        
| 122 | 122 | 'ª' => 'a', 'º' => 'o', 'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A',  | 
                                                        
| 123 | 123 | 'Ä' => 'A', 'Å' => 'A', 'Ā' => 'A', 'Ă' => 'A', 'Ą' => 'A', 'à' => 'a',  | 
                                                        
@@ -166,7 +166,7 @@ discard block  | 
                                                    ||
| 166 | 166 | * @param string $str  | 
                                                        
| 167 | 167 | * @return string the converted string.  | 
                                                        
| 168 | 168 | */  | 
                                                        
| 169 | -	public static function latin1( $str ) { | 
                                                        |
| 169 | +	public static function latin1($str) { | 
                                                        |
| 170 | 170 | return utf8_decode(  | 
                                                        
| 171 | 171 | mb_encode_numericentity(  | 
                                                        
| 172 | 172 | (string) $str,  | 
                                                        
@@ -182,7 +182,7 @@ discard block  | 
                                                    ||
| 182 | 182 | * @param string $str  | 
                                                        
| 183 | 183 | * @return string the converted string.  | 
                                                        
| 184 | 184 | */  | 
                                                        
| 185 | -	public static function utf8( $str ) { | 
                                                        |
| 185 | +	public static function utf8($str) { | 
                                                        |
| 186 | 186 | return html_entity_decode(  | 
                                                        
| 187 | 187 | mb_convert_encoding(  | 
                                                        
| 188 | 188 | (string) $str,  | 
                                                        
@@ -201,10 +201,10 @@ discard block  | 
                                                    ||
| 201 | 201 | * @param integer $n  | 
                                                        
| 202 | 202 | * @return string the number cast as a string with the ordinal suffixed.  | 
                                                        
| 203 | 203 | */  | 
                                                        
| 204 | -	public static function ordinal( $n ) { | 
                                                        |
| 205 | -		$ends = array('th','st','nd','rd','th','th','th','th','th','th'); | 
                                                        |
| 204 | +	public static function ordinal($n) { | 
                                                        |
| 205 | +		$ends = array('th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th'); | 
                                                        |
| 206 | 206 | // if tens digit is 1, 2 or 3 then use th instead of usual ordinal  | 
                                                        
| 207 | - if( ($n % 100) >= 11 && ($n % 100) <= 13 )  | 
                                                        |
| 207 | + if (($n % 100) >= 11 && ($n % 100) <= 13)  | 
                                                        |
| 208 | 208 |  		   return "{$n}th"; | 
                                                        
| 209 | 209 | else  | 
                                                        
| 210 | 210 |  		   return "{$n}{$ends[$n % 10]}"; | 
                                                        
@@ -218,13 +218,13 @@ discard block  | 
                                                    ||
| 218 | 218 | * @param integer $precision the number of decimal places to format the result to.  | 
                                                        
| 219 | 219 | * @return string  | 
                                                        
| 220 | 220 | */  | 
                                                        
| 221 | -	public static function sizeFormat( $bytes, $precision ) { | 
                                                        |
| 221 | +	public static function sizeFormat($bytes, $precision) { | 
                                                        |
| 222 | 222 |  		$units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB'); | 
                                                        
| 223 | 223 | $bytes = max($bytes, 0);  | 
                                                        
| 224 | 224 | $pow = floor(($bytes ? log($bytes) : 0) / log(1024));  | 
                                                        
| 225 | 225 | $pow = min($pow, count($units) - 1);  | 
                                                        
| 226 | 226 | $bytes /= (1 << (10 * $pow));  | 
                                                        
| 227 | - return round($bytes, $precision). ' '. $units[$pow];  | 
                                                        |
| 227 | + return round($bytes, $precision).' '.$units[$pow];  | 
                                                        |
| 228 | 228 | }  | 
                                                        
| 229 | 229 | |
| 230 | 230 | /**  | 
                                                        
@@ -236,13 +236,13 @@ discard block  | 
                                                    ||
| 236 | 236 | * @param string|array str  | 
                                                        
| 237 | 237 | * @return string|array  | 
                                                        
| 238 | 238 | */  | 
                                                        
| 239 | -	public static function xssClean( $str, $charset = 'UTF-8' ) { | 
                                                        |
| 239 | +	public static function xssClean($str, $charset = 'UTF-8') { | 
                                                        |
| 240 | 240 | |
| 241 | - if( !$str )  | 
                                                        |
| 241 | + if (!$str)  | 
                                                        |
| 242 | 242 | return $str;  | 
                                                        
| 243 | 243 | |
| 244 | -		if( is_array($str) ) { | 
                                                        |
| 245 | -			foreach( $str as &$item ) { | 
                                                        |
| 244 | +		if (is_array($str)) { | 
                                                        |
| 245 | +			foreach ($str as &$item) { | 
                                                        |
| 246 | 246 | $item = static::xssClean($item);  | 
                                                        
| 247 | 247 | }  | 
                                                        
| 248 | 248 | return $str;  | 
                                                        
@@ -252,7 +252,7 @@ discard block  | 
                                                    ||
| 252 | 252 | $str = static::stripControlChars($str);  | 
                                                        
| 253 | 253 | |
| 254 | 254 | // fix and decode entities (handles missing ; terminator)  | 
                                                        
| 255 | -		$str = str_replace(array('&','<','>'), array('&amp;','&lt;','&gt;'), $str); | 
                                                        |
| 255 | +		$str = str_replace(array('&', '<', '>'), array('&amp;', '&lt;', '&gt;'), $str); | 
                                                        |
| 256 | 256 |  		$str = preg_replace('/(&#*\w+)\s+;/u', '$1;', $str); | 
                                                        
| 257 | 257 |  		$str = preg_replace('/(&#x*[0-9A-F]+);*/iu', '$1;', $str); | 
                                                        
| 258 | 258 | $str = html_entity_decode($str, ENT_COMPAT, $charset);  | 
                                                        
@@ -297,10 +297,10 @@ discard block  | 
                                                    ||
| 297 | 297 | * @param string|array str  | 
                                                        
| 298 | 298 | * @return string|array  | 
                                                        
| 299 | 299 | */  | 
                                                        
| 300 | -	public static function stripControlChars( $str ) { | 
                                                        |
| 300 | +	public static function stripControlChars($str) { | 
                                                        |
| 301 | 301 | |
| 302 | -		if( is_array($str) ) { | 
                                                        |
| 303 | -			foreach( $str as &$item ) { | 
                                                        |
| 302 | +		if (is_array($str)) { | 
                                                        |
| 303 | +			foreach ($str as &$item) { | 
                                                        |
| 304 | 304 | $item = static::stripControlChars($item);  | 
                                                        
| 305 | 305 | }  | 
                                                        
| 306 | 306 | return $str;  | 
                                                        
@@ -321,7 +321,7 @@ discard block  | 
                                                    ||
| 321 | 321 | * All line-ending are converted to LF with maximum of two consecutive.  | 
                                                        
| 322 | 322 | * @return string  | 
                                                        
| 323 | 323 | */  | 
                                                        
| 324 | -	public static function normaliseLineEndings( $str ) { | 
                                                        |
| 324 | +	public static function normaliseLineEndings($str) { | 
                                                        |
| 325 | 325 |  		$str = str_replace("\r\n", "\n", $str); | 
                                                        
| 326 | 326 |  		$str = str_replace("\r", "\n", $str); | 
                                                        
| 327 | 327 |  		return preg_replace("/\n{2,}/", "\n\n", $str); | 
                                                        
@@ -32,12 +32,13 @@ discard block  | 
                                                    ||
| 32 | 32 | $parts = is_string($url) ? \parse_url(urldecode($url)) : $url;  | 
                                                        
| 33 | 33 | |
| 34 | 34 |  		$select = function( $k ) use ( $parts, $defaults ) { | 
                                                        
| 35 | - if( isset($parts[$k]) )  | 
                                                        |
| 36 | - return $parts[$k];  | 
                                                        |
| 37 | - elseif( isset($defaults[$k]) )  | 
                                                        |
| 38 | - return $defaults[$k];  | 
                                                        |
| 39 | - else  | 
                                                        |
| 40 | - return '';  | 
                                                        |
| 35 | +			if( isset($parts[$k]) ) { | 
                                                        |
| 36 | + return $parts[$k];  | 
                                                        |
| 37 | +			} elseif( isset($defaults[$k]) ) { | 
                                                        |
| 38 | + return $defaults[$k];  | 
                                                        |
| 39 | +			} else { | 
                                                        |
| 40 | + return '';  | 
                                                        |
| 41 | + }  | 
                                                        |
| 41 | 42 | };  | 
                                                        
| 42 | 43 | |
| 43 | 44 | $url = array(  | 
                                                        
@@ -50,8 +51,9 @@ discard block  | 
                                                    ||
| 50 | 51 | 'options' => array(),  | 
                                                        
| 51 | 52 | );  | 
                                                        
| 52 | 53 | |
| 53 | - if( isset($parts['query']) )  | 
                                                        |
| 54 | - parse_str($parts['query'], $url['options']);  | 
                                                        |
| 54 | +		if( isset($parts['query']) ) { | 
                                                        |
| 55 | + parse_str($parts['query'], $url['options']);  | 
                                                        |
| 56 | + }  | 
                                                        |
| 55 | 57 | |
| 56 | 58 | return $url;  | 
                                                        
| 57 | 59 | |
@@ -204,10 +206,11 @@ discard block  | 
                                                    ||
| 204 | 206 |  	public static function ordinal( $n ) { | 
                                                        
| 205 | 207 |  		$ends = array('th','st','nd','rd','th','th','th','th','th','th'); | 
                                                        
| 206 | 208 | // if tens digit is 1, 2 or 3 then use th instead of usual ordinal  | 
                                                        
| 207 | - if( ($n % 100) >= 11 && ($n % 100) <= 13 )  | 
                                                        |
| 208 | -		   return "{$n}th"; | 
                                                        |
| 209 | - else  | 
                                                        |
| 210 | -		   return "{$n}{$ends[$n % 10]}"; | 
                                                        |
| 209 | +		if( ($n % 100) >= 11 && ($n % 100) <= 13 ) { | 
                                                        |
| 210 | +				   return "{$n}th"; | 
                                                        |
| 211 | +		} else { | 
                                                        |
| 212 | +				   return "{$n}{$ends[$n % 10]}"; | 
                                                        |
| 213 | + }  | 
                                                        |
| 211 | 214 | }  | 
                                                        
| 212 | 215 | |
| 213 | 216 | /**  | 
                                                        
@@ -238,8 +241,9 @@ discard block  | 
                                                    ||
| 238 | 241 | */  | 
                                                        
| 239 | 242 |  	public static function xssClean( $str, $charset = 'UTF-8' ) { | 
                                                        
| 240 | 243 | |
| 241 | - if( !$str )  | 
                                                        |
| 242 | - return $str;  | 
                                                        |
| 244 | +		if( !$str ) { | 
                                                        |
| 245 | + return $str;  | 
                                                        |
| 246 | + }  | 
                                                        |
| 243 | 247 | |
| 244 | 248 |  		if( is_array($str) ) { | 
                                                        
| 245 | 249 |  			foreach( $str as &$item ) { | 
                                                        
@@ -18,17 +18,17 @@ discard block  | 
                                                    ||
| 18 | 18 | * @param mixed $time  | 
                                                        
| 19 | 19 | * @return integer  | 
                                                        
| 20 | 20 | */  | 
                                                        
| 21 | -	public static function makeTimestamp( $time ) { | 
                                                        |
| 21 | +	public static function makeTimestamp($time) { | 
                                                        |
| 22 | 22 | |
| 23 | - if( is_numeric($time) )  | 
                                                        |
| 23 | + if (is_numeric($time))  | 
                                                        |
| 24 | 24 | return (int) $time;  | 
                                                        
| 25 | 25 | |
| 26 | - elseif( $time instanceof \DateTime )  | 
                                                        |
| 26 | + elseif ($time instanceof \DateTime)  | 
                                                        |
| 27 | 27 | return $time->getTimestamp();  | 
                                                        
| 28 | 28 | |
| 29 | 29 | $ts = strtotime($time);  | 
                                                        
| 30 | 30 | |
| 31 | - if( $ts === false )  | 
                                                        |
| 31 | + if ($ts === false)  | 
                                                        |
| 32 | 32 |  			throw new \LogicException("Unable convert {$time} to a valid timestamp"); | 
                                                        
| 33 | 33 | |
| 34 | 34 | return $ts;  | 
                                                        
@@ -42,16 +42,16 @@ discard block  | 
                                                    ||
| 42 | 42 | * @param string $str string to convert  | 
                                                        
| 43 | 43 | * @return integer|float  | 
                                                        
| 44 | 44 | */  | 
                                                        
| 45 | -	public static function seconds( $str ) { | 
                                                        |
| 45 | +	public static function seconds($str) { | 
                                                        |
| 46 | 46 | |
| 47 | 47 | $hours = 0;  | 
                                                        
| 48 | 48 | $minutes = 0;  | 
                                                        
| 49 | 49 | $seconds = 0;  | 
                                                        
| 50 | 50 | |
| 51 | -		if( preg_match('/^\d+:\d+$/', $str) ) { | 
                                                        |
| 51 | +		if (preg_match('/^\d+:\d+$/', $str)) { | 
                                                        |
| 52 | 52 |  			list(, $minutes, $seconds) = explode(':', $str); | 
                                                        
| 53 | 53 | }  | 
                                                        
| 54 | -		elseif( preg_match('/^\d+:\d+:\d+$/', $str) ) { | 
                                                        |
| 54 | +		elseif (preg_match('/^\d+:\d+:\d+$/', $str)) { | 
                                                        |
| 55 | 55 |  			list($hours, $minutes, $seconds) = explode(':', $str); | 
                                                        
| 56 | 56 | }  | 
                                                        
| 57 | 57 |  		else { | 
                                                        
@@ -65,22 +65,22 @@ discard block  | 
                                                    ||
| 65 | 65 | // compress scales and units together so '2 hours' => '2hours'  | 
                                                        
| 66 | 66 |  			$str = preg_replace('/([0-9.]+) ([cdehimnorstu]+)/u', '$1$2', $str); | 
                                                        
| 67 | 67 | |
| 68 | -			foreach( explode(' ', $str) as $item ) { | 
                                                        |
| 68 | +			foreach (explode(' ', $str) as $item) { | 
                                                        |
| 69 | 69 | |
| 70 | -				if( !preg_match('/^([0-9.]+)([cdehimnorstu]+)$/u', $item, $m) ) | 
                                                        |
| 70 | +				if (!preg_match('/^([0-9.]+)([cdehimnorstu]+)$/u', $item, $m)) | 
                                                        |
| 71 | 71 | return false;  | 
                                                        
| 72 | 72 | |
| 73 | 73 | list(, $scale, $unit) = $m;  | 
                                                        
| 74 | 74 | |
| 75 | 75 | $scale = ((float) $scale != (int) $scale) ? (float) $scale : (int) $scale;  | 
                                                        
| 76 | 76 | |
| 77 | -				if( preg_match('/^h(r|our|ours)?$/u', $unit) && !$hours ) { | 
                                                        |
| 77 | +				if (preg_match('/^h(r|our|ours)?$/u', $unit) && !$hours) { | 
                                                        |
| 78 | 78 | $hours = $scale;  | 
                                                        
| 79 | 79 | }  | 
                                                        
| 80 | -				elseif( preg_match('/^m(in|ins|inute|inutes)?$/u', $unit) && !$minutes ) { | 
                                                        |
| 80 | +				elseif (preg_match('/^m(in|ins|inute|inutes)?$/u', $unit) && !$minutes) { | 
                                                        |
| 81 | 81 | $minutes = $scale;  | 
                                                        
| 82 | 82 | }  | 
                                                        
| 83 | -				elseif( preg_match('/^s(ec|ecs|econd|econds)?$/u', $unit) && !$seconds ) { | 
                                                        |
| 83 | +				elseif (preg_match('/^s(ec|ecs|econd|econds)?$/u', $unit) && !$seconds) { | 
                                                        |
| 84 | 84 | $seconds = $scale;  | 
                                                        
| 85 | 85 | }  | 
                                                        
| 86 | 86 |  				else { | 
                                                        
@@ -20,16 +20,17 @@ discard block  | 
                                                    ||
| 20 | 20 | */  | 
                                                        
| 21 | 21 |  	public static function makeTimestamp( $time ) { | 
                                                        
| 22 | 22 | |
| 23 | - if( is_numeric($time) )  | 
                                                        |
| 24 | - return (int) $time;  | 
                                                        |
| 25 | -  | 
                                                        |
| 26 | - elseif( $time instanceof \DateTime )  | 
                                                        |
| 27 | - return $time->getTimestamp();  | 
                                                        |
| 23 | +		if( is_numeric($time) ) { | 
                                                        |
| 24 | + return (int) $time;  | 
                                                        |
| 25 | +		} elseif( $time instanceof \DateTime ) { | 
                                                        |
| 26 | + return $time->getTimestamp();  | 
                                                        |
| 27 | + }  | 
                                                        |
| 28 | 28 | |
| 29 | 29 | $ts = strtotime($time);  | 
                                                        
| 30 | 30 | |
| 31 | - if( $ts === false )  | 
                                                        |
| 32 | -			throw new \LogicException("Unable convert {$time} to a valid timestamp"); | 
                                                        |
| 31 | +		if( $ts === false ) { | 
                                                        |
| 32 | +					throw new \LogicException("Unable convert {$time} to a valid timestamp"); | 
                                                        |
| 33 | + }  | 
                                                        |
| 33 | 34 | |
| 34 | 35 | return $ts;  | 
                                                        
| 35 | 36 | |
@@ -50,11 +51,9 @@ discard block  | 
                                                    ||
| 50 | 51 | |
| 51 | 52 |  		if( preg_match('/^\d+:\d+$/', $str) ) { | 
                                                        
| 52 | 53 |  			list(, $minutes, $seconds) = explode(':', $str); | 
                                                        
| 53 | - }  | 
                                                        |
| 54 | -		elseif( preg_match('/^\d+:\d+:\d+$/', $str) ) { | 
                                                        |
| 54 | +		} elseif( preg_match('/^\d+:\d+:\d+$/', $str) ) { | 
                                                        |
| 55 | 55 |  			list($hours, $minutes, $seconds) = explode(':', $str); | 
                                                        
| 56 | - }  | 
                                                        |
| 57 | -		else { | 
                                                        |
| 56 | +		} else { | 
                                                        |
| 58 | 57 | |
| 59 | 58 | // convert invalid characters to spaces  | 
                                                        
| 60 | 59 |  			$str = preg_replace('/[^a-z0-9. ]+/iu', ' ', $str); | 
                                                        
@@ -67,8 +66,9 @@ discard block  | 
                                                    ||
| 67 | 66 | |
| 68 | 67 |  			foreach( explode(' ', $str) as $item ) { | 
                                                        
| 69 | 68 | |
| 70 | -				if( !preg_match('/^([0-9.]+)([cdehimnorstu]+)$/u', $item, $m) ) | 
                                                        |
| 71 | - return false;  | 
                                                        |
| 69 | +				if( !preg_match('/^([0-9.]+)([cdehimnorstu]+)$/u', $item, $m) ) { | 
                                                        |
| 70 | + return false;  | 
                                                        |
| 71 | + }  | 
                                                        |
| 72 | 72 | |
| 73 | 73 | list(, $scale, $unit) = $m;  | 
                                                        
| 74 | 74 | |
@@ -76,14 +76,11 @@ discard block  | 
                                                    ||
| 76 | 76 | |
| 77 | 77 |  				if( preg_match('/^h(r|our|ours)?$/u', $unit) && !$hours ) { | 
                                                        
| 78 | 78 | $hours = $scale;  | 
                                                        
| 79 | - }  | 
                                                        |
| 80 | -				elseif( preg_match('/^m(in|ins|inute|inutes)?$/u', $unit) && !$minutes ) { | 
                                                        |
| 79 | +				} elseif( preg_match('/^m(in|ins|inute|inutes)?$/u', $unit) && !$minutes ) { | 
                                                        |
| 81 | 80 | $minutes = $scale;  | 
                                                        
| 82 | - }  | 
                                                        |
| 83 | -				elseif( preg_match('/^s(ec|ecs|econd|econds)?$/u', $unit) && !$seconds ) { | 
                                                        |
| 81 | +				} elseif( preg_match('/^s(ec|ecs|econd|econds)?$/u', $unit) && !$seconds ) { | 
                                                        |
| 84 | 82 | $seconds = $scale;  | 
                                                        
| 85 | - }  | 
                                                        |
| 86 | -				else { | 
                                                        |
| 83 | +				} else { | 
                                                        |
| 87 | 84 | return false;  | 
                                                        
| 88 | 85 | }  | 
                                                        
| 89 | 86 | |
@@ -3,22 +3,22 @@  | 
                                                    ||
| 3 | 3 | use yolk\Yolk;  | 
                                                        
| 4 | 4 | |
| 5 | 5 |  defined('YOLK_START_TIME') || define('YOLK_START_TIME', microtime(true)); | 
                                                        
| 6 | -defined('YOLK_START_MEM')  || define('YOLK_START_MEM', memory_get_usage()); | 
                                                        |
| 6 | +defined('YOLK_START_MEM') || define('YOLK_START_MEM', memory_get_usage()); | 
                                                        |
| 7 | 7 | |
| 8 | -if( !function_exists('d') ) { | 
                                                        |
| 8 | +if (!function_exists('d')) { | 
                                                        |
| 9 | 9 |  	function d() { | 
                                                        
| 10 | 10 | $args = func_get_args();  | 
                                                        
| 11 | -		if( Yolk::isDebug() ) { | 
                                                        |
| 12 | -			foreach( $args as $arg ) { | 
                                                        |
| 11 | +		if (Yolk::isDebug()) { | 
                                                        |
| 12 | +			foreach ($args as $arg) { | 
                                                        |
| 13 | 13 | Yolk::dump($arg);  | 
                                                        
| 14 | 14 | }  | 
                                                        
| 15 | 15 | }  | 
                                                        
| 16 | 16 | return array_shift($args);  | 
                                                        
| 17 | 17 | }  | 
                                                        
| 18 | 18 |  	function dd() { | 
                                                        
| 19 | -		if( Yolk::isDebug() ) { | 
                                                        |
| 19 | +		if (Yolk::isDebug()) { | 
                                                        |
| 20 | 20 |  			headers_sent() || header('Content-type: text/plain; charset=UTF-8'); | 
                                                        
| 21 | -			foreach( func_get_args() as $arg ) { | 
                                                        |
| 21 | +			foreach (func_get_args() as $arg) { | 
                                                        |
| 22 | 22 | Yolk::dump($arg);  | 
                                                        
| 23 | 23 | }  | 
                                                        
| 24 | 24 | die();  | 
                                                        
@@ -15,7 +15,7 @@ discard block  | 
                                                    ||
| 15 | 15 | |
| 16 | 16 |  	private function __construct() {} | 
                                                        
| 17 | 17 | |
| 18 | -	public static function dump( $var, $output = true ) { | 
                                                        |
| 18 | +	public static function dump($var, $output = true) { | 
                                                        |
| 19 | 19 | |
| 20 | 20 | $dumpers = [  | 
                                                        
| 21 | 21 | 'is_null' => 'dumpNull',  | 
                                                        
@@ -30,27 +30,27 @@ discard block  | 
                                                    ||
| 30 | 30 | |
| 31 | 31 | $item = false;  | 
                                                        
| 32 | 32 | |
| 33 | -		foreach( $dumpers as $test => $dumper ) { | 
                                                        |
| 34 | -			if( $test($var) ) { | 
                                                        |
| 33 | +		foreach ($dumpers as $test => $dumper) { | 
                                                        |
| 34 | +			if ($test($var)) { | 
                                                        |
| 35 | 35 | $item = static::$dumper($var);  | 
                                                        
| 36 | 36 | break;  | 
                                                        
| 37 | 37 | }  | 
                                                        
| 38 | 38 | }  | 
                                                        
| 39 | 39 | |
| 40 | -		if( !$item ) { | 
                                                        |
| 40 | +		if (!$item) { | 
                                                        |
| 41 | 41 | ob_start();  | 
                                                        
| 42 | 42 | var_dump($var);  | 
                                                        
| 43 | 43 | $item = ob_get_clean();  | 
                                                        
| 44 | 44 | }  | 
                                                        
| 45 | 45 | |
| 46 | - if( $output )  | 
                                                        |
| 46 | + if ($output)  | 
                                                        |
| 47 | 47 | static::output($item);  | 
                                                        
| 48 | 48 | |
| 49 | 49 | return $item;  | 
                                                        
| 50 | 50 | |
| 51 | 51 | }  | 
                                                        
| 52 | 52 | |
| 53 | -	protected static function output( $item ) { | 
                                                        |
| 53 | +	protected static function output($item) { | 
                                                        |
| 54 | 54 | echo $item, "\n";  | 
                                                        
| 55 | 55 | }  | 
                                                        
| 56 | 56 | |
@@ -43,8 +43,9 @@  | 
                                                    ||
| 43 | 43 | $item = ob_get_clean();  | 
                                                        
| 44 | 44 | }  | 
                                                        
| 45 | 45 | |
| 46 | - if( $output )  | 
                                                        |
| 47 | - static::output($item);  | 
                                                        |
| 46 | +		if( $output ) { | 
                                                        |
| 47 | + static::output($item);  | 
                                                        |
| 48 | + }  | 
                                                        |
| 48 | 49 | |
| 49 | 50 | return $item;  | 
                                                        
| 50 | 51 | |