@@ -7,8 +7,12 @@  | 
                                                    ||
| 7 | 7 | namespace Transphporm\Property;  | 
                                                        
| 8 | 8 |  class Display implements \Transphporm\Property { | 
                                                        
| 9 | 9 |  	public function run(array $values, \DomElement $element, array $rules, \Transphporm\Hook\PseudoMatcher $pseudoMatcher, array $properties = []) { | 
                                                        
| 10 | -		if ($pseudoMatcher->hasFunction('attr')) $element->removeAttribute($pseudoMatcher->getFuncArgs('attr')[0]); | 
                                                        |
| 11 | -		else if (strtolower($values[0]) === 'none') $element->setAttribute('transphporm', 'remove'); | 
                                                        |
| 12 | -		else $element->setAttribute('transphporm', 'show'); | 
                                                        |
| 10 | +		if ($pseudoMatcher->hasFunction('attr')) { | 
                                                        |
| 11 | +			$element->removeAttribute($pseudoMatcher->getFuncArgs('attr')[0]); | 
                                                        |
| 12 | +		} else if (strtolower($values[0]) === 'none') { | 
                                                        |
| 13 | +			$element->setAttribute('transphporm', 'remove'); | 
                                                        |
| 14 | +		} else { | 
                                                        |
| 15 | +			$element->setAttribute('transphporm', 'show'); | 
                                                        |
| 16 | + }  | 
                                                        |
| 13 | 17 | }  | 
                                                        
| 14 | 18 | }  | 
                                                        
@@ -102,14 +102,14 @@  | 
                                                    ||
| 102 | 102 | }  | 
                                                        
| 103 | 103 | |
| 104 | 104 |  	private function getProperties($tokens) { | 
                                                        
| 105 | - $rules = $tokens->splitOnToken(Tokenizer::SEMI_COLON);  | 
                                                        |
| 105 | + $rules = $tokens->splitOnToken(Tokenizer::SEMI_COLON);  | 
                                                        |
| 106 | 106 | |
| 107 | - $return = [];  | 
                                                        |
| 108 | -        foreach ($rules as $rule) { | 
                                                        |
| 109 | - $name = $rule->from(Tokenizer::NAME, true)->to(Tokenizer::COLON)->read();  | 
                                                        |
| 110 | - $return[$name] = $rule->from(Tokenizer::COLON)->trim();  | 
                                                        |
| 111 | - }  | 
                                                        |
| 107 | + $return = [];  | 
                                                        |
| 108 | +		foreach ($rules as $rule) { | 
                                                        |
| 109 | + $name = $rule->from(Tokenizer::NAME, true)->to(Tokenizer::COLON)->read();  | 
                                                        |
| 110 | + $return[$name] = $rule->from(Tokenizer::COLON)->trim();  | 
                                                        |
| 111 | + }  | 
                                                        |
| 112 | 112 | |
| 113 | - return $return;  | 
                                                        |
| 114 | - }  | 
                                                        |
| 113 | + return $return;  | 
                                                        |
| 114 | + }  | 
                                                        |
| 115 | 115 | }  | 
                                                        
@@ -30,6 +30,9 @@ discard block  | 
                                                    ||
| 30 | 30 | return $rules;  | 
                                                        
| 31 | 31 | }  | 
                                                        
| 32 | 32 | |
| 33 | + /**  | 
                                                        |
| 34 | + * @param integer $indexStart  | 
                                                        |
| 35 | + */  | 
                                                        |
