@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | public function __construct(array $dirs = null) |
28 | 28 | { |
29 | - if($dirs) { |
|
29 | + if ($dirs) { |
|
30 | 30 | $this->searchDirs = array_merge($this->searchDirs, $dirs); |
31 | 31 | } |
32 | 32 | |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | public function leaveNode(\PhpParser\Node $node) { |
60 | 60 | |
61 | 61 | if ($node instanceof Namespace_) { |
62 | - $this->namespace = $node->name . ''; |
|
62 | + $this->namespace = $node->name.''; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | if ($node instanceof Class_) { |
66 | - $this->class = $node->name . ''; |
|
66 | + $this->class = $node->name.''; |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | public function getClass() |
76 | 76 | { |
77 | - if($this->namespace && $this->class) { |
|
77 | + if ($this->namespace && $this->class) { |
|
78 | 78 | $res = sprintf('%s\%s', $this->namespace, $this->class); |
79 | 79 | return $res; |
80 | 80 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | $class = $vis->getClass(); |
100 | 100 | |
101 | - if(is_subclass_of($class, CheckConfigInterface::class)) { |
|
101 | + if (is_subclass_of($class, CheckConfigInterface::class)) { |
|
102 | 102 | $res[] = $class; |
103 | 103 | } |
104 | 104 |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | ->setName('tvi:monitor:generator:check') |
48 | 48 | ->setDescription('Generates check plugin from tvi monitor template') |
49 | 49 | ->addArgument('name', InputArgument::REQUIRED, 'Check name') |
50 | - ->addOption('group', 'g',InputOption::VALUE_OPTIONAL, 'Check group') |
|
51 | - ->addOption('integration-test-src', null,InputOption::VALUE_OPTIONAL, 'Path to integration tests src', null) |
|
50 | + ->addOption('group', 'g', InputOption::VALUE_OPTIONAL, 'Check group') |
|
51 | + ->addOption('integration-test-src', null, InputOption::VALUE_OPTIONAL, 'Path to integration tests src', null) |
|
52 | 52 | ->addOption('no-backup', 'b', InputOption::VALUE_NONE, 'Do not backup existing check files.') |
53 | 53 | ->setHelp(<<<EOT |
54 | 54 | The <info>%command.name%</info> command generates check classes |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | @list($bundle, $checkPath) = (count($r) == 1) ? [null, current($r)] : $r; |
102 | 102 | |
103 | 103 | /* @var $bundle Bundle */ |
104 | - if(!$bundle) { |
|
104 | + if (!$bundle) { |
|
105 | 105 | $defaultBundle = 'TviMonitorBundle'; |
106 | 106 | $bundle = $this->getApplication()->getKernel()->getBundle('TviMonitorBundle'); |
107 | 107 | $output->writeln(sprintf('<info>Use default bundle <comment>%s</comment></info>', $bundle->getNamespace())); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | } |
115 | 115 | |
116 | 116 | preg_match('#^(.*?)(\w+)$#', $checkPath, $m); |
117 | - list($checkNamespace, $checkName) = [$m[1], $m[2]]; |
|
117 | + list($checkNamespace, $checkName) = [$m[1], $m[2]]; |
|
118 | 118 | |
119 | 119 | $checkNamespace = preg_replace('#\\\$#', '', $checkNamespace); |
120 | 120 | $bundleNamespace = $bundle->getNamespace(); |
@@ -138,14 +138,14 @@ discard block |
||
138 | 138 | |
139 | 139 | //CHECK_GROUP |
140 | 140 | $group = $input->getOption('group'); |
141 | - $CHECK_GROUP = $group ? $group: $CHECK_ALIAS; |
|
141 | + $CHECK_GROUP = $group ? $group : $CHECK_ALIAS; |
|
142 | 142 | |
143 | 143 | $checkPath = sprintf('%s%s%s', $bundle->getPath(), DIRECTORY_SEPARATOR, $checkPath); |
144 | 144 | $checkPath = str_replace('\\', DIRECTORY_SEPARATOR, $checkPath); |
145 | 145 | |
146 | - if(is_dir($checkPath)) { |
|
146 | + if (is_dir($checkPath)) { |
|
147 | 147 | |
148 | - if($noBackup && is_dir($checkPath)) { |
|
148 | + if ($noBackup && is_dir($checkPath)) { |
|
149 | 149 | $output->writeln(sprintf('<info><error>Check %s exist</error>. Use --no-backup flag to rewrite</info>', $NAMESPACE)); |
150 | 150 | exit(1); |
151 | 151 | } else { |
@@ -157,17 +157,17 @@ discard block |
||
157 | 157 | |
158 | 158 | foreach ($this->tpls as $f) { |
159 | 159 | |
160 | - if(in_array($f->getBasename(), ['config.example.yml.twig', 'README.mdpp.twig'])) { |
|
160 | + if (in_array($f->getBasename(), ['config.example.yml.twig', 'README.mdpp.twig'])) { |
|
161 | 161 | continue; |
162 | 162 | } |
163 | 163 | |
164 | 164 | /* @var SplFileInfo $f */ |
165 | 165 | $fName = $f->getBasename('.twig'); |
166 | 166 | |
167 | - if($fName == 'Test.php.integration') { |
|
167 | + if ($fName == 'Test.php.integration') { |
|
168 | 168 | |
169 | 169 | $testPath = $input->getOption('integration-test-src'); |
170 | - if(!$testPath) { |
|
170 | + if (!$testPath) { |
|
171 | 171 | continue; |
172 | 172 | } else { |
173 | 173 | $fName = $f->getBasename('.integration.twig'); |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | $checkName |
187 | 187 | ); |
188 | 188 | |
189 | - if(is_dir($fPath)) { |
|
190 | - if($noBackup && is_dir($fPath)) { |
|
189 | + if (is_dir($fPath)) { |
|
190 | + if ($noBackup && is_dir($fPath)) { |
|
191 | 191 | $output->writeln(sprintf('<info>Tests for <error>check %s exist</error>. Use --no-backup flag to rewrite</info>', $NAMESPACE)); |
192 | 192 | continue; |
193 | 193 | } else { |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | @mkdir($fPath, 0775, true) && !is_dir($fPath); |
198 | 198 | } |
199 | 199 | } |
200 | - $TEST_NAMESPACE = sprintf('%s\%s\%s\%s', $bundleNamespace,'Test', $checkNamespace, $checkName); |
|
200 | + $TEST_NAMESPACE = sprintf('%s\%s\%s\%s', $bundleNamespace, 'Test', $checkNamespace, $checkName); |
|
201 | 201 | |
202 | 202 | $tplData = [ |
203 | 203 | 'NAMESPACE' => $TEST_NAMESPACE, |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | $path = sprintf('%s%s%s', $fPath, DIRECTORY_SEPARATOR, $fName); |
212 | 212 | file_put_contents($path, $res); |
213 | 213 | |
214 | - $this->createFile($fPath,'config.example.yml.twig','config.yml', $tplData); |
|
214 | + $this->createFile($fPath, 'config.example.yml.twig', 'config.yml', $tplData); |
|
215 | 215 | |
216 | 216 | } else { |
217 | 217 | $path = sprintf('%s%s%s', $checkPath, DIRECTORY_SEPARATOR, $fName); |
@@ -227,8 +227,8 @@ discard block |
||
227 | 227 | |
228 | 228 | file_put_contents($path, $res); |
229 | 229 | |
230 | - $this->createFile($checkPath,'config.example.yml.twig','config.example.yml', $tplData); |
|
231 | - $this->createFile($checkPath,'README.mdpp.twig','README.mdpp', $tplData); |
|
230 | + $this->createFile($checkPath, 'config.example.yml.twig', 'config.example.yml', $tplData); |
|
231 | + $this->createFile($checkPath, 'README.mdpp.twig', 'README.mdpp', $tplData); |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | } |
@@ -245,13 +245,13 @@ discard block |
||
245 | 245 | */ |
246 | 246 | private function createFile(string $basePath, string $from, string $to, array $tplData) |
247 | 247 | { |
248 | - $r = array_filter($this->tpls, function (SplFileInfo $f) use($from) { |
|
248 | + $r = array_filter($this->tpls, function(SplFileInfo $f) use($from) { |
|
249 | 249 | return $f->getBasename() == $from; |
250 | 250 | }); |
251 | 251 | |
252 | 252 | /* @var SplFileInfo $f */ |
253 | 253 | $f = current($r); |
254 | - if($f) { |
|
254 | + if ($f) { |
|
255 | 255 | $res = $this->twig->render($f->getRelativePathname(), $tplData); |
256 | 256 | $savePath = sprintf('%s%s%s', $basePath, DIRECTORY_SEPARATOR, $to); |
257 | 257 | file_put_contents($savePath, $res); |