@@ -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 | } |
@@ -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 | } |
@@ -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) { |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | /** Converts $val into a \DateTime object if it's not already */ |
| 17 | 17 | private function getDate($val) { |
| 18 | 18 | $tz = new \DateTimeZone($this->locale['timezone']); |
| 19 | - $date = $val instanceof \DateTimeInterface ? $val : new \DateTime($val, $tz); |
|
| 19 | + $date = $val instanceof \DateTimeInterface ? $val : new \DateTime($val, $tz); |
|
| 20 | 20 | $date->setTimeZone($tz); |
| 21 | 21 | return $date; |
| 22 | 22 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | /** Formats \DateTime as Date and Time using formats from $locale */ |
| 37 | 37 | public function dateTime($val) { |
| 38 | - return $this->date($val, $this->locale['date_format'] . ' ' . $this->locale['time_format']); |
|
| 38 | + return $this->date($val, $this->locale['date_format'].' '.$this->locale['time_format']); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** Generates relative time offsets based on system clock. e.g "10 minutes ago" or "In 6 months" |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | $diff = $now->diff($date); |
| 48 | 48 | |
| 49 | 49 | |
| 50 | - $diffDays = $diff->invert === 1 ? $diff->days : 0- $diff->days; |
|
| 50 | + $diffDays = $diff->invert === 1 ? $diff->days : 0-$diff->days; |
|
| 51 | 51 | |
| 52 | 52 | if ($diffDays !== 0) return $this->dayOffset($diffDays); |
| 53 | 53 | else return $this->timeOffset($diff); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | /** Gets date ranges to represent uses of weeks/months/days/etc */ |
| 77 | 77 | private function getRanges($strings) { |
| 78 | - $ranges = [ |
|
| 78 | + $ranges = [ |
|
| 79 | 79 | [1, 1, $strings['yesterday'], 1, ''], |
| 80 | 80 | [1, 13, $strings['past'], 1, 'days'], |
| 81 | 81 | [13, 28, $strings['past'], 7, 'weeks'], |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | /** Converts "week" to "weeks", "month" to "months" etc when plural is required using language from $locale */ |
| 96 | 96 | private function getPlural($strings, $num, $interval) { |
| 97 | - if ($interval !== '') return $num == 1 ? $strings[$interval . '_singular'] : $strings[$interval . '_plural']; |
|
| 97 | + if ($interval !== '') return $num == 1 ? $strings[$interval.'_singular'] : $strings[$interval.'_plural']; |
|
| 98 | 98 | else return ''; |
| 99 | 99 | } |
| 100 | 100 | |
@@ -69,7 +69,7 @@ |
||
| 69 | 69 | |
| 70 | 70 | public function extract($last, $autoLookup, $traversing) { |
| 71 | 71 | $value = $this->read($last); |
| 72 | - if ($value !== null && ($autoLookup || $traversing) ) { |
|
| 72 | + if ($value !== null && ($autoLookup || $traversing)) { |
|
| 73 | 73 | return $value; |
| 74 | 74 | } |
| 75 | 75 | throw new \UnexpectedValueException('Not found'); |
@@ -85,7 +85,7 @@ |
||
| 85 | 85 | if ($lastResult) { |
| 86 | 86 | $this->last->makeTraversing(); |
| 87 | 87 | } |
| 88 | - else if ($this->last->isEmpty()) { |
|
| 88 | + else if ($this->last->isEmpty()) { |
|
| 89 | 89 | $this->processString(['value' => '.']); |
| 90 | 90 | $this->result->setMode(Tokenizer::CONCAT); |
| 91 | 91 | } |
@@ -55,21 +55,21 @@ discard block |
||
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | public function read($offset = 0) { |
| 58 | - return $this->str[$this->pos + $offset]; |
|
| 58 | + return $this->str[$this->pos+$offset]; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | public function identifyChar($offset = 0) { |
| 62 | - $chr = $this->str[$this->pos + $offset]; |
|
| 62 | + $chr = $this->str[$this->pos+$offset]; |
|
| 63 | 63 | if (!empty($this->chars[$chr])) return $this->chars[$chr]; |
| 64 | 64 | else return Tokenizer::NAME; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | public function has($offset = 0) { |
| 68 | - return isset($this->str[$this->pos + $offset]); |
|
| 68 | + return isset($this->str[$this->pos+$offset]); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | public function pos($str) { |
| 72 | - $pos = strpos($this->str, $str, $this->pos); |
|
| 72 | + $pos = strpos($this->str, $str, $this->pos); |
|
| 73 | 73 | return $pos ? $pos-$this->pos : false; |
| 74 | 74 | } |
| 75 | 75 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | public function extractString($offset = 0) { |
| 85 | - $pos = $this->pos + $offset; |
|
| 85 | + $pos = $this->pos+$offset; |
|
| 86 | 86 | $char = $this->str[$pos]; |
| 87 | 87 | $end = strpos($this->str, $char, $pos+1); |
| 88 | 88 | while ($end !== false && $this->str[$end-1] == '\\') $end = strpos($this->str, $char, $end+1); |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | $chr = $str->read(); |
| 11 | 11 | $string = $str->extractString(); |
| 12 | 12 | $length = strlen($string)+1; |
| 13 | - $string = str_replace('\\' . $chr, $chr, $string); |
|
| 13 | + $string = str_replace('\\'.$chr, $chr, $string); |
|
| 14 | 14 | $tokens->add(['type' => Tokenizer::STRING, 'value' => $string, 'line' => $str->lineNo()]); |
| 15 | 15 | $str->move($length); |
| 16 | 16 | } |
@@ -19,13 +19,13 @@ discard block |
||
| 19 | 19 | $this->functionSet = $functionSet; |
| 20 | 20 | |
| 21 | 21 | $this->translators = [ |
| 22 | - Tokenizer::WHITESPACE => function($string) use ($prefix) { return '//' . $prefix . $string; }, |
|
| 23 | - Tokenizer::MULTIPLY => function () { return '*'; }, |
|
| 24 | - '' => function($string) use ($prefix) { return '/' . $prefix . $string; }, |
|
| 25 | - Tokenizer::GREATER_THAN => function($string) use ($prefix) { return '/' . $prefix . $string; }, |
|
| 26 | - Tokenizer::NUM_SIGN => function($string) { return '[@id=\'' . $string . '\']'; }, |
|
| 27 | - Tokenizer::DOT => function($string) { return '[contains(concat(\' \', normalize-space(@class), \' \'), \' ' . $string . ' \')]'; }, |
|
| 28 | - Tokenizer::OPEN_SQUARE_BRACKET => function($string) { return '[' .'php:function(\'\Transphporm\Parser\CssToXpath::processAttr\', \'' . base64_encode(serialize($string)) . '\', ., "' . $this->id . '")' . ']'; } |
|
| 22 | + Tokenizer::WHITESPACE => function($string) use ($prefix) { return '//'.$prefix.$string; }, |
|
| 23 | + Tokenizer::MULTIPLY => function() { return '*'; }, |
|
| 24 | + '' => function($string) use ($prefix) { return '/'.$prefix.$string; }, |
|
| 25 | + Tokenizer::GREATER_THAN => function($string) use ($prefix) { return '/'.$prefix.$string; }, |
|
| 26 | + Tokenizer::NUM_SIGN => function($string) { return '[@id=\''.$string.'\']'; }, |
|
| 27 | + Tokenizer::DOT => function($string) { return '[contains(concat(\' \', normalize-space(@class), \' \'), \' '.$string.' \')]'; }, |
|
| 28 | + Tokenizer::OPEN_SQUARE_BRACKET => function($string) { return '['.'php:function(\'\Transphporm\Parser\CssToXpath::processAttr\', \''.base64_encode(serialize($string)).'\', ., "'.$this->id.'")'.']'; } |
|
| 29 | 29 | ]; |
| 30 | 30 | } |
| 31 | 31 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $functionSet->setElement($element[0]); |
| 45 | 45 | |
| 46 | 46 | $attributes = []; |
| 47 | - foreach($element[0]->attributes as $name => $node) { |
|
| 47 | + foreach ($element[0]->attributes as $name => $node) { |
|
| 48 | 48 | $attributes[$name] = $node->nodeValue; |
| 49 | 49 | } |
| 50 | 50 | |