| 33 | 36 |  	private function parseTokens($indexStart) { | 
                                                        
| 34 | 37 | $this->rules = [];  | 
                                                        
| 35 | 38 |  		foreach (new TokenFilterIterator($this->tss, [Tokenizer::WHITESPACE]) as $token) { | 
                                                        
@@ -55,6 +58,10 @@ discard block  | 
                                                    ||
| 55 | 58 |  		if (empty($rules) && count($this->tss) > 0) throw new \Exception('No TSS rules parsed'); | 
                                                        
| 56 | 59 | }  | 
                                                        
| 57 | 60 | |
| 61 | + /**  | 
                                                        |
| 62 | + * @param Tokens $selector  | 
                                                        |
| 63 | + * @param integer $index  | 
                                                        |
| 64 | + */  | 
                                                        |
| 58 | 65 |  	private function CssToRules($selector, $index, $properties, $line) { | 
                                                        
| 59 | 66 | $parts = $selector->trim()->splitOnToken(Tokenizer::ARG);  | 
                                                        
| 60 | 67 | $rules = [];  | 
                                                        
@@ -78,6 +85,9 @@ discard block  | 
                                                    ||
| 78 | 85 | return $rules;  | 
                                                        
| 79 | 86 | }  | 
                                                        
| 80 | 87 | |
| 88 | + /**  | 
                                                        |
| 89 | + * @param integer $indexStart  | 
                                                        |
| 90 | + */  | 
                                                        |
| 81 | 91 |  	private function processingInstructions($token, $indexStart) { | 
                                                        
| 82 | 92 | if ($token['type'] !== Tokenizer::AT_SIGN) return false;  | 
                                                        
| 83 | 93 | $tokens = $this->tss->from(Tokenizer::AT_SIGN, false)->to(Tokenizer::SEMI_COLON, false);  | 
                                                        
@@ -24,7 +24,9 @@ discard block  | 
                                                    ||
| 24 | 24 | }  | 
                                                        
| 25 | 25 | |
| 26 | 26 |  	public function parse($indexStart = 0) { | 
                                                        
| 27 | - if (!empty($this->rules)) return $this->rules['rules'];  | 
                                                        |
| 27 | +		if (!empty($this->rules)) { | 
                                                        |
| 28 | + return $this->rules['rules'];  | 
                                                        |
| 29 | + }  | 
                                                        |
| 28 | 30 | $rules = $this->parseTokens($indexStart);  | 
                                                        
| 29 | 31 | $this->checkError($rules);  | 
                                                        
| 30 | 32 | return $rules;  | 
                                                        
@@ -35,8 +37,9 @@ discard block  | 
                                                    ||
| 35 | 37 |  		foreach (new TokenFilterIterator($this->tss, [Tokenizer::WHITESPACE]) as $token) { | 
                                                        
| 36 | 38 |  			if ($processing = $this->processingInstructions($token, count($this->rules)+$indexStart)) { | 
                                                        
| 37 | 39 | $this->rules = array_merge($this->rules, $processing);  | 
                                                        
| 40 | +			} else if (!in_array($token['type'], [Tokenizer::NEW_LINE, Tokenizer::AT_SIGN])) { | 
                                                        |
| 41 | + $this->addRules($token, $indexStart++);  | 
                                                        |
| 38 | 42 | }  | 
                                                        
| 39 | - else if (!in_array($token['type'], [Tokenizer::NEW_LINE, Tokenizer::AT_SIGN])) $this->addRules($token, $indexStart++);  | 
                                                        |
| 40 | 43 | }  | 
                                                        
| 41 | 44 | |
| 42 | 45 | return $this->rules;  | 
                                                        
@@ -46,13 +49,17 @@ discard block  | 
                                                    ||
| 46 | 49 | $selector = $this->tss->from($token['type'], true)->to(Tokenizer::OPEN_BRACE);  | 
                                                        
| 47 | 50 | |
| 48 | 51 | $this->tss->skip(count($selector));  | 
                                                        
| 49 | - if (count($selector) === 0) return;  | 
                                                        |
| 52 | +		if (count($selector) === 0) { | 
                                                        |
| 53 | + return;  | 
                                                        |
| 54 | + }  | 
                                                        |
| 50 | 55 | $newRules = $this->cssToRules($selector, count($this->rules)+$indexStart, $this->getProperties($this->tss->current()['value']), $token['line']);  | 
                                                        
| 51 | 56 | $this->rules = $this->writeRule($this->rules, $newRules);  | 
                                                        
| 52 | 57 | }  | 
                                                        
| 53 | 58 | |
| 54 | 59 |  	private function checkError($rules) { | 
                                                        
| 55 | -		if (empty($rules) && count($this->tss) > 0) throw new \Exception('No TSS rules parsed'); | 
                                                        |
| 60 | +		if (empty($rules) && count($this->tss) > 0) { | 
                                                        |
| 61 | +			throw new \Exception('No TSS rules parsed'); | 
                                                        |
| 62 | + }  | 
                                                        |
| 56 | 63 | }  | 
                                                        
| 57 | 64 | |
| 58 | 65 |  	private function CssToRules($selector, $index, $properties, $line) { | 
                                                        
@@ -79,7 +86,9 @@ discard block  | 
                                                    ||
| 79 | 86 | }  | 
                                                        
| 80 | 87 | |
| 81 | 88 |  	private function processingInstructions($token, $indexStart) { | 
                                                        
| 82 | - if ($token['type'] !== Tokenizer::AT_SIGN) return false;  | 
                                                        |
| 89 | +		if ($token['type'] !== Tokenizer::AT_SIGN) { | 
                                                        |
| 90 | + return false;  | 
                                                        |
| 91 | + }  | 
                                                        |
| 83 | 92 | $tokens = $this->tss->from(Tokenizer::AT_SIGN, false)->to(Tokenizer::SEMI_COLON, false);  | 
                                                        
| 84 | 93 | $funcName = $tokens->from(Tokenizer::NAME, true)->read();  | 
                                                        
| 85 | 94 | $funcToks = $tokens->from(Tokenizer::NAME);  | 
                                                        
@@ -35,7 +35,9 @@  | 
                                                    ||
| 35 | 35 | |
| 36 | 36 |      public function rewind() { | 
                                                        
| 37 | 37 | $this->tokens->rewind();  | 
                                                        
| 38 | - while ($this->shouldContinue()) $this->tokens->next();  | 
                                                        |
| 38 | +        while ($this->shouldContinue()) { | 
                                                        |
| 39 | + $this->tokens->next();  | 
                                                        |
| 40 | + }  | 
                                                        |
| 39 | 41 | }  | 
                                                        
| 40 | 42 | |
| 41 | 43 |      private function shouldContinue() { | 
                                                        
@@ -6,39 +6,39 @@  | 
                                                    ||
| 6 | 6 | * @version 1.2 */  | 
                                                        
| 7 | 7 | namespace Transphporm\Parser;  | 
                                                        
| 8 | 8 |  class TokenFilterIterator implements \Iterator { | 
                                                        
| 9 | - private $ignore;  | 
                                                        |
| 10 | - private $tokens;  | 
                                                        |
| 9 | + private $ignore;  | 
                                                        |
| 10 | + private $tokens;  | 
                                                        |
| 11 | 11 | |
| 12 | -    public function __construct(Tokens $tokens, array $ignore) { | 
                                                        |
| 13 | - $this->ignore = $ignore;  | 
                                                        |
| 14 | - $this->tokens = $tokens;  | 
                                                        |
| 15 | - }  | 
                                                        |
| 12 | +	public function __construct(Tokens $tokens, array $ignore) { | 
                                                        |
| 13 | + $this->ignore = $ignore;  | 
                                                        |
| 14 | + $this->tokens = $tokens;  | 
                                                        |
| 15 | + }  | 
                                                        |
| 16 | 16 | |
| 17 | -    public function current() { | 
                                                        |
| 18 | - return $this->tokens->current();  | 
                                                        |
| 19 | - }  | 
                                                        |
| 17 | +	public function current() { | 
                                                        |
| 18 | + return $this->tokens->current();  | 
                                                        |
| 19 | + }  | 
                                                        |
| 20 | 20 | |
| 21 | -    public function key() { | 
                                                        |
| 22 | - return $this->tokens->key();  | 
                                                        |
| 23 | - }  | 
                                                        |
| 21 | +	public function key() { | 
                                                        |
| 22 | + return $this->tokens->key();  | 
                                                        |
| 23 | + }  | 
                                                        |
| 24 | 24 | |
| 25 | -    public function valid() { | 
                                                        |
| 26 | - return $this->tokens->valid();  | 
                                                        |
| 27 | - }  | 
                                                        |
| 25 | +	public function valid() { | 
                                                        |
| 26 | + return $this->tokens->valid();  | 
                                                        |
| 27 | + }  | 
                                                        |
| 28 | 28 | |
| 29 | -    public function next() { | 
                                                        |
| 30 | -        do { | 
                                                        |
| 31 | - $this->tokens->next();  | 
                                                        |
| 32 | - }  | 
                                                        |
| 33 | - while ($this->shouldContinue());  | 
                                                        |
| 34 | - }  | 
                                                        |
| 29 | +	public function next() { | 
                                                        |
| 30 | +		do { | 
                                                        |
| 31 | + $this->tokens->next();  | 
                                                        |
| 32 | + }  | 
                                                        |
| 33 | + while ($this->shouldContinue());  | 
                                                        |
| 34 | + }  | 
                                                        |
| 35 | 35 | |
| 36 | -    public function rewind() { | 
                                                        |
| 37 | - $this->tokens->rewind();  | 
                                                        |
| 38 | - while ($this->shouldContinue()) $this->tokens->next();  | 
                                                        |
| 39 | - }  | 
                                                        |
| 36 | +	public function rewind() { | 
                                                        |
| 37 | + $this->tokens->rewind();  | 
                                                        |
| 38 | + while ($this->shouldContinue()) $this->tokens->next();  | 
                                                        |
| 39 | + }  | 
                                                        |
| 40 | 40 | |
| 41 | -    private function shouldContinue() { | 
                                                        |
| 42 | - return $this->tokens->valid() && in_array($this->tokens->current()['type'], $this->ignore);  | 
                                                        |
| 43 | - }  | 
                                                        |
| 41 | +	private function shouldContinue() { | 
                                                        |
| 42 | + return $this->tokens->valid() && in_array($this->tokens->current()['type'], $this->ignore);  | 
                                                        |
| 43 | + }  | 
                                                        |
| 44 | 44 | }  | 
                                                        
@@ -7,7 +7,7 @@  | 
                                                    ||
| 7 | 7 | const FORMATTER = 'formatter';  | 
                                                        
| 8 | 8 | |
| 9 | 9 |      public function __construct(RunException $runException, $file, $line) { | 
                                                        
| 10 | - $message = $runException->getMessage() . ' on Line ' . $line . ' of ' . ($file === null ? 'tss' : $file);  | 
                                                        |
| 10 | + $message = $runException->getMessage().' on Line '.$line.' of '.($file === null ? 'tss' : $file);  | 
                                                        |
| 11 | 11 | |
| 12 | 12 | parent::__construct($message, 0, $runException->getPrevious());  | 
                                                        
| 13 | 13 | }  | 
                                                        
@@ -6,14 +6,14 @@  | 
                                                    ||
| 6 | 6 | * @version 1.2 */  | 
                                                        
| 7 | 7 | namespace Transphporm;  | 
                                                        
| 8 | 8 |  class Exception extends \Exception { | 
                                                        
| 9 | - const PROPERTY = 'property';  | 
                                                        |
| 10 | - const TSS_FUNCTION = 'function';  | 
                                                        |
| 11 | - const PSEUDO = 'pseudo';  | 
                                                        |
| 12 | - const FORMATTER = 'formatter';  | 
                                                        |
| 9 | + const PROPERTY = 'property';  | 
                                                        |
| 10 | + const TSS_FUNCTION = 'function';  | 
                                                        |
| 11 | + const PSEUDO = 'pseudo';  | 
                                                        |
| 12 | + const FORMATTER = 'formatter';  | 
                                                        |
| 13 | 13 | |
| 14 | -    public function __construct(RunException $runException, $file, $line) { | 
                                                        |
| 15 | - $message = $runException->getMessage() . ' on Line ' . $line . ' of ' . ($file === null ? 'tss' : $file);  | 
                                                        |
| 14 | +	public function __construct(RunException $runException, $file, $line) { | 
                                                        |
| 15 | + $message = $runException->getMessage() . ' on Line ' . $line . ' of ' . ($file === null ? 'tss' : $file);  | 
                                                        |
| 16 | 16 | |
| 17 | - parent::__construct($message, 0, $runException->getPrevious());  | 
                                                        |
| 18 | - }  | 
                                                        |
| 17 | + parent::__construct($message, 0, $runException->getPrevious());  | 
                                                        |
| 18 | + }  | 
                                                        |
| 19 | 19 | }  | 
                                                        
@@ -7,6 +7,9 @@  | 
                                                    ||
| 7 | 7 | $this->templateFunction = $templateFunction;  | 
                                                        
| 8 | 8 | }  | 
                                                        
| 9 | 9 | |
| 10 | + /**  | 
                                                        |
| 11 | + * @param string $val  | 
                                                        |
| 12 | + */  | 
                                                        |
| 10 | 13 |      public function html($val) { | 
                                                        
| 11 | 14 | return $this->templateFunction->run(['<template>' . $val . '</template>']);  | 
                                                        
| 12 | 15 | }  | 
                                                        
@@ -8,12 +8,12 @@  | 
                                                    ||
| 8 | 8 | }  | 
                                                        
| 9 | 9 | |
| 10 | 10 |      public function html($val) { | 
                                                        
| 11 | - return $this->templateFunction->run(['<template>' . $val . '</template>']);  | 
                                                        |
| 11 | + return $this->templateFunction->run(['<template>'.$val.'</template>']);  | 
                                                        |
| 12 | 12 | }  | 
                                                        
| 13 | 13 | |
| 14 | 14 |  	public function debug($val) { | 
                                                        
| 15 | 15 | ob_start();  | 
                                                        
| 16 | 16 | var_dump($val);  | 
                                                        
| 17 | -		return $this->html('<pre>' . ob_get_clean() . '</pre>'); | 
                                                        |
| 17 | +		return $this->html('<pre>'.ob_get_clean().'</pre>'); | 
                                                        |
| 18 | 18 | }  | 
                                                        
| 19 | 19 | }  | 
                                                        
