@@ -44,8 +44,11 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | $diffDays = $diff->invert === 1 ? $diff->days : 0- $diff->days; |
| 46 | 46 | |
| 47 | - if ($diffDays !== 0) return $this->dayOffset($diffDays); |
|
| 48 | - else return $this->timeOffset($diff); |
|
| 47 | + if ($diffDays !== 0) { |
|
| 48 | + return $this->dayOffset($diffDays); |
|
| 49 | + } else { |
|
| 50 | + return $this->timeOffset($diff); |
|
| 51 | + } |
|
| 49 | 52 | } |
| 50 | 53 | |
| 51 | 54 | /** Calculates offset in hours/minutes/seconds */ |
@@ -80,15 +83,22 @@ discard block |
||
| 80 | 83 | [-365, -28, $strings['future'], 28, 'months'], |
| 81 | 84 | [-999999, -365, $strings['future'], 365, 'years'], |
| 82 | 85 | ]; |
| 83 | - if (isset($strings['day_before_yesterday'])) array_unshift($ranges, [2, 2, $strings['day_before_yesterday'], 1, '']); |
|
| 84 | - if (isset($strings['day_after_tomorrow'])) array_unshift($ranges, [-2, -2, $strings['day_after_tomorrow'], 1, '']); |
|
| 86 | + if (isset($strings['day_before_yesterday'])) { |
|
| 87 | + array_unshift($ranges, [2, 2, $strings['day_before_yesterday'], 1, '']); |
|
| 88 | + } |
|
| 89 | + if (isset($strings['day_after_tomorrow'])) { |
|
| 90 | + array_unshift($ranges, [-2, -2, $strings['day_after_tomorrow'], 1, '']); |
|
| 91 | + } |
|
| 85 | 92 | return $ranges; |
| 86 | 93 | } |
| 87 | 94 | |
| 88 | 95 | /** Converts "week" to "weeks", "month" to "months" etc when plural is required using language from $locale */ |
| 89 | 96 | private function getPlural($strings, $num, $interval) { |
| 90 | - if ($interval !== '') return $num == 1 ? $strings[$interval . '_singular'] : $strings[$interval . '_plural']; |
|
| 91 | - else return ''; |
|
| 97 | + if ($interval !== '') { |
|
| 98 | + return $num == 1 ? $strings[$interval . '_singular'] : $strings[$interval . '_plural']; |
|
| 99 | + } else { |
|
| 100 | + return ''; |
|
| 101 | + } |
|
| 92 | 102 | } |
| 93 | 103 | |
| 94 | 104 | /** Calculates offset in days/weeks/month/years */ |
@@ -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 |
@@ -31,7 +31,9 @@ |
||
| 31 | 31 | /** Returns the data that has been bound to $element, or, if no data is bound to $element climb the DOM tree to find the data bound to a parent node*/ |
| 32 | 32 | public function getData(\DomElement $element = null, $type = 'data') { |
| 33 | 33 | while ($element) { |
| 34 | - if (isset($this->elementMap[$element]) && isset($this->elementMap[$element][$type])) return $this->elementMap[$element][$type]; |
|
| 34 | + if (isset($this->elementMap[$element]) && isset($this->elementMap[$element][$type])) { |
|
| 35 | + return $this->elementMap[$element][$type]; |
|
| 36 | + } |
|
| 35 | 37 | $element = $element->parentNode; |
| 36 | 38 | } |
| 37 | 39 | return $this->data; |
@@ -16,7 +16,9 @@ discard block |
||
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | public function match($name, $args, \DomElement $element) { |
| 19 | - if ($name !== 'not') return true; |
|
| 19 | + if ($name !== 'not') { |
|
| 20 | + return true; |
|
| 21 | + } |
|
| 20 | 22 | |
| 21 | 23 | $xpath = new \DomXpath($element->ownerDocument); |
| 22 | 24 | return $this->notElement($args, $xpath, $element); |
@@ -29,7 +31,9 @@ discard block |
||
| 29 | 31 | //Find all nodes matched by the expressions in the brackets :not(EXPR) |
| 30 | 32 | foreach ($xpath->query($xpathString) as $matchedElement) { |
| 31 | 33 | //Check to see whether this node was matched by the not query |
| 32 | - if ($element->isSameNode($matchedElement)) return false; |
|
| 34 | + if ($element->isSameNode($matchedElement)) { |
|
| 35 | + return false; |
|
| 36 | + } |
|
| 33 | 37 | } |
| 34 | 38 | } |
| 35 | 39 | return true; |
@@ -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 | } |
@@ -69,7 +69,9 @@ discard block |
||
| 69 | 69 | $selector->type = $token['type']; |
| 70 | 70 | $selectors[] = $selector; |
| 71 | 71 | } |
| 72 | - if (isset($token['value'])) $selectors[count($selectors)-1]->string = $token['value']; |
|
| 72 | + if (isset($token['value'])) { |
|
| 73 | + $selectors[count($selectors)-1]->string = $token['value']; |
|
| 74 | + } |
|
| 73 | 75 | } |
| 74 | 76 | return $selectors; |
| 75 | 77 | } |
@@ -79,7 +81,9 @@ discard block |
||
| 79 | 81 | $selectors = $this->split($css); |
| 80 | 82 | $xpath = '/'; |
| 81 | 83 | foreach ($selectors as $selector) { |
| 82 | - if (isset($this->translators[$selector->type])) $xpath .= $this->translators[$selector->type]($selector->string, $xpath); |
|
| 84 | + if (isset($this->translators[$selector->type])) { |
|
| 85 | + $xpath .= $this->translators[$selector->type]($selector->string, $xpath); |
|
| 86 | + } |
|
| 83 | 87 | } |
| 84 | 88 | |
| 85 | 89 | $xpath = str_replace('/[', '/*[', $xpath); |
@@ -90,7 +94,9 @@ discard block |
||
| 90 | 94 | private function removeSpacesFromDirectDecend($css) { |
| 91 | 95 | $tokens = []; |
| 92 | 96 | foreach ($css->splitOnToken(Tokenizer::GREATER_THAN) as $token) { |
| 93 | - foreach ($token->trim() as $t) $tokens[] = $t; |
|
| 97 | + foreach ($token->trim() as $t) { |
|
| 98 | + $tokens[] = $t; |
|
| 99 | + } |
|
| 94 | 100 | $tokens[] = ['type' => Tokenizer::GREATER_THAN]; |
| 95 | 101 | } |
| 96 | 102 | return new Tokens(array_slice($tokens, 0, -1)); |
@@ -67,12 +67,16 @@ |
||
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | public function loadProperties(Hook\PropertyHook $hook) { |
| 70 | - foreach ($this->properties as $name => $property) $hook->registerProperty($name, $property); |
|
| 70 | + foreach ($this->properties as $name => $property) { |
|
| 71 | + $hook->registerProperty($name, $property); |
|
| 72 | + } |
|
| 71 | 73 | } |
| 72 | 74 | |
| 73 | 75 | public function createPseudoMatcher($pseudo) { |
| 74 | 76 | $pseudoMatcher = new Hook\PseudoMatcher($pseudo, $this->valueParser); |
| 75 | - foreach ($this->pseudo as $pseudoFunction) $pseudoMatcher->registerFunction(clone $pseudoFunction); |
|
| 77 | + foreach ($this->pseudo as $pseudoFunction) { |
|
| 78 | + $pseudoMatcher->registerFunction(clone $pseudoFunction); |
|
| 79 | + } |
|
| 76 | 80 | return $pseudoMatcher; |
| 77 | 81 | } |
| 78 | 82 | |
@@ -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() { |