@@ -33,9 +33,13 @@ discard block |
||
33 | 33 | $rules = $this->writeRule($rules, $newRules); |
34 | 34 | } |
35 | 35 | //there may be processing instructions at the end |
36 | - if ($processing = $this->processingInstructions($this->tss, $pos, strlen($this->tss), count($rules)+$indexStart)) $rules = array_merge($rules, $processing['rules']); |
|
36 | + if ($processing = $this->processingInstructions($this->tss, $pos, strlen($this->tss), count($rules)+$indexStart)) { |
|
37 | + $rules = array_merge($rules, $processing['rules']); |
|
38 | + } |
|
37 | 39 | usort($rules, [$this, 'sortRules']); |
38 | - if (empty($rules) && !empty($this->tss)) throw new \Exception("No TSS rules parsed"); |
|
40 | + if (empty($rules) && !empty($this->tss)) { |
|
41 | + throw new \Exception("No TSS rules parsed"); |
|
42 | + } |
|
39 | 43 | return $rules; |
40 | 44 | } |
41 | 45 | |
@@ -69,8 +73,7 @@ discard block |
||
69 | 73 | $pos = strpos($tss, ';', $spacePos); |
70 | 74 | $args = substr($tss, $spacePos+1, $pos-$spacePos-1); |
71 | 75 | $rules = array_merge($rules, $this->$funcName($args, $indexStart)); |
72 | - } |
|
73 | - else { |
|
76 | + } else { |
|
74 | 77 | break; |
75 | 78 | } |
76 | 79 | } |
@@ -79,15 +82,20 @@ discard block |
||
79 | 82 | } |
80 | 83 | |
81 | 84 | private function import($args, $indexStart) { |
82 | - if (is_file(trim($args,'\'" '))) $fileName = trim($args,'\'" '); |
|
83 | - else $fileName = $this->valueParser->parse($args)[0]; |
|
85 | + if (is_file(trim($args,'\'" '))) { |
|
86 | + $fileName = trim($args,'\'" '); |
|
87 | + } else { |
|
88 | + $fileName = $this->valueParser->parse($args)[0]; |
|
89 | + } |
|
84 | 90 | $sheet = new Sheet(file_get_contents($this->baseDir . $fileName), dirname(realpath($this->baseDir . $fileName)) . DIRECTORY_SEPARATOR, $this->xPath, $this->valueParser); |
85 | 91 | return $sheet->parse(0, [], $indexStart); |
86 | 92 | } |
87 | 93 | |
88 | 94 | private function sortRules($a, $b) { |
89 | 95 | //If they have the same depth, compare on index |
90 | - if ($a->depth === $b->depth) return $a->index < $b->index ? -1 : 1; |
|
96 | + if ($a->depth === $b->depth) { |
|
97 | + return $a->index < $b->index ? -1 : 1; |
|
98 | + } |
|
91 | 99 | |
92 | 100 | return ($a->depth < $b->depth) ? -1 : 1; |
93 | 101 | } |
@@ -96,7 +104,9 @@ discard block |
||
96 | 104 | $pos = 0; |
97 | 105 | while (($pos = strpos($str, $open, $pos)) !== false) { |
98 | 106 | $end = strpos($str, $close, $pos); |
99 | - if ($end === false) break; |
|
107 | + if ($end === false) { |
|
108 | + break; |
|
109 | + } |
|
100 | 110 | $str = substr_replace($str, '', $pos, $end-$pos+strlen($close)); |
101 | 111 | } |
102 | 112 | |
@@ -110,13 +120,18 @@ discard block |
||
110 | 120 | $rules = []; |
111 | 121 | $i = 0; |
112 | 122 | foreach ($tokens as $token) { |
113 | - if ($token['type'] === Tokenizer::SEMI_COLON) $i++; |
|
114 | - else $rules[$i][] = $token; |
|
123 | + if ($token['type'] === Tokenizer::SEMI_COLON) { |
|
124 | + $i++; |
|
125 | + } else { |
|
126 | + $rules[$i][] = $token; |
|
127 | + } |
|
115 | 128 | } |
116 | 129 | |
117 | 130 | $return = []; |
118 | 131 | foreach ($rules as $rule) { |
119 | - if ($rule[1]['type'] === Tokenizer::COLON) $return[$rule[0]['value']] = array_slice($rule, 2); |
|
132 | + if ($rule[1]['type'] === Tokenizer::COLON) { |
|
133 | + $return[$rule[0]['value']] = array_slice($rule, 2); |
|
134 | + } |
|
120 | 135 | } |
121 | 136 | |
122 | 137 | return $return; |