@@ -6,13 +6,13 @@  | 
                                                    ||
| 6 | 6 | * @version 1.2 */  | 
                                                        
| 7 | 7 | namespace Transphporm\Formatter;  | 
                                                        
| 8 | 8 |  class HTMLFormatter { | 
                                                        
| 9 | - private $templateFunction;  | 
                                                        |
| 9 | + private $templateFunction;  | 
                                                        |
| 10 | 10 | |
| 11 | -    public function __construct(\Transphporm\TSSFunction\Template $templateFunction) { | 
                                                        |
| 12 | - $this->templateFunction = $templateFunction;  | 
                                                        |
| 13 | - }  | 
                                                        |
| 11 | +	public function __construct(\Transphporm\TSSFunction\Template $templateFunction) { | 
                                                        |
| 12 | + $this->templateFunction = $templateFunction;  | 
                                                        |
| 13 | + }  | 
                                                        |
| 14 | 14 | |
| 15 | -    public function html($val) { | 
                                                        |
| 15 | +	public function html($val) { | 
                                                        |
| 16 | 16 | return $this->templateFunction->run(['<template>' . $val . '</template>']);  | 
                                                        
| 17 | 17 | }  | 
                                                        
| 18 | 18 | |
@@ -10,7 +10,7 @@ discard block  | 
                                                    ||
| 10 | 10 | private $pseudo;  | 
                                                        
| 11 | 11 | private $depth;  | 
                                                        
| 12 | 12 | private $index;  | 
                                                        
| 13 | - private $file;  | 
                                                        |
| 13 | + private $file;  | 
                                                        |
| 14 | 14 | private $line;  | 
                                                        
| 15 | 15 | private $properties = [];  | 
                                                        
| 16 | 16 | private $lastRun = 0;  | 
                                                        
@@ -26,7 +26,7 @@ discard block  | 
                                                    ||
| 26 | 26 | $this->pseudo = $pseudo;  | 
                                                        
| 27 | 27 | $this->depth = $depth;  | 
                                                        
| 28 | 28 | $this->index = $index;  | 
                                                        
| 29 | - $this->file = $file;  | 
                                                        |
| 29 | + $this->file = $file;  | 
                                                        |
| 30 | 30 | $this->line = $line;  | 
                                                        
| 31 | 31 | $this->properties = $properties;  | 
                                                        
| 32 | 32 | }  | 
                                                        
@@ -48,7 +48,7 @@ discard block  | 
                                                    ||
| 48 | 48 | |
| 49 | 49 | $offset = $this->getUpdateFrequency($frequency);  | 
                                                        
| 50 | 50 | |
| 51 | - if ($time > $this->lastRun + $offset) return true;  | 
                                                        |
| 51 | + if ($time > $this->lastRun+$offset) return true;  | 
                                                        |
| 52 | 52 | else return false;  | 
                                                        
| 53 | 53 | }  | 
                                                        
