@@ -49,6 +49,6 @@ |
||
49 | 49 | $path = substr($name, strlen($this->prefix) + 1); |
50 | 50 | $path = str_replace('.', DIRECTORY_SEPARATOR, $path); |
51 | 51 | |
52 | - return $builder->load($this->path . DIRECTORY_SEPARATOR . $path); |
|
52 | + return $builder->load($this->path.DIRECTORY_SEPARATOR.$path); |
|
53 | 53 | } |
54 | 54 | } |
@@ -50,19 +50,19 @@ |
||
50 | 50 | */ |
51 | 51 | public function resolve(Builder $builder, string $name): ?Template |
52 | 52 | { |
53 | - if ($this->template === null) { |
|
53 | + if ($this->template === null){ |
|
54 | 54 | $this->template = $builder->load($this->path); |
55 | 55 | } |
56 | 56 | |
57 | 57 | $path = $name; |
58 | - if ($this->prefix !== null) { |
|
58 | + if ($this->prefix !== null){ |
|
59 | 59 | $path = substr($path, strlen($this->prefix) + 1); |
60 | 60 | } |
61 | 61 | |
62 | 62 | /** @var ImportInterface $import */ |
63 | - foreach ($this->template->getAttribute(ImportContext::class, []) as $import) { |
|
63 | + foreach ($this->template->getAttribute(ImportContext::class, []) as $import){ |
|
64 | 64 | $tpl = $import->resolve($builder, $path); |
65 | - if ($tpl !== null) { |
|
65 | + if ($tpl !== null){ |
|
66 | 66 | return $tpl; |
67 | 67 | } |
68 | 68 | } |
@@ -50,19 +50,23 @@ |
||
50 | 50 | */ |
51 | 51 | public function resolve(Builder $builder, string $name): ?Template |
52 | 52 | { |
53 | - if ($this->template === null) { |
|
53 | + if ($this->template === null) |
|
54 | + { |
|
54 | 55 | $this->template = $builder->load($this->path); |
55 | 56 | } |
56 | 57 | |
57 | 58 | $path = $name; |
58 | - if ($this->prefix !== null) { |
|
59 | + if ($this->prefix !== null) |
|
60 | + { |
|
59 | 61 | $path = substr($path, strlen($this->prefix) + 1); |
60 | 62 | } |
61 | 63 | |
62 | 64 | /** @var ImportInterface $import */ |
63 | - foreach ($this->template->getAttribute(ImportContext::class, []) as $import) { |
|
65 | + foreach ($this->template->getAttribute(ImportContext::class, []) as $import) |
|
66 | + { |
|
64 | 67 | $tpl = $import->resolve($builder, $path); |
65 | - if ($tpl !== null) { |
|
68 | + if ($tpl !== null) |
|
69 | + { |
|
66 | 70 | return $tpl; |
67 | 71 | } |
68 | 72 | } |
@@ -43,25 +43,25 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function enterNode($node, VisitorContext $ctx) |
45 | 45 | { |
46 | - if (!$node instanceof Aggregate) { |
|
46 | + if (!$node instanceof Aggregate){ |
|
47 | 47 | return null; |
48 | 48 | } |
49 | 49 | |
50 | - foreach ($this->blocks->getUnclaimed() as $name) { |
|
50 | + foreach ($this->blocks->getUnclaimed() as $name){ |
|
51 | 51 | $alias = $node->accepts($name); |
52 | - if ($alias === null) { |
|
52 | + if ($alias === null){ |
|
53 | 53 | continue; |
54 | 54 | } |
55 | 55 | |
56 | 56 | $value = $this->blocks->claim($name); |
57 | 57 | |
58 | - if ($value instanceof QuotedValue) { |
|
58 | + if ($value instanceof QuotedValue){ |
|
59 | 59 | $node->nodes[] = new Attr($alias, $value->getValue()); |
60 | 60 | continue; |
61 | 61 | } |
62 | 62 | |
63 | 63 | // simple copy attribute copy |
64 | - if ($value instanceof Attr) { |
|
64 | + if ($value instanceof Attr){ |
|
65 | 65 | $node->nodes[] = clone $value; |
66 | 66 | continue; |
67 | 67 | } |
@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | */ |
84 | 84 | private function wrapValue($value) |
85 | 85 | { |
86 | - if ($value === [] || $value === null || $value instanceof Nil) { |
|
86 | + if ($value === [] || $value === null || $value instanceof Nil){ |
|
87 | 87 | return new Nil(); |
88 | 88 | } |
89 | 89 | |
90 | - if ($value instanceof Verbatim || is_scalar($value)) { |
|
90 | + if ($value instanceof Verbatim || is_scalar($value)){ |
|
91 | 91 | return $value; |
92 | 92 | } |
93 | 93 |
@@ -43,25 +43,30 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function enterNode($node, VisitorContext $ctx) |
45 | 45 | { |
46 | - if (!$node instanceof Aggregate) { |
|
46 | + if (!$node instanceof Aggregate) |
|
47 | + { |
|
47 | 48 | return null; |
48 | 49 | } |
49 | 50 | |
50 | - foreach ($this->blocks->getUnclaimed() as $name) { |
|
51 | + foreach ($this->blocks->getUnclaimed() as $name) |
|
52 | + { |
|
51 | 53 | $alias = $node->accepts($name); |
52 | - if ($alias === null) { |
|
54 | + if ($alias === null) |
|
55 | + { |
|
53 | 56 | continue; |
54 | 57 | } |
55 | 58 | |
56 | 59 | $value = $this->blocks->claim($name); |
57 | 60 | |
58 | - if ($value instanceof QuotedValue) { |
|
61 | + if ($value instanceof QuotedValue) |
|
62 | + { |
|
59 | 63 | $node->nodes[] = new Attr($alias, $value->getValue()); |
60 | 64 | continue; |
61 | 65 | } |
62 | 66 | |
63 | 67 | // simple copy attribute copy |
64 | - if ($value instanceof Attr) { |
|
68 | + if ($value instanceof Attr) |
|
69 | + { |
|
65 | 70 | $node->nodes[] = clone $value; |
66 | 71 | continue; |
67 | 72 | } |
@@ -83,11 +88,13 @@ discard block |
||
83 | 88 | */ |
84 | 89 | private function wrapValue($value) |
85 | 90 | { |
86 | - if ($value === [] || $value === null || $value instanceof Nil) { |
|
91 | + if ($value === [] || $value === null || $value instanceof Nil) |
|
92 | + { |
|
87 | 93 | return new Nil(); |
88 | 94 | } |
89 | 95 | |
90 | - if ($value instanceof Verbatim || is_scalar($value)) { |
|
96 | + if ($value instanceof Verbatim || is_scalar($value)) |
|
97 | + { |
|
91 | 98 | return $value; |
92 | 99 | } |
93 | 100 |
@@ -59,20 +59,20 @@ discard block |
||
59 | 59 | strpos($node->content, self::PHP_MACRO_FUNCTION) === false |
60 | 60 | && strpos($node->content, self::PHP_MARCO_EXISTS_FUNCTION) === false |
61 | 61 | ) |
62 | - ) { |
|
62 | + ){ |
|
63 | 63 | return null; |
64 | 64 | } |
65 | 65 | |
66 | 66 | $php = new PHPMixin($node->tokens, self::PHP_MACRO_FUNCTION); |
67 | - foreach ($this->blocks->getNames() as $name) { |
|
67 | + foreach ($this->blocks->getNames() as $name){ |
|
68 | 68 | $block = $this->blocks->get($name); |
69 | 69 | |
70 | - if ($this->isReference($block)) { |
|
70 | + if ($this->isReference($block)){ |
|
71 | 71 | // resolved on later stage |
72 | 72 | continue; |
73 | 73 | } |
74 | 74 | |
75 | - if ($php->has($name)) { |
|
75 | + if ($php->has($name)){ |
|
76 | 76 | $php->set($name, $this->trimPHP($this->blocks->claim($name))); |
77 | 77 | } |
78 | 78 | } |
@@ -81,15 +81,15 @@ discard block |
||
81 | 81 | $node->tokens = token_get_all($node->content); |
82 | 82 | |
83 | 83 | $exists = new PHPMixin($node->tokens, self::PHP_MARCO_EXISTS_FUNCTION); |
84 | - foreach ($this->blocks->getNames() as $name) { |
|
84 | + foreach ($this->blocks->getNames() as $name){ |
|
85 | 85 | $block = $this->blocks->get($name); |
86 | 86 | |
87 | - if ($this->isReference($block)) { |
|
87 | + if ($this->isReference($block)){ |
|
88 | 88 | // resolved on later stage |
89 | 89 | continue; |
90 | 90 | } |
91 | 91 | |
92 | - if ($exists->has($name)) { |
|
92 | + if ($exists->has($name)){ |
|
93 | 93 | $exists->set($name, 'true'); |
94 | 94 | } |
95 | 95 | } |
@@ -111,10 +111,10 @@ discard block |
||
111 | 111 | */ |
112 | 112 | private function isReference($node): bool |
113 | 113 | { |
114 | - switch (true) { |
|
114 | + switch (true){ |
|
115 | 115 | case is_array($node): |
116 | - foreach ($node as $child) { |
|
117 | - if ($this->isReference($child)) { |
|
116 | + foreach ($node as $child){ |
|
117 | + if ($this->isReference($child)){ |
|
118 | 118 | return true; |
119 | 119 | } |
120 | 120 | } |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | return $this->isReference($node->getValue()); |
126 | 126 | |
127 | 127 | case $node instanceof Mixin: |
128 | - foreach ($node->nodes as $child) { |
|
129 | - if ($this->isReference($child)) { |
|
128 | + foreach ($node->nodes as $child){ |
|
129 | + if ($this->isReference($child)){ |
|
130 | 130 | return true; |
131 | 131 | } |
132 | 132 | } |
@@ -146,10 +146,10 @@ discard block |
||
146 | 146 | */ |
147 | 147 | private function trimPHP($node): string |
148 | 148 | { |
149 | - switch (true) { |
|
149 | + switch (true){ |
|
150 | 150 | case is_array($node): |
151 | 151 | $result = []; |
152 | - foreach ($node as $child) { |
|
152 | + foreach ($node as $child){ |
|
153 | 153 | $result[] = $this->trimPHP($child); |
154 | 154 | } |
155 | 155 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | |
158 | 158 | case $node instanceof Mixin: |
159 | 159 | $result = []; |
160 | - foreach ($node->nodes as $child) { |
|
160 | + foreach ($node->nodes as $child){ |
|
161 | 161 | $result[] = $this->trimPHP($child); |
162 | 162 | } |
163 | 163 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | return trim($node->body); |
171 | 171 | |
172 | 172 | case $node instanceof PHP: |
173 | - if ($node->getContext()->getValue(PHP::ORIGINAL_BODY) !== null) { |
|
173 | + if ($node->getContext()->getValue(PHP::ORIGINAL_BODY) !== null){ |
|
174 | 174 | return $node->getContext()->getValue(PHP::ORIGINAL_BODY); |
175 | 175 | } |
176 | 176 | |
@@ -190,13 +190,13 @@ discard block |
||
190 | 190 | private function exportValue(Raw $node): string |
191 | 191 | { |
192 | 192 | $value = $node->content; |
193 | - switch (true) { |
|
193 | + switch (true){ |
|
194 | 194 | case strtolower($value) === 'true': |
195 | 195 | return 'true'; |
196 | 196 | case strtolower($value) === 'false': |
197 | 197 | return 'false'; |
198 | 198 | case is_float($value) || is_numeric($value): |
199 | - return (string) $value; |
|
199 | + return (string)$value; |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | return var_export($node->content, true); |
@@ -64,15 +64,18 @@ discard block |
||
64 | 64 | } |
65 | 65 | |
66 | 66 | $php = new PHPMixin($node->tokens, self::PHP_MACRO_FUNCTION); |
67 | - foreach ($this->blocks->getNames() as $name) { |
|
67 | + foreach ($this->blocks->getNames() as $name) |
|
68 | + { |
|
68 | 69 | $block = $this->blocks->get($name); |
69 | 70 | |
70 | - if ($this->isReference($block)) { |
|
71 | + if ($this->isReference($block)) |
|
72 | + { |
|
71 | 73 | // resolved on later stage |
72 | 74 | continue; |
73 | 75 | } |
74 | 76 | |
75 | - if ($php->has($name)) { |
|
77 | + if ($php->has($name)) |
|
78 | + { |
|
76 | 79 | $php->set($name, $this->trimPHP($this->blocks->claim($name))); |
77 | 80 | } |
78 | 81 | } |
@@ -81,15 +84,18 @@ discard block |
||
81 | 84 | $node->tokens = token_get_all($node->content); |
82 | 85 | |
83 | 86 | $exists = new PHPMixin($node->tokens, self::PHP_MARCO_EXISTS_FUNCTION); |
84 | - foreach ($this->blocks->getNames() as $name) { |
|
87 | + foreach ($this->blocks->getNames() as $name) |
|
88 | + { |
|
85 | 89 | $block = $this->blocks->get($name); |
86 | 90 | |
87 | - if ($this->isReference($block)) { |
|
91 | + if ($this->isReference($block)) |
|
92 | + { |
|
88 | 93 | // resolved on later stage |
89 | 94 | continue; |
90 | 95 | } |
91 | 96 | |
92 | - if ($exists->has($name)) { |
|
97 | + if ($exists->has($name)) |
|
98 | + { |
|
93 | 99 | $exists->set($name, 'true'); |
94 | 100 | } |
95 | 101 | } |
@@ -111,10 +117,13 @@ discard block |
||
111 | 117 | */ |
112 | 118 | private function isReference($node): bool |
113 | 119 | { |
114 | - switch (true) { |
|
120 | + switch (true) |
|
121 | + { |
|
115 | 122 | case is_array($node): |
116 | - foreach ($node as $child) { |
|
117 | - if ($this->isReference($child)) { |
|
123 | + foreach ($node as $child) |
|
124 | + { |
|
125 | + if ($this->isReference($child)) |
|
126 | + { |
|
118 | 127 | return true; |
119 | 128 | } |
120 | 129 | } |
@@ -125,8 +134,10 @@ discard block |
||
125 | 134 | return $this->isReference($node->getValue()); |
126 | 135 | |
127 | 136 | case $node instanceof Mixin: |
128 | - foreach ($node->nodes as $child) { |
|
129 | - if ($this->isReference($child)) { |
|
137 | + foreach ($node->nodes as $child) |
|
138 | + { |
|
139 | + if ($this->isReference($child)) |
|
140 | + { |
|
130 | 141 | return true; |
131 | 142 | } |
132 | 143 | } |
@@ -146,10 +157,12 @@ discard block |
||
146 | 157 | */ |
147 | 158 | private function trimPHP($node): string |
148 | 159 | { |
149 | - switch (true) { |
|
160 | + switch (true) |
|
161 | + { |
|
150 | 162 | case is_array($node): |
151 | 163 | $result = []; |
152 | - foreach ($node as $child) { |
|
164 | + foreach ($node as $child) |
|
165 | + { |
|
153 | 166 | $result[] = $this->trimPHP($child); |
154 | 167 | } |
155 | 168 | |
@@ -157,7 +170,8 @@ discard block |
||
157 | 170 | |
158 | 171 | case $node instanceof Mixin: |
159 | 172 | $result = []; |
160 | - foreach ($node->nodes as $child) { |
|
173 | + foreach ($node->nodes as $child) |
|
174 | + { |
|
161 | 175 | $result[] = $this->trimPHP($child); |
162 | 176 | } |
163 | 177 | |
@@ -170,7 +184,8 @@ discard block |
||
170 | 184 | return trim($node->body); |
171 | 185 | |
172 | 186 | case $node instanceof PHP: |
173 | - if ($node->getContext()->getValue(PHP::ORIGINAL_BODY) !== null) { |
|
187 | + if ($node->getContext()->getValue(PHP::ORIGINAL_BODY) !== null) |
|
188 | + { |
|
174 | 189 | return $node->getContext()->getValue(PHP::ORIGINAL_BODY); |
175 | 190 | } |
176 | 191 | |
@@ -190,7 +205,8 @@ discard block |
||
190 | 205 | private function exportValue(Raw $node): string |
191 | 206 | { |
192 | 207 | $value = $node->content; |
193 | - switch (true) { |
|
208 | + switch (true) |
|
209 | + { |
|
194 | 210 | case strtolower($value) === 'true': |
195 | 211 | return 'true'; |
196 | 212 | case strtolower($value) === 'false': |
@@ -30,15 +30,15 @@ |
||
30 | 30 | */ |
31 | 31 | public function enterNode($node, VisitorContext $ctx) |
32 | 32 | { |
33 | - if (!$node instanceof Attr || $node->name !== self::AGGREGATE_ATTRIBUTE) { |
|
33 | + if (!$node instanceof Attr || $node->name !== self::AGGREGATE_ATTRIBUTE){ |
|
34 | 34 | return null; |
35 | 35 | } |
36 | 36 | |
37 | - if ($node->value instanceof Nil) { |
|
37 | + if ($node->value instanceof Nil){ |
|
38 | 38 | return new Aggregate($node->getContext()); |
39 | 39 | } |
40 | 40 | |
41 | - if (!is_string($node->value)) { |
|
41 | + if (!is_string($node->value)){ |
|
42 | 42 | return null; |
43 | 43 | } |
44 | 44 |
@@ -30,15 +30,18 @@ |
||
30 | 30 | */ |
31 | 31 | public function enterNode($node, VisitorContext $ctx) |
32 | 32 | { |
33 | - if (!$node instanceof Attr || $node->name !== self::AGGREGATE_ATTRIBUTE) { |
|
33 | + if (!$node instanceof Attr || $node->name !== self::AGGREGATE_ATTRIBUTE) |
|
34 | + { |
|
34 | 35 | return null; |
35 | 36 | } |
36 | 37 | |
37 | - if ($node->value instanceof Nil) { |
|
38 | + if ($node->value instanceof Nil) |
|
39 | + { |
|
38 | 40 | return new Aggregate($node->getContext()); |
39 | 41 | } |
40 | 42 | |
41 | - if (!is_string($node->value)) { |
|
43 | + if (!is_string($node->value)) |
|
44 | + { |
|
42 | 45 | return null; |
43 | 46 | } |
44 | 47 |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function enterNode($node, VisitorContext $ctx) |
32 | 32 | { |
33 | - if ($node instanceof Tag && strpos($node->name, $this->stackKeyword) === 0) { |
|
33 | + if ($node instanceof Tag && strpos($node->name, $this->stackKeyword) === 0){ |
|
34 | 34 | return $this->registerAggregate(StackContext::on($ctx), $node); |
35 | 35 | } |
36 | 36 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | private function registerAggregate(StackContext $ctx, Tag $node) |
53 | 53 | { |
54 | 54 | $name = $this->stackName($node); |
55 | - if ($name === null) { |
|
55 | + if ($name === null){ |
|
56 | 56 | return $node; |
57 | 57 | } |
58 | 58 | |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | private function stackName(Tag $tag): ?string |
73 | 73 | { |
74 | 74 | $options = []; |
75 | - foreach ($tag->attrs as $attr) { |
|
76 | - if (is_string($attr->value)) { |
|
75 | + foreach ($tag->attrs as $attr){ |
|
76 | + if (is_string($attr->value)){ |
|
77 | 77 | $options[$attr->name] = trim($attr->value, '\'"'); |
78 | 78 | } |
79 | 79 | } |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | private function stackLevel(Tag $tag): int |
89 | 89 | { |
90 | 90 | $options = []; |
91 | - foreach ($tag->attrs as $attr) { |
|
92 | - if (is_string($attr->value)) { |
|
91 | + foreach ($tag->attrs as $attr){ |
|
92 | + if (is_string($attr->value)){ |
|
93 | 93 | $options[$attr->name] = trim($attr->value, '\'"'); |
94 | 94 | } |
95 | 95 | } |
@@ -30,7 +30,8 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function enterNode($node, VisitorContext $ctx) |
32 | 32 | { |
33 | - if ($node instanceof Tag && strpos($node->name, $this->stackKeyword) === 0) { |
|
33 | + if ($node instanceof Tag && strpos($node->name, $this->stackKeyword) === 0) |
|
34 | + { |
|
34 | 35 | return $this->registerAggregate(StackContext::on($ctx), $node); |
35 | 36 | } |
36 | 37 | |
@@ -52,7 +53,8 @@ discard block |
||
52 | 53 | private function registerAggregate(StackContext $ctx, Tag $node) |
53 | 54 | { |
54 | 55 | $name = $this->stackName($node); |
55 | - if ($name === null) { |
|
56 | + if ($name === null) |
|
57 | + { |
|
56 | 58 | return $node; |
57 | 59 | } |
58 | 60 | |
@@ -72,8 +74,10 @@ discard block |
||
72 | 74 | private function stackName(Tag $tag): ?string |
73 | 75 | { |
74 | 76 | $options = []; |
75 | - foreach ($tag->attrs as $attr) { |
|
76 | - if (is_string($attr->value)) { |
|
77 | + foreach ($tag->attrs as $attr) |
|
78 | + { |
|
79 | + if (is_string($attr->value)) |
|
80 | + { |
|
77 | 81 | $options[$attr->name] = trim($attr->value, '\'"'); |
78 | 82 | } |
79 | 83 | } |
@@ -88,8 +92,10 @@ discard block |
||
88 | 92 | private function stackLevel(Tag $tag): int |
89 | 93 | { |
90 | 94 | $options = []; |
91 | - foreach ($tag->attrs as $attr) { |
|
92 | - if (is_string($attr->value)) { |
|
95 | + foreach ($tag->attrs as $attr) |
|
96 | + { |
|
97 | + if (is_string($attr->value)) |
|
98 | + { |
|
93 | 99 | $options[$attr->name] = trim($attr->value, '\'"'); |
94 | 100 | } |
95 | 101 | } |
@@ -33,7 +33,7 @@ |
||
33 | 33 | */ |
34 | 34 | public function leaveNode($node, VisitorContext $ctx) |
35 | 35 | { |
36 | - if ($node instanceof Tag && strpos($node->name, $this->hiddenKeyword) === 0) { |
|
36 | + if ($node instanceof Tag && strpos($node->name, $this->hiddenKeyword) === 0){ |
|
37 | 37 | return new Hidden([$node]); |
38 | 38 | } |
39 | 39 |
@@ -33,7 +33,8 @@ |
||
33 | 33 | */ |
34 | 34 | public function leaveNode($node, VisitorContext $ctx) |
35 | 35 | { |
36 | - if ($node instanceof Tag && strpos($node->name, $this->hiddenKeyword) === 0) { |
|
36 | + if ($node instanceof Tag && strpos($node->name, $this->hiddenKeyword) === 0) |
|
37 | + { |
|
37 | 38 | return new Hidden([$node]); |
38 | 39 | } |
39 | 40 |
@@ -49,14 +49,14 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function accepts(string $name): ?string |
51 | 51 | { |
52 | - if ($this->pattern === '' || $this->pattern === '*') { |
|
52 | + if ($this->pattern === '' || $this->pattern === '*'){ |
|
53 | 53 | // accept everything |
54 | 54 | return $name; |
55 | 55 | } |
56 | 56 | |
57 | 57 | $conditions = []; |
58 | - foreach (explode(';', $this->pattern) as $condition) { |
|
59 | - if (strpos($condition, ':') === false) { |
|
58 | + foreach (explode(';', $this->pattern) as $condition){ |
|
59 | + if (strpos($condition, ':') === false){ |
|
60 | 60 | //Invalid |
61 | 61 | continue; |
62 | 62 | } |
@@ -65,27 +65,27 @@ discard block |
||
65 | 65 | $conditions[$option] = $value; |
66 | 66 | } |
67 | 67 | |
68 | - if (isset($conditions['include'])) { |
|
68 | + if (isset($conditions['include'])){ |
|
69 | 69 | $include = explode(',', $conditions['include']); |
70 | - if (in_array($name, $include)) { |
|
70 | + if (in_array($name, $include)){ |
|
71 | 71 | return $name; |
72 | 72 | } |
73 | 73 | |
74 | 74 | return null; |
75 | 75 | } |
76 | 76 | |
77 | - if (isset($conditions['exclude'])) { |
|
77 | + if (isset($conditions['exclude'])){ |
|
78 | 78 | $exclude = explode(',', $conditions['exclude']); |
79 | - if (in_array($name, $exclude)) { |
|
79 | + if (in_array($name, $exclude)){ |
|
80 | 80 | return null; |
81 | 81 | } |
82 | 82 | |
83 | 83 | return $name; |
84 | 84 | } |
85 | 85 | |
86 | - if (isset($conditions['prefix'])) { |
|
86 | + if (isset($conditions['prefix'])){ |
|
87 | 87 | $conditions['prefix'] = rtrim($conditions['prefix'], ' *'); |
88 | - if (strpos($name, $conditions['prefix']) === 0) { |
|
88 | + if (strpos($name, $conditions['prefix']) === 0){ |
|
89 | 89 | return substr($name, strlen($conditions['prefix'])); |
90 | 90 | } |
91 | 91 |
@@ -49,14 +49,17 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function accepts(string $name): ?string |
51 | 51 | { |
52 | - if ($this->pattern === '' || $this->pattern === '*') { |
|
52 | + if ($this->pattern === '' || $this->pattern === '*') |
|
53 | + { |
|
53 | 54 | // accept everything |
54 | 55 | return $name; |
55 | 56 | } |
56 | 57 | |
57 | 58 | $conditions = []; |
58 | - foreach (explode(';', $this->pattern) as $condition) { |
|
59 | - if (strpos($condition, ':') === false) { |
|
59 | + foreach (explode(';', $this->pattern) as $condition) |
|
60 | + { |
|
61 | + if (strpos($condition, ':') === false) |
|
62 | + { |
|
60 | 63 | //Invalid |
61 | 64 | continue; |
62 | 65 | } |
@@ -65,27 +68,33 @@ discard block |
||
65 | 68 | $conditions[$option] = $value; |
66 | 69 | } |
67 | 70 | |
68 | - if (isset($conditions['include'])) { |
|
71 | + if (isset($conditions['include'])) |
|
72 | + { |
|
69 | 73 | $include = explode(',', $conditions['include']); |
70 | - if (in_array($name, $include)) { |
|
74 | + if (in_array($name, $include)) |
|
75 | + { |
|
71 | 76 | return $name; |
72 | 77 | } |
73 | 78 | |
74 | 79 | return null; |
75 | 80 | } |
76 | 81 | |
77 | - if (isset($conditions['exclude'])) { |
|
82 | + if (isset($conditions['exclude'])) |
|
83 | + { |
|
78 | 84 | $exclude = explode(',', $conditions['exclude']); |
79 | - if (in_array($name, $exclude)) { |
|
85 | + if (in_array($name, $exclude)) |
|
86 | + { |
|
80 | 87 | return null; |
81 | 88 | } |
82 | 89 | |
83 | 90 | return $name; |
84 | 91 | } |
85 | 92 | |
86 | - if (isset($conditions['prefix'])) { |
|
93 | + if (isset($conditions['prefix'])) |
|
94 | + { |
|
87 | 95 | $conditions['prefix'] = rtrim($conditions['prefix'], ' *'); |
88 | - if (strpos($name, $conditions['prefix']) === 0) { |
|
96 | + if (strpos($name, $conditions['prefix']) === 0) |
|
97 | + { |
|
89 | 98 | return substr($name, strlen($conditions['prefix'])); |
90 | 99 | } |
91 | 100 |
@@ -53,7 +53,7 @@ |
||
53 | 53 | */ |
54 | 54 | public function peak(): ?string |
55 | 55 | { |
56 | - if ($this->offset + 1 > $this->length) { |
|
56 | + if ($this->offset + 1 > $this->length){ |
|
57 | 57 | return null; |
58 | 58 | } |
59 | 59 |
@@ -53,7 +53,8 @@ |
||
53 | 53 | */ |
54 | 54 | public function peak(): ?string |
55 | 55 | { |
56 | - if ($this->offset + 1 > $this->length) { |
|
56 | + if ($this->offset + 1 > $this->length) |
|
57 | + { |
|
57 | 58 | return null; |
58 | 59 | } |
59 | 60 |