@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | FilesInterface $files, |
53 | 53 | DirectoriesInterface $directories |
54 | 54 | ): void { |
55 | - switch ($this->argument('type')) { |
|
55 | + switch ($this->argument('type')){ |
|
56 | 56 | case 'replace': |
57 | 57 | case 'follow': |
58 | - if ($this->isDirectory()) { |
|
58 | + if ($this->isDirectory()){ |
|
59 | 59 | $this->sprintf( |
60 | 60 | '<fg=cyan>•</fg=cyan> publish directory <comment>%s</comment> to <comment>%s</comment>', |
61 | 61 | $this->getSource($files), |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $this->getMergeMode(), |
69 | 69 | $this->getFileMode() |
70 | 70 | ); |
71 | - } else { |
|
71 | + }else{ |
|
72 | 72 | $this->sprintf( |
73 | 73 | '<fg=cyan>•</fg=cyan> publish file <comment>%s</comment> to <comment>%s</comment>', |
74 | 74 | $this->getSource($files), |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | private function getSource(FilesInterface $files): ?string |
109 | 109 | { |
110 | - if (!$this->isDirectory()) { |
|
110 | + if (!$this->isDirectory()){ |
|
111 | 111 | return $files->normalizePath($this->argument('source')); |
112 | 112 | } |
113 | 113 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | private function getTarget(FilesInterface $files, DirectoriesInterface $directories): ?string |
123 | 123 | { |
124 | 124 | $target = $this->argument('target'); |
125 | - foreach ($directories->getAll() as $alias => $value) { |
|
125 | + foreach ($directories->getAll() as $alias => $value){ |
|
126 | 126 | $target = str_replace("@{$alias}", $value, $target); |
127 | 127 | } |
128 | 128 | |
@@ -134,11 +134,11 @@ discard block |
||
134 | 134 | */ |
135 | 135 | private function isDirectory(): bool |
136 | 136 | { |
137 | - if ($this->argument('type') == 'ensure') { |
|
137 | + if ($this->argument('type') == 'ensure'){ |
|
138 | 138 | return true; |
139 | 139 | } |
140 | 140 | |
141 | - if (strpos($this->argument('source'), '*') !== false) { |
|
141 | + if (strpos($this->argument('source'), '*') !== false){ |
|
142 | 142 | return true; |
143 | 143 | } |
144 | 144 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | private function getMergeMode(): string |
152 | 152 | { |
153 | - switch ($this->argument('type')) { |
|
153 | + switch ($this->argument('type')){ |
|
154 | 154 | case 'follow': |
155 | 155 | return PublisherInterface::FOLLOW; |
156 | 156 | case 'replace': |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | private function getFileMode(): int |
167 | 167 | { |
168 | - switch ($this->argument('mode')) { |
|
168 | + switch ($this->argument('mode')){ |
|
169 | 169 | case 'readonly': |
170 | 170 | return FilesInterface::READONLY; |
171 | 171 | case 'runtime': |
@@ -52,10 +52,12 @@ discard block |
||
52 | 52 | FilesInterface $files, |
53 | 53 | DirectoriesInterface $directories |
54 | 54 | ): void { |
55 | - switch ($this->argument('type')) { |
|
55 | + switch ($this->argument('type')) |
|
56 | + { |
|
56 | 57 | case 'replace': |
57 | 58 | case 'follow': |
58 | - if ($this->isDirectory()) { |
|
59 | + if ($this->isDirectory()) |
|
60 | + { |
|
59 | 61 | $this->sprintf( |
60 | 62 | '<fg=cyan>•</fg=cyan> publish directory <comment>%s</comment> to <comment>%s</comment>', |
61 | 63 | $this->getSource($files), |
@@ -68,7 +70,9 @@ discard block |
||
68 | 70 | $this->getMergeMode(), |
69 | 71 | $this->getFileMode() |
70 | 72 | ); |
71 | - } else { |
|
73 | + } |
|
74 | + else |
|
75 | + { |
|
72 | 76 | $this->sprintf( |
73 | 77 | '<fg=cyan>•</fg=cyan> publish file <comment>%s</comment> to <comment>%s</comment>', |
74 | 78 | $this->getSource($files), |
@@ -107,7 +111,8 @@ discard block |
||
107 | 111 | */ |
108 | 112 | private function getSource(FilesInterface $files): ?string |
109 | 113 | { |
110 | - if (!$this->isDirectory()) { |
|
114 | + if (!$this->isDirectory()) |
|
115 | + { |
|
111 | 116 | return $files->normalizePath($this->argument('source')); |
112 | 117 | } |
113 | 118 | |
@@ -122,7 +127,8 @@ discard block |
||
122 | 127 | private function getTarget(FilesInterface $files, DirectoriesInterface $directories): ?string |
123 | 128 | { |
124 | 129 | $target = $this->argument('target'); |
125 | - foreach ($directories->getAll() as $alias => $value) { |
|
130 | + foreach ($directories->getAll() as $alias => $value) |
|
131 | + { |
|
126 | 132 | $target = str_replace("@{$alias}", $value, $target); |
127 | 133 | } |
128 | 134 | |
@@ -134,11 +140,13 @@ discard block |
||
134 | 140 | */ |
135 | 141 | private function isDirectory(): bool |
136 | 142 | { |
137 | - if ($this->argument('type') == 'ensure') { |
|
143 | + if ($this->argument('type') == 'ensure') |
|
144 | + { |
|
138 | 145 | return true; |
139 | 146 | } |
140 | 147 | |
141 | - if (strpos($this->argument('source'), '*') !== false) { |
|
148 | + if (strpos($this->argument('source'), '*') !== false) |
|
149 | + { |
|
142 | 150 | return true; |
143 | 151 | } |
144 | 152 | |
@@ -150,7 +158,8 @@ discard block |
||
150 | 158 | */ |
151 | 159 | private function getMergeMode(): string |
152 | 160 | { |
153 | - switch ($this->argument('type')) { |
|
161 | + switch ($this->argument('type')) |
|
162 | + { |
|
154 | 163 | case 'follow': |
155 | 164 | return PublisherInterface::FOLLOW; |
156 | 165 | case 'replace': |
@@ -165,7 +174,8 @@ discard block |
||
165 | 174 | */ |
166 | 175 | private function getFileMode(): int |
167 | 176 | { |
168 | - switch ($this->argument('mode')) { |
|
177 | + switch ($this->argument('mode')) |
|
178 | + { |
|
169 | 179 | case 'readonly': |
170 | 180 | return FilesInterface::READONLY; |
171 | 181 | case 'runtime': |
@@ -167,7 +167,7 @@ |
||
167 | 167 | { |
168 | 168 | switch ($this->argument('mode')) { |
169 | 169 | case 'readonly': |
170 | - return FilesInterface::READONLY; |
|
170 | + return FilesInterface::readonly; |
|
171 | 171 | case 'runtime': |
172 | 172 | return FilesInterface::RUNTIME; |
173 | 173 | default: |
@@ -41,17 +41,17 @@ discard block |
||
41 | 41 | string $mergeMode = self::FOLLOW, |
42 | 42 | int $mode = FilesInterface::READONLY |
43 | 43 | ): void { |
44 | - if (!$this->files->isFile($filename)) { |
|
44 | + if (!$this->files->isFile($filename)){ |
|
45 | 45 | throw new PublishException("Given '{$filename}' is not valid file"); |
46 | 46 | } |
47 | 47 | |
48 | - if ($this->files->exists($destination)) { |
|
49 | - if ($this->files->md5($destination) === $this->files->md5($filename)) { |
|
48 | + if ($this->files->exists($destination)){ |
|
49 | + if ($this->files->md5($destination) === $this->files->md5($filename)){ |
|
50 | 50 | //Nothing to do |
51 | 51 | return; |
52 | 52 | } |
53 | 53 | |
54 | - if ($mergeMode === self::FOLLOW) { |
|
54 | + if ($mergeMode === self::FOLLOW){ |
|
55 | 55 | return; |
56 | 56 | } |
57 | 57 | } |
@@ -73,17 +73,17 @@ discard block |
||
73 | 73 | string $mergeMode = self::REPLACE, |
74 | 74 | int $mode = FilesInterface::READONLY |
75 | 75 | ): void { |
76 | - if (!$this->files->isDirectory($directory)) { |
|
76 | + if (!$this->files->isDirectory($directory)){ |
|
77 | 77 | throw new PublishException("Given '{$directory}' is not valid directory"); |
78 | 78 | } |
79 | 79 | |
80 | 80 | $finder = new Finder(); |
81 | 81 | $finder->files()->in($directory); |
82 | 82 | |
83 | - foreach ($finder->getIterator() as $file) { |
|
83 | + foreach ($finder->getIterator() as $file){ |
|
84 | 84 | $this->publish( |
85 | 85 | (string)$file, |
86 | - $destination . '/' . $file->getRelativePathname(), |
|
86 | + $destination.'/'.$file->getRelativePathname(), |
|
87 | 87 | $mergeMode, |
88 | 88 | $mode |
89 | 89 | ); |
@@ -41,17 +41,21 @@ discard block |
||
41 | 41 | string $mergeMode = self::FOLLOW, |
42 | 42 | int $mode = FilesInterface::READONLY |
43 | 43 | ): void { |
44 | - if (!$this->files->isFile($filename)) { |
|
44 | + if (!$this->files->isFile($filename)) |
|
45 | + { |
|
45 | 46 | throw new PublishException("Given '{$filename}' is not valid file"); |
46 | 47 | } |
47 | 48 | |
48 | - if ($this->files->exists($destination)) { |
|
49 | - if ($this->files->md5($destination) === $this->files->md5($filename)) { |
|
49 | + if ($this->files->exists($destination)) |
|
50 | + { |
|
51 | + if ($this->files->md5($destination) === $this->files->md5($filename)) |
|
52 | + { |
|
50 | 53 | //Nothing to do |
51 | 54 | return; |
52 | 55 | } |
53 | 56 | |
54 | - if ($mergeMode === self::FOLLOW) { |
|
57 | + if ($mergeMode === self::FOLLOW) |
|
58 | + { |
|
55 | 59 | return; |
56 | 60 | } |
57 | 61 | } |
@@ -73,14 +77,16 @@ discard block |
||
73 | 77 | string $mergeMode = self::REPLACE, |
74 | 78 | int $mode = FilesInterface::READONLY |
75 | 79 | ): void { |
76 | - if (!$this->files->isDirectory($directory)) { |
|
80 | + if (!$this->files->isDirectory($directory)) |
|
81 | + { |
|
77 | 82 | throw new PublishException("Given '{$directory}' is not valid directory"); |
78 | 83 | } |
79 | 84 | |
80 | 85 | $finder = new Finder(); |
81 | 86 | $finder->files()->in($directory); |
82 | 87 | |
83 | - foreach ($finder->getIterator() as $file) { |
|
88 | + foreach ($finder->getIterator() as $file) |
|
89 | + { |
|
84 | 90 | $this->publish( |
85 | 91 | (string)$file, |
86 | 92 | $destination . '/' . $file->getRelativePathname(), |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | string $filename, |
40 | 40 | string $destination, |
41 | 41 | string $mergeMode = self::FOLLOW, |
42 | - int $mode = FilesInterface::READONLY |
|
42 | + int $mode = FilesInterface::readonly |
|
43 | 43 | ): void { |
44 | 44 | if (!$this->files->isFile($filename)) { |
45 | 45 | throw new PublishException("Given '{$filename}' is not valid file"); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | string $directory, |
72 | 72 | string $destination, |
73 | 73 | string $mergeMode = self::REPLACE, |
74 | - int $mode = FilesInterface::READONLY |
|
74 | + int $mode = FilesInterface::readonly |
|
75 | 75 | ): void { |
76 | 76 | if (!$this->files->isDirectory($directory)) { |
77 | 77 | throw new PublishException("Given '{$directory}' is not valid directory"); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | /** |
94 | 94 | * {@inheritdoc} |
95 | 95 | */ |
96 | - public function ensureDirectory(string $directory, int $mode = FilesInterface::READONLY): void |
|
96 | + public function ensureDirectory(string $directory, int $mode = FilesInterface::readonly): void |
|
97 | 97 | { |
98 | 98 | $this->files->ensureDirectory($directory, $mode); |
99 | 99 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | { |
35 | 35 | parent::__construct($config); |
36 | 36 | |
37 | - foreach ($config['authorizeTopics'] as $topic => $callback) { |
|
37 | + foreach ($config['authorizeTopics'] as $topic => $callback){ |
|
38 | 38 | $this->patterns[$this->compilePattern($topic)] = $callback; |
39 | 39 | } |
40 | 40 | } |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function findTopicCallback(string $topic, array &$matches): ?callable |
64 | 64 | { |
65 | - foreach ($this->patterns as $pattern => $callback) { |
|
66 | - if (preg_match($pattern, $topic, $matches)) { |
|
65 | + foreach ($this->patterns as $pattern => $callback){ |
|
66 | + if (preg_match($pattern, $topic, $matches)){ |
|
67 | 67 | return $callback; |
68 | 68 | } |
69 | 69 | } |
@@ -78,13 +78,13 @@ discard block |
||
78 | 78 | private function compilePattern(string $topic): string |
79 | 79 | { |
80 | 80 | $replaces = []; |
81 | - if (preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)) { |
|
81 | + if (preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)){ |
|
82 | 82 | $variables = array_combine($matches[1], $matches[2]); |
83 | - foreach ($variables as $key => $_) { |
|
84 | - $replaces['{' . $key . '}'] = '(?P<' . $key . '>[^\/\.]+)'; |
|
83 | + foreach ($variables as $key => $_){ |
|
84 | + $replaces['{'.$key.'}'] = '(?P<'.$key.'>[^\/\.]+)'; |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | - return '/^' . strtr($topic, $replaces + ['/' => '\\/', '[' => '(?:', ']' => ')?', '.' => '\.']) . '$/iu'; |
|
88 | + return '/^'.strtr($topic, $replaces + ['/' => '\\/', '[' => '(?:', ']' => ')?', '.' => '\.']).'$/iu'; |
|
89 | 89 | } |
90 | 90 | } |
@@ -34,7 +34,8 @@ discard block |
||
34 | 34 | { |
35 | 35 | parent::__construct($config); |
36 | 36 | |
37 | - foreach ($config['authorizeTopics'] as $topic => $callback) { |
|
37 | + foreach ($config['authorizeTopics'] as $topic => $callback) |
|
38 | + { |
|
38 | 39 | $this->patterns[$this->compilePattern($topic)] = $callback; |
39 | 40 | } |
40 | 41 | } |
@@ -62,8 +63,10 @@ discard block |
||
62 | 63 | */ |
63 | 64 | public function findTopicCallback(string $topic, array &$matches): ?callable |
64 | 65 | { |
65 | - foreach ($this->patterns as $pattern => $callback) { |
|
66 | - if (preg_match($pattern, $topic, $matches)) { |
|
66 | + foreach ($this->patterns as $pattern => $callback) |
|
67 | + { |
|
68 | + if (preg_match($pattern, $topic, $matches)) |
|
69 | + { |
|
67 | 70 | return $callback; |
68 | 71 | } |
69 | 72 | } |
@@ -78,9 +81,11 @@ discard block |
||
78 | 81 | private function compilePattern(string $topic): string |
79 | 82 | { |
80 | 83 | $replaces = []; |
81 | - if (preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)) { |
|
84 | + if (preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)) |
|
85 | + { |
|
82 | 86 | $variables = array_combine($matches[1], $matches[2]); |
83 | - foreach ($variables as $key => $_) { |
|
87 | + foreach ($variables as $key => $_) |
|
88 | + { |
|
84 | 89 | $replaces['{' . $key . '}'] = '(?P<' . $key . '>[^\/\.]+)'; |
85 | 90 | } |
86 | 91 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function getLocales(): array |
50 | 50 | { |
51 | - if (!is_dir($this->config->getLocalesDirectory())) { |
|
51 | + if (!is_dir($this->config->getLocalesDirectory())){ |
|
52 | 52 | return []; |
53 | 53 | } |
54 | 54 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | $locales = []; |
59 | 59 | |
60 | - foreach ($finder->directories() as $directory) { |
|
60 | + foreach ($finder->directories() as $directory){ |
|
61 | 61 | $locales[] = $directory->getFilename(); |
62 | 62 | } |
63 | 63 | |
@@ -72,14 +72,14 @@ discard block |
||
72 | 72 | $locale = preg_replace('/[^a-zA-Z_]/', '', mb_strtolower($locale)); |
73 | 73 | $catalogue = new Catalogue($locale); |
74 | 74 | |
75 | - if (!$this->hasLocale($locale)) { |
|
75 | + if (!$this->hasLocale($locale)){ |
|
76 | 76 | return $catalogue; |
77 | 77 | } |
78 | 78 | |
79 | 79 | $finder = new Finder(); |
80 | 80 | $finder->in($this->config->getLocaleDirectory($locale)); |
81 | 81 | |
82 | - foreach ($finder->getIterator() as $file) { |
|
82 | + foreach ($finder->getIterator() as $file){ |
|
83 | 83 | $this->getLogger()->info( |
84 | 84 | sprintf( |
85 | 85 | "found locale domain file '%s'", |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | //Per application agreement domain name must present in filename |
92 | 92 | $domain = strstr($file->getFilename(), '.', true); |
93 | 93 | |
94 | - if (!$this->config->hasLoader($file->getExtension())) { |
|
94 | + if (!$this->config->hasLoader($file->getExtension())){ |
|
95 | 95 | $this->getLogger()->warning( |
96 | 96 | sprintf( |
97 | 97 | "unable to load domain file '%s', no loader found", |
@@ -48,7 +48,8 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function getLocales(): array |
50 | 50 | { |
51 | - if (!is_dir($this->config->getLocalesDirectory())) { |
|
51 | + if (!is_dir($this->config->getLocalesDirectory())) |
|
52 | + { |
|
52 | 53 | return []; |
53 | 54 | } |
54 | 55 | |
@@ -57,7 +58,8 @@ discard block |
||
57 | 58 | |
58 | 59 | $locales = []; |
59 | 60 | |
60 | - foreach ($finder->directories() as $directory) { |
|
61 | + foreach ($finder->directories() as $directory) |
|
62 | + { |
|
61 | 63 | $locales[] = $directory->getFilename(); |
62 | 64 | } |
63 | 65 | |
@@ -72,14 +74,16 @@ discard block |
||
72 | 74 | $locale = preg_replace('/[^a-zA-Z_]/', '', mb_strtolower($locale)); |
73 | 75 | $catalogue = new Catalogue($locale); |
74 | 76 | |
75 | - if (!$this->hasLocale($locale)) { |
|
77 | + if (!$this->hasLocale($locale)) |
|
78 | + { |
|
76 | 79 | return $catalogue; |
77 | 80 | } |
78 | 81 | |
79 | 82 | $finder = new Finder(); |
80 | 83 | $finder->in($this->config->getLocaleDirectory($locale)); |
81 | 84 | |
82 | - foreach ($finder->getIterator() as $file) { |
|
85 | + foreach ($finder->getIterator() as $file) |
|
86 | + { |
|
83 | 87 | $this->getLogger()->info( |
84 | 88 | sprintf( |
85 | 89 | "found locale domain file '%s'", |
@@ -91,7 +95,8 @@ discard block |
||
91 | 95 | //Per application agreement domain name must present in filename |
92 | 96 | $domain = strstr($file->getFilename(), '.', true); |
93 | 97 | |
94 | - if (!$this->config->hasLoader($file->getExtension())) { |
|
98 | + if (!$this->config->hasLoader($file->getExtension())) |
|
99 | + { |
|
95 | 100 | $this->getLogger()->warning( |
96 | 101 | sprintf( |
97 | 102 | "unable to load domain file '%s', no loader found", |
@@ -31,7 +31,8 @@ discard block |
||
31 | 31 | */ |
32 | 32 | protected function iterableToArray(iterable $iterable): array |
33 | 33 | { |
34 | - if ($iterable instanceof \Traversable) { |
|
34 | + if ($iterable instanceof \Traversable) |
|
35 | + { |
|
35 | 36 | return \iterator_to_array($iterable, false); |
36 | 37 | } |
37 | 38 | |
@@ -47,7 +48,8 @@ discard block |
||
47 | 48 | { |
48 | 49 | $instance = new $class(); |
49 | 50 | |
50 | - foreach ($fields as $field => $value) { |
|
51 | + foreach ($fields as $field => $value) |
|
52 | + { |
|
51 | 53 | $instance->$field = $value; |
52 | 54 | } |
53 | 55 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | protected function iterableToArray(iterable $iterable): array |
26 | 26 | { |
27 | - if ($iterable instanceof \Traversable) { |
|
27 | + if ($iterable instanceof \Traversable){ |
|
28 | 28 | return \iterator_to_array($iterable, false); |
29 | 29 | } |
30 | 30 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | { |
50 | 50 | $instance = new $class(); |
51 | 51 | |
52 | - foreach ($fields as $field => $value) { |
|
52 | + foreach ($fields as $field => $value){ |
|
53 | 53 | $instance->$field = $value; |
54 | 54 | } |
55 | 55 |
@@ -43,13 +43,13 @@ discard block |
||
43 | 43 | ->getReflectionConstants() |
44 | 44 | ; |
45 | 45 | |
46 | - foreach ($constants as $reflection) { |
|
47 | - if ($reflection->getName() === $name) { |
|
46 | + foreach ($constants as $reflection){ |
|
47 | + if ($reflection->getName() === $name){ |
|
48 | 48 | return $reflection; |
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | - throw new \ReflectionException('Constant ' . $name . ' not found'); |
|
52 | + throw new \ReflectionException('Constant '.$name.' not found'); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | protected function getReflectionFunctionParameter(string $function, string $name): \ReflectionParameter |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | ->getParameters() |
59 | 59 | ; |
60 | 60 | |
61 | - foreach ($parameters as $reflection) { |
|
62 | - if ($reflection->getName() === $name) { |
|
61 | + foreach ($parameters as $reflection){ |
|
62 | + if ($reflection->getName() === $name){ |
|
63 | 63 | return $reflection; |
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | - throw new \ReflectionException('Parameter ' . $name . ' not found'); |
|
67 | + throw new \ReflectionException('Parameter '.$name.' not found'); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | protected function getReflectionMethodParameter(string $class, string $method, string $name): \ReflectionParameter |
@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | ->getParameters() |
74 | 74 | ; |
75 | 75 | |
76 | - foreach ($parameters as $reflection) { |
|
77 | - if ($reflection->getName() === $name) { |
|
76 | + foreach ($parameters as $reflection){ |
|
77 | + if ($reflection->getName() === $name){ |
|
78 | 78 | return $reflection; |
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
82 | - throw new \ReflectionException('Parameter ' . $name . ' not found'); |
|
82 | + throw new \ReflectionException('Parameter '.$name.' not found'); |
|
83 | 83 | } |
84 | 84 | } |
@@ -43,8 +43,10 @@ discard block |
||
43 | 43 | ->getReflectionConstants() |
44 | 44 | ; |
45 | 45 | |
46 | - foreach ($constants as $reflection) { |
|
47 | - if ($reflection->getName() === $name) { |
|
46 | + foreach ($constants as $reflection) |
|
47 | + { |
|
48 | + if ($reflection->getName() === $name) |
|
49 | + { |
|
48 | 50 | return $reflection; |
49 | 51 | } |
50 | 52 | } |
@@ -58,8 +60,10 @@ discard block |
||
58 | 60 | ->getParameters() |
59 | 61 | ; |
60 | 62 | |
61 | - foreach ($parameters as $reflection) { |
|
62 | - if ($reflection->getName() === $name) { |
|
63 | + foreach ($parameters as $reflection) |
|
64 | + { |
|
65 | + if ($reflection->getName() === $name) |
|
66 | + { |
|
63 | 67 | return $reflection; |
64 | 68 | } |
65 | 69 | } |
@@ -73,8 +77,10 @@ discard block |
||
73 | 77 | ->getParameters() |
74 | 78 | ; |
75 | 79 | |
76 | - foreach ($parameters as $reflection) { |
|
77 | - if ($reflection->getName() === $name) { |
|
80 | + foreach ($parameters as $reflection) |
|
81 | + { |
|
82 | + if ($reflection->getName() === $name) |
|
83 | + { |
|
78 | 84 | return $reflection; |
79 | 85 | } |
80 | 86 | } |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | */ |
22 | 22 | function hasKey(array $array, $search): bool |
23 | 23 | { |
24 | - foreach ($array as $key => $_) { |
|
25 | - if (equals($key, $search)) { |
|
24 | + foreach ($array as $key => $_){ |
|
25 | + if (equals($key, $search)){ |
|
26 | 26 | return true; |
27 | 27 | } |
28 | 28 | } |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | */ |
38 | 38 | function hasValue(array $array, $search): bool |
39 | 39 | { |
40 | - foreach ($array as $value) { |
|
41 | - if (equals($value, $search)) { |
|
40 | + foreach ($array as $value){ |
|
41 | + if (equals($value, $search)){ |
|
42 | 42 | return true; |
43 | 43 | } |
44 | 44 | } |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | */ |
57 | 57 | function getValue(array $array, string $search) |
58 | 58 | { |
59 | - foreach ($array as $key => $value) { |
|
60 | - if (equals($key, $search)) { |
|
59 | + foreach ($array as $key => $value){ |
|
60 | + if (equals($key, $search)){ |
|
61 | 61 | return $value; |
62 | 62 | } |
63 | 63 | } |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | */ |
74 | 74 | function equals($value1, $value2): bool |
75 | 75 | { |
76 | - if (is_string($value1) && is_string($value2) && strcasecmp($value1, $value2) === 0) { |
|
76 | + if (is_string($value1) && is_string($value2) && strcasecmp($value1, $value2) === 0){ |
|
77 | 77 | return true; |
78 | 78 | } |
79 | 79 | |
80 | - if (is_numeric($value1) && is_numeric($value2) && strcasecmp((string)$value1, (string)$value2) === 0) { |
|
80 | + if (is_numeric($value1) && is_numeric($value2) && strcasecmp((string)$value1, (string)$value2) === 0){ |
|
81 | 81 | return true; |
82 | 82 | } |
83 | 83 |
@@ -21,8 +21,10 @@ discard block |
||
21 | 21 | */ |
22 | 22 | function hasKey(array $array, $search): bool |
23 | 23 | { |
24 | - foreach ($array as $key => $_) { |
|
25 | - if (equals($key, $search)) { |
|
24 | + foreach ($array as $key => $_) |
|
25 | + { |
|
26 | + if (equals($key, $search)) |
|
27 | + { |
|
26 | 28 | return true; |
27 | 29 | } |
28 | 30 | } |
@@ -37,8 +39,10 @@ discard block |
||
37 | 39 | */ |
38 | 40 | function hasValue(array $array, $search): bool |
39 | 41 | { |
40 | - foreach ($array as $value) { |
|
41 | - if (equals($value, $search)) { |
|
42 | + foreach ($array as $value) |
|
43 | + { |
|
44 | + if (equals($value, $search)) |
|
45 | + { |
|
42 | 46 | return true; |
43 | 47 | } |
44 | 48 | } |
@@ -56,8 +60,10 @@ discard block |
||
56 | 60 | */ |
57 | 61 | function getValue(array $array, string $search) |
58 | 62 | { |
59 | - foreach ($array as $key => $value) { |
|
60 | - if (equals($key, $search)) { |
|
63 | + foreach ($array as $key => $value) |
|
64 | + { |
|
65 | + if (equals($key, $search)) |
|
66 | + { |
|
61 | 67 | return $value; |
62 | 68 | } |
63 | 69 | } |
@@ -73,11 +79,13 @@ discard block |
||
73 | 79 | */ |
74 | 80 | function equals($value1, $value2): bool |
75 | 81 | { |
76 | - if (is_string($value1) && is_string($value2) && strcasecmp($value1, $value2) === 0) { |
|
82 | + if (is_string($value1) && is_string($value2) && strcasecmp($value1, $value2) === 0) |
|
83 | + { |
|
77 | 84 | return true; |
78 | 85 | } |
79 | 86 | |
80 | - if (is_numeric($value1) && is_numeric($value2) && strcasecmp((string)$value1, (string)$value2) === 0) { |
|
87 | + if (is_numeric($value1) && is_numeric($value2) && strcasecmp((string)$value1, (string)$value2) === 0) |
|
88 | + { |
|
81 | 89 | return true; |
82 | 90 | } |
83 | 91 |
@@ -11,7 +11,8 @@ discard block |
||
11 | 11 | |
12 | 12 | namespace Spiral\Scaffolder; |
13 | 13 | |
14 | -if (!function_exists('trimPostfix')) { |
|
14 | +if (!function_exists('trimPostfix')) |
|
15 | +{ |
|
15 | 16 | /** |
16 | 17 | * @param string $name |
17 | 18 | * @param string $postfix |
@@ -26,7 +27,8 @@ discard block |
||
26 | 27 | } |
27 | 28 | } |
28 | 29 | |
29 | -if (!function_exists('isAssociativeArray')) { |
|
30 | +if (!function_exists('isAssociativeArray')) |
|
31 | +{ |
|
30 | 32 | /** |
31 | 33 | * @param array $array |
32 | 34 | * @return bool |
@@ -35,12 +37,15 @@ discard block |
||
35 | 37 | function isAssociativeArray(array $array): bool |
36 | 38 | { |
37 | 39 | $keys = []; |
38 | - foreach ($array as $key => $_) { |
|
39 | - if (!is_int($key)) { |
|
40 | + foreach ($array as $key => $_) |
|
41 | + { |
|
42 | + if (!is_int($key)) |
|
43 | + { |
|
40 | 44 | return true; |
41 | 45 | } |
42 | 46 | |
43 | - if ($key !== count($keys)) { |
|
47 | + if ($key !== count($keys)) |
|
48 | + { |
|
44 | 49 | return true; |
45 | 50 | } |
46 | 51 | |
@@ -51,7 +56,8 @@ discard block |
||
51 | 56 | } |
52 | 57 | } |
53 | 58 | |
54 | -if (!function_exists('defineArrayType')) { |
|
59 | +if (!function_exists('defineArrayType')) |
|
60 | +{ |
|
55 | 61 | /** |
56 | 62 | * @param array $array |
57 | 63 | * @param string|null $failureType |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | namespace Spiral\Scaffolder; |
13 | 13 | |
14 | -if (!function_exists('trimPostfix')) { |
|
14 | +if (!function_exists('trimPostfix')){ |
|
15 | 15 | /** |
16 | 16 | * @param string $name |
17 | 17 | * @param string $postfix |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | -if (!function_exists('isAssociativeArray')) { |
|
29 | +if (!function_exists('isAssociativeArray')){ |
|
30 | 30 | /** |
31 | 31 | * @param array $array |
32 | 32 | * @return bool |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | function isAssociativeArray(array $array): bool |
36 | 36 | { |
37 | 37 | $keys = []; |
38 | - foreach ($array as $key => $_) { |
|
39 | - if (!is_int($key)) { |
|
38 | + foreach ($array as $key => $_){ |
|
39 | + if (!is_int($key)){ |
|
40 | 40 | return true; |
41 | 41 | } |
42 | 42 | |
43 | - if ($key !== count($keys)) { |
|
43 | + if ($key !== count($keys)){ |
|
44 | 44 | return true; |
45 | 45 | } |
46 | 46 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | -if (!function_exists('defineArrayType')) { |
|
54 | +if (!function_exists('defineArrayType')){ |
|
55 | 55 | /** |
56 | 56 | * @param array $array |
57 | 57 | * @param string|null $failureType |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | function defineArrayType(array $array, string $failureType = null): ?string |
62 | 62 | { |
63 | - $types = array_map(static fn ($value): string => gettype($value), $array); |
|
63 | + $types = array_map(static fn ($value) : string => gettype($value), $array); |
|
64 | 64 | |
65 | 65 | $types = array_unique($types); |
66 | 66 |
@@ -18,7 +18,7 @@ |
||
18 | 18 | */ |
19 | 19 | protected function each(callable $resolver): iterable |
20 | 20 | { |
21 | - foreach ($this->readers as $reader) { |
|
21 | + foreach ($this->readers as $reader){ |
|
22 | 22 | yield from $resolver($reader); |
23 | 23 | } |
24 | 24 | } |
@@ -18,7 +18,8 @@ |
||
18 | 18 | */ |
19 | 19 | protected function each(callable $resolver): iterable |
20 | 20 | { |
21 | - foreach ($this->readers as $reader) { |
|
21 | + foreach ($this->readers as $reader) |
|
22 | + { |
|
22 | 23 | yield from $resolver($reader); |
23 | 24 | } |
24 | 25 | } |