| 54 | 54 | |
@@ -75,8 +75,8 @@ discard block  | 
                                                    ||
| 75 | 75 | $num = (int) $frequency;  | 
                                                        
| 76 | 76 | $unit = strtoupper(trim(str_replace($num, '', $frequency)));  | 
                                                        
| 77 | 77 | if ($frequency == 'always') return 0;  | 
                                                        
| 78 | - else if ($frequency == 'never') return self::D*3650; //Not quite never, in 10 years will cause issues on 32 bit PHP builds re 2038 problem  | 
                                                        |
| 78 | + else if ($frequency == 'never') return self::D * 3650; //Not quite never, in 10 years will cause issues on 32 bit PHP builds re 2038 problem  | 
                                                        |
| 79 | 79 | |
| 80 | - return $num * constant(self::class . '::' . $unit);  | 
                                                        |
| 80 | + return $num * constant(self::class.'::'.$unit);  | 
                                                        |
| 81 | 81 | }  | 
                                                        
| 82 | 82 | }  | 
                                                        
@@ -44,22 +44,31 @@ discard block  | 
                                                    ||
| 44 | 44 | }  | 
                                                        
| 45 | 45 | |
| 46 | 46 |  	private function timeFrequency($frequency, $time = null) { | 
                                                        
| 47 | - if ($time === null) $time = time();  | 
                                                        |
| 47 | +		if ($time === null) { | 
                                                        |
| 48 | + $time = time();  | 
                                                        |
| 49 | + }  | 
                                                        |
| 48 | 50 | |
| 49 | 51 | $offset = $this->getUpdateFrequency($frequency);  | 
                                                        
| 50 | 52 | |
| 51 | - if ($time > $this->lastRun + $offset) return true;  | 
                                                        |
| 52 | - else return false;  | 
                                                        |
| 53 | +		if ($time > $this->lastRun + $offset) { | 
                                                        |
| 54 | + return true;  | 
                                                        |
| 55 | +		} else { | 
                                                        |
| 56 | + return false;  | 
                                                        |
| 57 | + }  | 
                                                        |
| 53 | 58 | }  | 
                                                        
