@@ -40,10 +40,10 @@ |
||
40 | 40 | */ |
41 | 41 | public function matches(string $string, string $pattern): bool |
42 | 42 | { |
43 | - if ($string === $pattern) { |
|
43 | + if ($string === $pattern){ |
|
44 | 44 | return true; |
45 | 45 | } |
46 | - if (!$this->isPattern($pattern)) { |
|
46 | + if (!$this->isPattern($pattern)){ |
|
47 | 47 | return false; |
48 | 48 | } |
49 | 49 | return (bool)preg_match($this->getRegex($pattern), $string); |
@@ -40,10 +40,12 @@ |
||
40 | 40 | */ |
41 | 41 | public function matches(string $string, string $pattern): bool |
42 | 42 | { |
43 | - if ($string === $pattern) { |
|
43 | + if ($string === $pattern) |
|
44 | + { |
|
44 | 45 | return true; |
45 | 46 | } |
46 | - if (!$this->isPattern($pattern)) { |
|
47 | + if (!$this->isPattern($pattern)) |
|
48 | + { |
|
47 | 49 | return false; |
48 | 50 | } |
49 | 51 | return (bool)preg_match($this->getRegex($pattern), $string); |
@@ -63,20 +63,20 @@ |
||
63 | 63 | $parameters = compact('actor', 'permission', 'context') + $context; |
64 | 64 | |
65 | 65 | //Mounting aliases |
66 | - foreach (static::ALIASES as $target => $alias) { |
|
66 | + foreach (static::ALIASES as $target => $alias){ |
|
67 | 67 | $parameters[$target] = $parameters[$alias]; |
68 | 68 | } |
69 | 69 | |
70 | - try { |
|
70 | + try{ |
|
71 | 71 | $method = new \ReflectionMethod($this, static::CHECK_METHOD); |
72 | 72 | $method->setAccessible(true); |
73 | - } catch (\ReflectionException $e) { |
|
73 | + }catch (\ReflectionException $e){ |
|
74 | 74 | throw new RuleException($e->getMessage(), $e->getCode(), $e); |
75 | 75 | } |
76 | 76 | |
77 | - try { |
|
77 | + try{ |
|
78 | 78 | return $method->invokeArgs($this, $this->resolver->resolveArguments($method, $parameters)); |
79 | - } catch (\Throwable $e) { |
|
79 | + }catch (\Throwable $e){ |
|
80 | 80 | throw new RuleException(sprintf('[%s] %s', get_class($this), $e->getMessage()), $e->getCode(), $e); |
81 | 81 | } |
82 | 82 | } |
@@ -63,20 +63,27 @@ |
||
63 | 63 | $parameters = compact('actor', 'permission', 'context') + $context; |
64 | 64 | |
65 | 65 | //Mounting aliases |
66 | - foreach (static::ALIASES as $target => $alias) { |
|
66 | + foreach (static::ALIASES as $target => $alias) |
|
67 | + { |
|
67 | 68 | $parameters[$target] = $parameters[$alias]; |
68 | 69 | } |
69 | 70 | |
70 | - try { |
|
71 | + try |
|
72 | + { |
|
71 | 73 | $method = new \ReflectionMethod($this, static::CHECK_METHOD); |
72 | 74 | $method->setAccessible(true); |
73 | - } catch (\ReflectionException $e) { |
|
75 | + } |
|
76 | + catch (\ReflectionException $e) |
|
77 | + { |
|
74 | 78 | throw new RuleException($e->getMessage(), $e->getCode(), $e); |
75 | 79 | } |
76 | 80 | |
77 | - try { |
|
81 | + try |
|
82 | + { |
|
78 | 83 | return $method->invokeArgs($this, $this->resolver->resolveArguments($method, $parameters)); |
79 | - } catch (\Throwable $e) { |
|
84 | + } |
|
85 | + catch (\Throwable $e) |
|
86 | + { |
|
80 | 87 | throw new RuleException(sprintf('[%s] %s', get_class($this), $e->getMessage()), $e->getCode(), $e); |
81 | 88 | } |
82 | 89 | } |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function set(string $name, $rule = null): RuleManager |
44 | 44 | { |
45 | - if (empty($rule)) { |
|
45 | + if (empty($rule)){ |
|
46 | 46 | $rule = $name; |
47 | 47 | } |
48 | 48 | |
49 | - if (!$this->validateRule($rule)) { |
|
49 | + if (!$this->validateRule($rule)){ |
|
50 | 50 | throw new RuleException("Unable to set rule '{$name}', invalid rule body"); |
51 | 51 | } |
52 | 52 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function remove(string $name): RuleManager |
64 | 64 | { |
65 | - if (!$this->has($name)) { |
|
65 | + if (!$this->has($name)){ |
|
66 | 66 | throw new RuleException("Undefined rule '{$name}'"); |
67 | 67 | } |
68 | 68 | |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function has(string $name): bool |
78 | 78 | { |
79 | - if (isset($this->rules[$name])) { |
|
79 | + if (isset($this->rules[$name])){ |
|
80 | 80 | return true; |
81 | 81 | } |
82 | 82 | |
83 | - if (class_exists($name)) { |
|
83 | + if (class_exists($name)){ |
|
84 | 84 | //We are allowing to use class names without direct registration |
85 | 85 | return true; |
86 | 86 | } |
@@ -94,26 +94,26 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function get(string $name): RuleInterface |
96 | 96 | { |
97 | - if (!$this->has($name)) { |
|
97 | + if (!$this->has($name)){ |
|
98 | 98 | throw new RuleException("Undefined rule '{$name}'"); |
99 | 99 | } |
100 | 100 | |
101 | - if (!isset($this->rules[$name])) { |
|
101 | + if (!isset($this->rules[$name])){ |
|
102 | 102 | //Rule represented as class name |
103 | 103 | $rule = $name; |
104 | - } else { |
|
104 | + }else{ |
|
105 | 105 | $rule = $this->rules[$name]; |
106 | 106 | } |
107 | 107 | |
108 | - if ($rule instanceof RuleInterface) { |
|
108 | + if ($rule instanceof RuleInterface){ |
|
109 | 109 | return $rule; |
110 | 110 | } |
111 | 111 | |
112 | - if (is_string($rule)) { |
|
112 | + if (is_string($rule)){ |
|
113 | 113 | //We are expecting that rule points to |
114 | 114 | $rule = $this->container->get($rule); |
115 | 115 | |
116 | - if (!$rule instanceof RuleInterface) { |
|
116 | + if (!$rule instanceof RuleInterface){ |
|
117 | 117 | throw new RuleException(sprintf( |
118 | 118 | "Rule '%s' must point to RuleInterface, '%s' given", |
119 | 119 | $name, |
@@ -136,18 +136,18 @@ discard block |
||
136 | 136 | */ |
137 | 137 | private function validateRule($rule): bool |
138 | 138 | { |
139 | - if ($rule instanceof \Closure || $rule instanceof RuleInterface) { |
|
139 | + if ($rule instanceof \Closure || $rule instanceof RuleInterface){ |
|
140 | 140 | return true; |
141 | 141 | } |
142 | 142 | |
143 | - if (is_array($rule)) { |
|
143 | + if (is_array($rule)){ |
|
144 | 144 | return is_callable($rule, true); |
145 | 145 | } |
146 | 146 | |
147 | - if (is_string($rule) && class_exists($rule)) { |
|
148 | - try { |
|
147 | + if (is_string($rule) && class_exists($rule)){ |
|
148 | + try{ |
|
149 | 149 | $reflection = new \ReflectionClass($rule); |
150 | - } catch (\ReflectionException $e) { |
|
150 | + }catch (\ReflectionException $e){ |
|
151 | 151 | return false; |
152 | 152 | } |
153 | 153 |
@@ -42,11 +42,13 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function set(string $name, $rule = null): RuleManager |
44 | 44 | { |
45 | - if (empty($rule)) { |
|
45 | + if (empty($rule)) |
|
46 | + { |
|
46 | 47 | $rule = $name; |
47 | 48 | } |
48 | 49 | |
49 | - if (!$this->validateRule($rule)) { |
|
50 | + if (!$this->validateRule($rule)) |
|
51 | + { |
|
50 | 52 | throw new RuleException("Unable to set rule '{$name}', invalid rule body"); |
51 | 53 | } |
52 | 54 | |
@@ -62,7 +64,8 @@ discard block |
||
62 | 64 | */ |
63 | 65 | public function remove(string $name): RuleManager |
64 | 66 | { |
65 | - if (!$this->has($name)) { |
|
67 | + if (!$this->has($name)) |
|
68 | + { |
|
66 | 69 | throw new RuleException("Undefined rule '{$name}'"); |
67 | 70 | } |
68 | 71 | |
@@ -76,11 +79,13 @@ discard block |
||
76 | 79 | */ |
77 | 80 | public function has(string $name): bool |
78 | 81 | { |
79 | - if (isset($this->rules[$name])) { |
|
82 | + if (isset($this->rules[$name])) |
|
83 | + { |
|
80 | 84 | return true; |
81 | 85 | } |
82 | 86 | |
83 | - if (class_exists($name)) { |
|
87 | + if (class_exists($name)) |
|
88 | + { |
|
84 | 89 | //We are allowing to use class names without direct registration |
85 | 90 | return true; |
86 | 91 | } |
@@ -94,26 +99,33 @@ discard block |
||
94 | 99 | */ |
95 | 100 | public function get(string $name): RuleInterface |
96 | 101 | { |
97 | - if (!$this->has($name)) { |
|
102 | + if (!$this->has($name)) |
|
103 | + { |
|
98 | 104 | throw new RuleException("Undefined rule '{$name}'"); |
99 | 105 | } |
100 | 106 | |
101 | - if (!isset($this->rules[$name])) { |
|
107 | + if (!isset($this->rules[$name])) |
|
108 | + { |
|
102 | 109 | //Rule represented as class name |
103 | 110 | $rule = $name; |
104 | - } else { |
|
111 | + } |
|
112 | + else |
|
113 | + { |
|
105 | 114 | $rule = $this->rules[$name]; |
106 | 115 | } |
107 | 116 | |
108 | - if ($rule instanceof RuleInterface) { |
|
117 | + if ($rule instanceof RuleInterface) |
|
118 | + { |
|
109 | 119 | return $rule; |
110 | 120 | } |
111 | 121 | |
112 | - if (is_string($rule)) { |
|
122 | + if (is_string($rule)) |
|
123 | + { |
|
113 | 124 | //We are expecting that rule points to |
114 | 125 | $rule = $this->container->get($rule); |
115 | 126 | |
116 | - if (!$rule instanceof RuleInterface) { |
|
127 | + if (!$rule instanceof RuleInterface) |
|
128 | + { |
|
117 | 129 | throw new RuleException(sprintf( |
118 | 130 | "Rule '%s' must point to RuleInterface, '%s' given", |
119 | 131 | $name, |
@@ -136,18 +148,24 @@ discard block |
||
136 | 148 | */ |
137 | 149 | private function validateRule($rule): bool |
138 | 150 | { |
139 | - if ($rule instanceof \Closure || $rule instanceof RuleInterface) { |
|
151 | + if ($rule instanceof \Closure || $rule instanceof RuleInterface) |
|
152 | + { |
|
140 | 153 | return true; |
141 | 154 | } |
142 | 155 | |
143 | - if (is_array($rule)) { |
|
156 | + if (is_array($rule)) |
|
157 | + { |
|
144 | 158 | return is_callable($rule, true); |
145 | 159 | } |
146 | 160 | |
147 | - if (is_string($rule) && class_exists($rule)) { |
|
148 | - try { |
|
161 | + if (is_string($rule) && class_exists($rule)) |
|
162 | + { |
|
163 | + try |
|
164 | + { |
|
149 | 165 | $reflection = new \ReflectionClass($rule); |
150 | - } catch (\ReflectionException $e) { |
|
166 | + } |
|
167 | + catch (\ReflectionException $e) |
|
168 | + { |
|
151 | 169 | return false; |
152 | 170 | } |
153 | 171 |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | public function getGuard(): GuardInterface |
29 | 29 | { |
30 | 30 | $container = ContainerScope::getContainer(); |
31 | - if (empty($container) || !$container->has(GuardInterface::class)) { |
|
31 | + if (empty($container) || !$container->has(GuardInterface::class)){ |
|
32 | 32 | throw new ScopeException( |
33 | 33 | 'Unable to get `GuardInterface`, binding is missing or container scope is not set' |
34 | 34 | ); |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | */ |
66 | 66 | protected function resolvePermission(string $permission): string |
67 | 67 | { |
68 | - if (defined('static::GUARD_NAMESPACE')) { |
|
68 | + if (defined('static::GUARD_NAMESPACE')){ |
|
69 | 69 | // Yay! Isolation |
70 | - $permission = constant(get_called_class() . '::' . 'GUARD_NAMESPACE') . '.' . $permission; |
|
70 | + $permission = constant(get_called_class().'::'.'GUARD_NAMESPACE').'.'.$permission; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | return $permission; |
@@ -28,7 +28,8 @@ discard block |
||
28 | 28 | public function getGuard(): GuardInterface |
29 | 29 | { |
30 | 30 | $container = ContainerScope::getContainer(); |
31 | - if (empty($container) || !$container->has(GuardInterface::class)) { |
|
31 | + if (empty($container) || !$container->has(GuardInterface::class)) |
|
32 | + { |
|
32 | 33 | throw new ScopeException( |
33 | 34 | 'Unable to get `GuardInterface`, binding is missing or container scope is not set' |
34 | 35 | ); |
@@ -65,7 +66,8 @@ discard block |
||
65 | 66 | */ |
66 | 67 | protected function resolvePermission(string $permission): string |
67 | 68 | { |
68 | - if (defined('static::GUARD_NAMESPACE')) { |
|
69 | + if (defined('static::GUARD_NAMESPACE')) |
|
70 | + { |
|
69 | 71 | // Yay! Isolation |
70 | 72 | $permission = constant(get_called_class() . '::' . 'GUARD_NAMESPACE') . '.' . $permission; |
71 | 73 | } |
@@ -54,16 +54,16 @@ |
||
54 | 54 | public function allows(ActorInterface $actor, string $permission, array $context): bool |
55 | 55 | { |
56 | 56 | $allowed = 0; |
57 | - foreach (static::RULES as $rule) { |
|
57 | + foreach (static::RULES as $rule){ |
|
58 | 58 | $rule = $this->repository->get($rule); |
59 | 59 | |
60 | - if ($rule->allows($actor, $permission, $context)) { |
|
61 | - if (static::BEHAVIOUR == self::AT_LEAST_ONE) { |
|
60 | + if ($rule->allows($actor, $permission, $context)){ |
|
61 | + if (static::BEHAVIOUR == self::AT_LEAST_ONE){ |
|
62 | 62 | return true; |
63 | 63 | } |
64 | 64 | |
65 | 65 | $allowed++; |
66 | - } elseif (static::BEHAVIOUR == self::ALL) { |
|
66 | + } elseif (static::BEHAVIOUR == self::ALL){ |
|
67 | 67 | return false; |
68 | 68 | } |
69 | 69 | } |
@@ -54,16 +54,21 @@ |
||
54 | 54 | public function allows(ActorInterface $actor, string $permission, array $context): bool |
55 | 55 | { |
56 | 56 | $allowed = 0; |
57 | - foreach (static::RULES as $rule) { |
|
57 | + foreach (static::RULES as $rule) |
|
58 | + { |
|
58 | 59 | $rule = $this->repository->get($rule); |
59 | 60 | |
60 | - if ($rule->allows($actor, $permission, $context)) { |
|
61 | - if (static::BEHAVIOUR == self::AT_LEAST_ONE) { |
|
61 | + if ($rule->allows($actor, $permission, $context)) |
|
62 | + { |
|
63 | + if (static::BEHAVIOUR == self::AT_LEAST_ONE) |
|
64 | + { |
|
62 | 65 | return true; |
63 | 66 | } |
64 | 67 | |
65 | 68 | $allowed++; |
66 | - } elseif (static::BEHAVIOUR == self::ALL) { |
|
69 | + } |
|
70 | + elseif (static::BEHAVIOUR == self::ALL) |
|
71 | + { |
|
67 | 72 | return false; |
68 | 73 | } |
69 | 74 | } |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function getPage(): int |
105 | 105 | { |
106 | - if ($this->pageNumber < 1) { |
|
106 | + if ($this->pageNumber < 1){ |
|
107 | 107 | return 1; |
108 | 108 | } |
109 | 109 | |
110 | - if ($this->pageNumber > $this->countPages) { |
|
110 | + if ($this->pageNumber > $this->countPages){ |
|
111 | 111 | return $this->countPages; |
112 | 112 | } |
113 | 113 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | public function paginate(PaginableInterface $target): PaginatorInterface |
129 | 129 | { |
130 | 130 | $paginator = clone $this; |
131 | - if ($target instanceof \Countable && $paginator->count === 0) { |
|
131 | + if ($target instanceof \Countable && $paginator->count === 0){ |
|
132 | 132 | $paginator->setCount($target->count()); |
133 | 133 | } |
134 | 134 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public function countDisplayed(): int |
161 | 161 | { |
162 | - if ($this->getPage() == $this->countPages) { |
|
162 | + if ($this->getPage() == $this->countPages){ |
|
163 | 163 | return $this->count - $this->getOffset(); |
164 | 164 | } |
165 | 165 | |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function nextPage() |
181 | 181 | { |
182 | - if ($this->getPage() != $this->countPages) { |
|
182 | + if ($this->getPage() != $this->countPages){ |
|
183 | 183 | return $this->getPage() + 1; |
184 | 184 | } |
185 | 185 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function previousPage() |
193 | 193 | { |
194 | - if ($this->getPage() > 1) { |
|
194 | + if ($this->getPage() > 1){ |
|
195 | 195 | return $this->getPage() - 1; |
196 | 196 | } |
197 | 197 | |
@@ -208,9 +208,9 @@ discard block |
||
208 | 208 | private function setCount(int $count): self |
209 | 209 | { |
210 | 210 | $this->count = max($count, 0); |
211 | - if ($this->count > 0) { |
|
211 | + if ($this->count > 0){ |
|
212 | 212 | $this->countPages = (int)ceil($this->count / $this->limit); |
213 | - } else { |
|
213 | + }else{ |
|
214 | 214 | $this->countPages = 1; |
215 | 215 | } |
216 | 216 |
@@ -103,11 +103,13 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function getPage(): int |
105 | 105 | { |
106 | - if ($this->pageNumber < 1) { |
|
106 | + if ($this->pageNumber < 1) |
|
107 | + { |
|
107 | 108 | return 1; |
108 | 109 | } |
109 | 110 | |
110 | - if ($this->pageNumber > $this->countPages) { |
|
111 | + if ($this->pageNumber > $this->countPages) |
|
112 | + { |
|
111 | 113 | return $this->countPages; |
112 | 114 | } |
113 | 115 | |
@@ -128,7 +130,8 @@ discard block |
||
128 | 130 | public function paginate(PaginableInterface $target): PaginatorInterface |
129 | 131 | { |
130 | 132 | $paginator = clone $this; |
131 | - if ($target instanceof \Countable && $paginator->count === 0) { |
|
133 | + if ($target instanceof \Countable && $paginator->count === 0) |
|
134 | + { |
|
132 | 135 | $paginator->setCount($target->count()); |
133 | 136 | } |
134 | 137 | |
@@ -159,7 +162,8 @@ discard block |
||
159 | 162 | */ |
160 | 163 | public function countDisplayed(): int |
161 | 164 | { |
162 | - if ($this->getPage() == $this->countPages) { |
|
165 | + if ($this->getPage() == $this->countPages) |
|
166 | + { |
|
163 | 167 | return $this->count - $this->getOffset(); |
164 | 168 | } |
165 | 169 | |
@@ -179,7 +183,8 @@ discard block |
||
179 | 183 | */ |
180 | 184 | public function nextPage() |
181 | 185 | { |
182 | - if ($this->getPage() != $this->countPages) { |
|
186 | + if ($this->getPage() != $this->countPages) |
|
187 | + { |
|
183 | 188 | return $this->getPage() + 1; |
184 | 189 | } |
185 | 190 | |
@@ -191,7 +196,8 @@ discard block |
||
191 | 196 | */ |
192 | 197 | public function previousPage() |
193 | 198 | { |
194 | - if ($this->getPage() > 1) { |
|
199 | + if ($this->getPage() > 1) |
|
200 | + { |
|
195 | 201 | return $this->getPage() - 1; |
196 | 202 | } |
197 | 203 | |
@@ -208,9 +214,12 @@ discard block |
||
208 | 214 | private function setCount(int $count): self |
209 | 215 | { |
210 | 216 | $this->count = max($count, 0); |
211 | - if ($this->count > 0) { |
|
217 | + if ($this->count > 0) |
|
218 | + { |
|
212 | 219 | $this->countPages = (int)ceil($this->count / $this->limit); |
213 | - } else { |
|
220 | + } |
|
221 | + else |
|
222 | + { |
|
214 | 223 | $this->countPages = 1; |
215 | 224 | } |
216 | 225 |
@@ -30,6 +30,6 @@ |
||
30 | 30 | */ |
31 | 31 | protected function addIndent(string $string, int $indent = 0): string |
32 | 32 | { |
33 | - return str_repeat(self::INDENT, max($indent, 0)) . $string; |
|
33 | + return str_repeat(self::INDENT, max($indent, 0)).$string; |
|
34 | 34 | } |
35 | 35 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | public function addElement(DeclarationInterface $element): NamespaceDeclaration |
59 | 59 | { |
60 | 60 | $this->elements->add($element); |
61 | - if ($element instanceof DependedInterface) { |
|
61 | + if ($element instanceof DependedInterface){ |
|
62 | 62 | $this->addUses($element->getDependencies()); |
63 | 63 | } |
64 | 64 | |
@@ -85,23 +85,23 @@ discard block |
||
85 | 85 | $result = ''; |
86 | 86 | $indentShift = 0; |
87 | 87 | |
88 | - if (!$this->docComment->isEmpty()) { |
|
89 | - $result .= $this->docComment->render($indentLevel) . "\n"; |
|
88 | + if (!$this->docComment->isEmpty()){ |
|
89 | + $result .= $this->docComment->render($indentLevel)."\n"; |
|
90 | 90 | } |
91 | 91 | |
92 | - if (!empty($this->getName())) { |
|
93 | - $result .= $this->addIndent("namespace {$this->getName()} {", $indentLevel) . "\n"; |
|
92 | + if (!empty($this->getName())){ |
|
93 | + $result .= $this->addIndent("namespace {$this->getName()} {", $indentLevel)."\n"; |
|
94 | 94 | $indentShift = 1; |
95 | 95 | } |
96 | 96 | |
97 | - if (!empty($this->uses)) { |
|
98 | - $result .= $this->renderUses($indentLevel + $indentShift) . "\n\n"; |
|
97 | + if (!empty($this->uses)){ |
|
98 | + $result .= $this->renderUses($indentLevel + $indentShift)."\n\n"; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | $result .= $this->elements->render($indentLevel + $indentShift); |
102 | 102 | |
103 | - if (!empty($this->getName())) { |
|
104 | - $result .= "\n" . $this->addIndent('}', $indentLevel); |
|
103 | + if (!empty($this->getName())){ |
|
104 | + $result .= "\n".$this->addIndent('}', $indentLevel); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | return $result; |
@@ -58,7 +58,8 @@ discard block |
||
58 | 58 | public function addElement(DeclarationInterface $element): NamespaceDeclaration |
59 | 59 | { |
60 | 60 | $this->elements->add($element); |
61 | - if ($element instanceof DependedInterface) { |
|
61 | + if ($element instanceof DependedInterface) |
|
62 | + { |
|
62 | 63 | $this->addUses($element->getDependencies()); |
63 | 64 | } |
64 | 65 | |
@@ -85,22 +86,26 @@ discard block |
||
85 | 86 | $result = ''; |
86 | 87 | $indentShift = 0; |
87 | 88 | |
88 | - if (!$this->docComment->isEmpty()) { |
|
89 | + if (!$this->docComment->isEmpty()) |
|
90 | + { |
|
89 | 91 | $result .= $this->docComment->render($indentLevel) . "\n"; |
90 | 92 | } |
91 | 93 | |
92 | - if (!empty($this->getName())) { |
|
94 | + if (!empty($this->getName())) |
|
95 | + { |
|
93 | 96 | $result .= $this->addIndent("namespace {$this->getName()} {", $indentLevel) . "\n"; |
94 | 97 | $indentShift = 1; |
95 | 98 | } |
96 | 99 | |
97 | - if (!empty($this->uses)) { |
|
100 | + if (!empty($this->uses)) |
|
101 | + { |
|
98 | 102 | $result .= $this->renderUses($indentLevel + $indentShift) . "\n\n"; |
99 | 103 | } |
100 | 104 | |
101 | 105 | $result .= $this->elements->render($indentLevel + $indentShift); |
102 | 106 | |
103 | - if (!empty($this->getName())) { |
|
107 | + if (!empty($this->getName())) |
|
108 | + { |
|
104 | 109 | $result .= "\n" . $this->addIndent('}', $indentLevel); |
105 | 110 | } |
106 | 111 |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | public function addElement(DeclarationInterface $element): FileDeclaration |
107 | 107 | { |
108 | 108 | $this->elements->add($element); |
109 | - if ($element instanceof DependedInterface) { |
|
109 | + if ($element instanceof DependedInterface){ |
|
110 | 110 | $this->addUses($element->getDependencies()); |
111 | 111 | } |
112 | 112 | |
@@ -132,23 +132,23 @@ discard block |
||
132 | 132 | { |
133 | 133 | $result = "<?php\n"; |
134 | 134 | |
135 | - if (!$this->docComment->isEmpty()) { |
|
136 | - $result .= $this->docComment->render($indentLevel) . "\n"; |
|
135 | + if (!$this->docComment->isEmpty()){ |
|
136 | + $result .= $this->docComment->render($indentLevel)."\n"; |
|
137 | 137 | } |
138 | 138 | |
139 | - if ($this->directives !== null && !empty($this->directives->render())) { |
|
140 | - $result .= $this->directives->render() . "\n\n"; |
|
139 | + if ($this->directives !== null && !empty($this->directives->render())){ |
|
140 | + $result .= $this->directives->render()."\n\n"; |
|
141 | 141 | } |
142 | 142 | |
143 | - if (!empty($this->namespace)) { |
|
144 | - if ($this->docComment->isEmpty()) { |
|
143 | + if (!empty($this->namespace)){ |
|
144 | + if ($this->docComment->isEmpty()){ |
|
145 | 145 | $result .= "\n"; |
146 | 146 | } |
147 | 147 | $result .= "namespace {$this->namespace};\n\n"; |
148 | 148 | } |
149 | 149 | |
150 | - if (!empty($this->uses)) { |
|
151 | - $result .= $this->renderUses($indentLevel) . "\n\n"; |
|
150 | + if (!empty($this->uses)){ |
|
151 | + $result .= $this->renderUses($indentLevel)."\n\n"; |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | $result .= $this->elements->render($indentLevel); |
@@ -106,7 +106,8 @@ discard block |
||
106 | 106 | public function addElement(DeclarationInterface $element): FileDeclaration |
107 | 107 | { |
108 | 108 | $this->elements->add($element); |
109 | - if ($element instanceof DependedInterface) { |
|
109 | + if ($element instanceof DependedInterface) |
|
110 | + { |
|
110 | 111 | $this->addUses($element->getDependencies()); |
111 | 112 | } |
112 | 113 | |
@@ -132,22 +133,27 @@ discard block |
||
132 | 133 | { |
133 | 134 | $result = "<?php\n"; |
134 | 135 | |
135 | - if (!$this->docComment->isEmpty()) { |
|
136 | + if (!$this->docComment->isEmpty()) |
|
137 | + { |
|
136 | 138 | $result .= $this->docComment->render($indentLevel) . "\n"; |
137 | 139 | } |
138 | 140 | |
139 | - if ($this->directives !== null && !empty($this->directives->render())) { |
|
141 | + if ($this->directives !== null && !empty($this->directives->render())) |
|
142 | + { |
|
140 | 143 | $result .= $this->directives->render() . "\n\n"; |
141 | 144 | } |
142 | 145 | |
143 | - if (!empty($this->namespace)) { |
|
144 | - if ($this->docComment->isEmpty()) { |
|
146 | + if (!empty($this->namespace)) |
|
147 | + { |
|
148 | + if ($this->docComment->isEmpty()) |
|
149 | + { |
|
145 | 150 | $result .= "\n"; |
146 | 151 | } |
147 | 152 | $result .= "namespace {$this->namespace};\n\n"; |
148 | 153 | } |
149 | 154 | |
150 | - if (!empty($this->uses)) { |
|
155 | + if (!empty($this->uses)) |
|
156 | + { |
|
151 | 157 | $result .= $this->renderUses($indentLevel) . "\n\n"; |
152 | 158 | } |
153 | 159 |