@@ -13,7 +13,7 @@ |
||
13 | 13 | |
14 | 14 | public function currency($num) { |
15 | 15 | $num = $this->decimal($num, $this->locale['currency_decimals']); |
16 | - if ($this->locale['currency_position'] === 'before') return $this->locale['currency'] . $num; |
|
17 | - else return $num . $this->locale['currency']; |
|
16 | + if ($this->locale['currency_position'] === 'before') return $this->locale['currency'].$num; |
|
17 | + else return $num.$this->locale['currency']; |
|
18 | 18 | } |
19 | 19 | } |
20 | 20 | \ No newline at end of file |
@@ -13,7 +13,10 @@ |
||
13 | 13 | |
14 | 14 | public function currency($num) { |
15 | 15 | $num = $this->decimal($num, $this->locale['currency_decimals']); |
16 | - if ($this->locale['currency_position'] === 'before') return $this->locale['currency'] . $num; |
|
17 | - else return $num . $this->locale['currency']; |
|
16 | + if ($this->locale['currency_position'] === 'before') { |
|
17 | + return $this->locale['currency'] . $num; |
|
18 | + } else { |
|
19 | + return $num . $this->locale['currency']; |
|
20 | + } |
|
18 | 21 | } |
19 | 22 | } |
20 | 23 | \ No newline at end of file |
@@ -9,9 +9,13 @@ |
||
9 | 9 | class PostProcess implements \Transphporm\Hook { |
10 | 10 | public function run(\DomElement $element) { |
11 | 11 | $transphporm = $element->getAttribute('transphporm'); |
12 | - if ($transphporm === 'remove') $element->parentNode->removeChild($element); |
|
13 | - else if ($transphporm === 'text') $element->parentNode->replaceChild($element->firstChild, $element); |
|
14 | - else $element->removeAttribute('transphporm'); |
|
12 | + if ($transphporm === 'remove') { |
|
13 | + $element->parentNode->removeChild($element); |
|
14 | + } else if ($transphporm === 'text') { |
|
15 | + $element->parentNode->replaceChild($element->firstChild, $element); |
|
16 | + } else { |
|
17 | + $element->removeAttribute('transphporm'); |
|
18 | + } |
|
15 | 19 | } |
16 | 20 | |
17 | 21 | } |
18 | 22 | \ No newline at end of file |
@@ -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 | } |
@@ -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 | } |
@@ -21,6 +21,10 @@ |
||
21 | 21 | const D = 86400; |
22 | 22 | |
23 | 23 | |
24 | + /** |
|
25 | + * @param string $query |
|
26 | + * @param integer $depth |
|
27 | + */ |
|
24 | 28 | public function __construct($query, $pseudo, $depth, $index, $file, $line, array $properties = []) { |
25 | 29 | $this->query = $query; |
26 | 30 | $this->pseudo = $pseudo; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | $offset = $this->getUpdateFrequency(); |
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 | |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | $num = (int) $frequency; |
71 | 71 | $unit = strtoupper(trim(str_replace($num, '', $frequency))); |
72 | 72 | if ($frequency == 'always') return 0; |
73 | - 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 |
|
73 | + 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 |
|
74 | 74 | |
75 | - return $num * constant(self::class . '::' . $unit); |
|
75 | + return $num * constant(self::class.'::'.$unit); |
|
76 | 76 | } |
77 | 77 | } |
@@ -44,36 +44,52 @@ |
||
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(); |
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() { |
66 | 75 | $frequency = isset($this->properties['update-frequency']) ? $this->properties['update-frequency']->read() : false; |
67 | 76 | |
68 | - if (empty($frequency)) return 0; |
|
69 | - else return $this->calcUpdateFrequency($frequency); |
|
77 | + if (empty($frequency)) { |
|
78 | + return 0; |
|
79 | + } else { |
|
80 | + return $this->calcUpdateFrequency($frequency); |
|
81 | + } |
|
70 | 82 | } |
71 | 83 | |
72 | 84 | private function calcUpdateFrequency($frequency) { |
73 | 85 | $num = (int) $frequency; |
74 | 86 | $unit = strtoupper(trim(str_replace($num, '', $frequency))); |
75 | - if ($frequency == 'always') return 0; |
|
76 | - 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 |
|
87 | + if ($frequency == 'always') { |
|
88 | + return 0; |
|
89 | + } else if ($frequency == 'never') { |
|
90 | + return self::D*3650; |
|
91 | + } |
|
92 | + //Not quite never, in 10 years will cause issues on 32 bit PHP builds re 2038 problem |
|
77 | 93 | |
78 | 94 | return $num * constant(self::class . '::' . $unit); |
79 | 95 | } |
@@ -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) { |
@@ -7,7 +7,9 @@ |
||
7 | 7 | namespace Transphporm\Pseudo; |
8 | 8 | class Attribute implements \Transphporm\Pseudo { |
9 | 9 | public function match($name, $args, \DomElement $element) { |
10 | - if (!($name === null || in_array($name, ['data', 'iteration', 'root']))) return true; |
|
10 | + if (!($name === null || in_array($name, ['data', 'iteration', 'root']))) { |
|
11 | + return true; |
|
12 | + } |
|
11 | 13 | return $args[0]; |
12 | 14 | } |
13 | 15 | } |