| 54 | 59 | |
| 55 | 60 |  	public function shouldRun($time = null) { | 
                                                        
| 56 | 61 |  		if (isset($this->properties['update-frequency']) && $this->lastRun !== 0) { | 
                                                        
| 57 | 62 | $frequency = $this->properties['update-frequency']->read();  | 
                                                        
| 58 | 63 | $static = ['always' => true, 'never' => false];  | 
                                                        
| 59 | - if (isset($static[$frequency])) return $static[$frequency];  | 
                                                        |
| 60 | - else return $this->timeFrequency($frequency, $time);  | 
                                                        |
| 64 | +			if (isset($static[$frequency])) { | 
                                                        |
| 65 | + return $static[$frequency];  | 
                                                        |
| 66 | +			} else { | 
                                                        |
| 67 | + return $this->timeFrequency($frequency, $time);  | 
                                                        |
| 68 | + }  | 
                                                        |
| 69 | +		} else { | 
                                                        |
| 70 | + return true;  | 
                                                        |
| 61 | 71 | }  | 
                                                        
| 62 | - else return true;  | 
                                                        |
| 63 | 72 | }  | 
                                                        
| 64 | 73 | |
| 65 | 74 |  	public function getUpdateFrequency($frequency = null) { | 
                                                        
@@ -67,15 +76,22 @@ discard block  | 
                                                    ||
| 67 | 76 | $frequency = isset($this->properties['update-frequency']) ? $this->properties['update-frequency']->read() : false;  | 
                                                        
| 68 | 77 | }  | 
                                                        
| 69 | 78 | |
| 70 | - if (empty($frequency)) return 0;  | 
                                                        |
| 71 | - else return $this->calcUpdateFrequency($frequency);  | 
                                                        |
| 79 | +		if (empty($frequency)) { | 
                                                        |
| 80 | + return 0;  | 
                                                        |
| 81 | +		} else { | 
                                                        |
| 82 | + return $this->calcUpdateFrequency($frequency);  | 
                                                        |
| 83 | + }  | 
                                                        |
| 72 | 84 | }  | 
                                                        
| 73 | 85 | |
| 74 | 86 |  	private function calcUpdateFrequency($frequency) { | 
                                                        
| 75 | 87 | $num = (int) $frequency;  | 
                                                        
| 76 | 88 | $unit = strtoupper(trim(str_replace($num, '', $frequency)));  | 
                                                        
| 77 | - if ($frequency == 'always') return 0;  | 
                                                        |
| 78 | - else if ($frequency == 'never') return self::D*3650; //Not quite never, in 10 years will cause issues on 32 bit PHP builds re 2038 problem  | 
                                                        |
| 89 | +		if ($frequency == 'always') { | 
                                                        |
| 90 | + return 0;  | 
                                                        |
| 91 | +		} else if ($frequency == 'never') { | 
                                                        |
| 92 | + return self::D*3650;  | 
                                                        |
| 93 | + }  | 
                                                        |
| 94 | + //Not quite never, in 10 years will cause issues on 32 bit PHP builds re 2038 problem  | 
                                                        |
| 79 | 95 | |
| 80 | 96 | return $num * constant(self::class . '::' . $unit);  | 
                                                        
| 81 | 97 | }  | 
                                                        
@@ -15,8 +15,8 @@  | 
                                                    ||
| 15 | 15 | |
| 16 | 16 |  	private function getLocale() { | 
                                                        
| 17 | 17 | if (is_array($this->locale)) return $this->locale;  | 
                                                        
| 18 | - else if (strlen($this->locale) > 0) return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '../Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . $this->locale . '.json'), true);  | 
                                                        |
| 19 | - else return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '../Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . 'enGB.json'), true);  | 
                                                        |
| 18 | + else if (strlen($this->locale) > 0) return json_decode(file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'../Formatter'.DIRECTORY_SEPARATOR.'Locale'.DIRECTORY_SEPARATOR.$this->locale.'.json'), true);  | 
                                                        |
| 19 | + else return json_decode(file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'../Formatter'.DIRECTORY_SEPARATOR.'Locale'.DIRECTORY_SEPARATOR.'enGB.json'), true);  | 
                                                        |
| 20 | 20 | }  | 
                                                        
| 21 | 21 | |
| 22 | 22 |  	public function load(\Transphporm\Config $config) { | 
                                                        
@@ -14,9 +14,13 @@  | 
                                                    ||
| 14 | 14 | }  | 
                                                        
| 15 | 15 | |
| 16 | 16 |  	private function getLocale() { | 
                                                        
| 17 | - if (is_array($this->locale)) return $this->locale;  | 
                                                        |
| 18 | - else if (strlen($this->locale) > 0) return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '../Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . $this->locale . '.json'), true);  | 
                                                        |
| 19 | - else return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '../Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . 'enGB.json'), true);  | 
                                                        |
| 17 | +		if (is_array($this->locale)) { | 
                                                        |
| 18 | + return $this->locale;  | 
                                                        |
| 19 | +		} else if (strlen($this->locale) > 0) { | 
                                                        |
| 20 | + return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '../Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . $this->locale . '.json'), true);  | 
                                                        |
| 21 | +		} else { | 
                                                        |
| 22 | + return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '../Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . 'enGB.json'), true);  | 
                                                        |
| 23 | + }  | 
                                                        |
| 20 | 24 | }  | 
                                                        
| 21 | 25 | |
| 22 | 26 |  	public function load(\Transphporm\Config $config) { | 
                                                        
@@ -21,7 +21,8 @@  | 
                                                    ||
| 21 | 21 | $key = md5($key);  | 
                                                        
| 22 | 22 |  		if (isset($this->cache[$key]) && $this->cache[$key]['timestamp'] >= $modified) { | 
                                                        
| 23 | 23 | return $this->cache[$key]['content'];  | 
                                                        
| 24 | +		} else { | 
                                                        |
| 25 | + return false;  | 
                                                        |
| 24 | 26 | }  | 
                                                        
| 25 | - else return false;  | 
                                                        |
| 26 | 27 | }  | 
                                                        
| 27 | 28 | }  | 
                                                        
| 28 | 29 | \ No newline at end of file  | 
                                                        
@@ -14,7 +14,9 @@ discard block  | 
                                                    ||
| 14 | 14 | }  | 
                                                        
| 15 | 15 | |
| 16 | 16 |  	public function format($value, $rules) { | 
                                                        
| 17 | - if (!isset($rules['format'])) return $value;  | 
                                                        |
| 17 | +		if (!isset($rules['format'])) { | 
                                                        |
| 18 | + return $value;  | 
                                                        |
| 19 | + }  | 
                                                        |
| 18 | 20 | $tokens = $rules['format'];  | 
                                                        
| 19 | 21 | |
| 20 | 22 | $functionName = $tokens->from(\Transphporm\Parser\Tokenizer::NAME, true)->read();  | 
                                                        
@@ -27,15 +29,16 @@ discard block  | 
                                                    ||
| 27 | 29 | |
| 28 | 30 |  		try { | 
                                                        
| 29 | 31 | return $this->processFormat($options, $functionName, $value);  | 
                                                        
| 30 | - }  | 
                                                        |
| 31 | -		catch (\Exception $e) { | 
                                                        |
| 32 | +		} catch (\Exception $e) { | 
                                                        |
| 32 | 33 | throw new \Transphporm\RunException(\Transphporm\Exception::FORMATTER, $functionName, $e);  | 
                                                        
| 33 | 34 | }  | 
                                                        
| 34 | 35 | }  | 
                                                        
| 35 | 36 | |
| 36 | 37 | //TODO: Abstract all error reporting externally with a method for turning it on/off  | 
                                                        
| 37 | 38 |  	private function assert($condition, $error) { | 
                                                        
| 38 | - if (!$condition) throw new \Exception($error);  | 
                                                        |
| 39 | +		if (!$condition) { | 
                                                        |
| 40 | + throw new \Exception($error);  | 
                                                        |
| 41 | + }  | 
                                                        |
| 39 | 42 | }  | 
                                                        
| 40 | 43 | |
| 41 | 44 |  	private function processFormat($format, $functionName, $value) { |