@@ -169,7 +169,7 @@ |
||
| 169 | 169 | |
| 170 | 170 | $fPath = sprintf('%s%s%s%s%s%s%s%s%s', |
| 171 | 171 | $bundle->getPath(), |
| 172 | - DIRECTORY_SEPARATOR, |
|
| 172 | + DIRECTORY_SEPARATOR, |
|
| 173 | 173 | $testPath, |
| 174 | 174 | DIRECTORY_SEPARATOR, |
| 175 | 175 | 'Test', |
@@ -33,8 +33,8 @@ discard block |
||
| 33 | 33 | ->setName('tvi:monitor:generator:check') |
| 34 | 34 | ->setDescription('Generates check plugin from tvi monitor template') |
| 35 | 35 | ->addArgument('name', InputArgument::REQUIRED, 'Check name') |
| 36 | - ->addOption('group', 'g',InputOption::VALUE_OPTIONAL, 'Check group') |
|
| 37 | - ->addOption('integration-test-src', null,InputOption::VALUE_OPTIONAL, 'Path to integration tests src', null) |
|
| 36 | + ->addOption('group', 'g', InputOption::VALUE_OPTIONAL, 'Check group') |
|
| 37 | + ->addOption('integration-test-src', null, InputOption::VALUE_OPTIONAL, 'Path to integration tests src', null) |
|
| 38 | 38 | ->addOption('no-backup', 'b', InputOption::VALUE_NONE, 'Do not backup existing check files.') |
| 39 | 39 | ->setHelp(<<<EOT |
| 40 | 40 | The <info>%command.name%</info> command generates check classes |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | @list($bundle, $checkPath) = (count($r) == 1) ? [null, current($r)] : $r; |
| 93 | 93 | |
| 94 | 94 | /* @var $bundle Bundle */ |
| 95 | - if(!$bundle) { |
|
| 95 | + if (!$bundle) { |
|
| 96 | 96 | $defaultBundle = 'TviMonitorBundle'; |
| 97 | 97 | $bundle = $this->getApplication()->getKernel()->getBundle('TviMonitorBundle'); |
| 98 | 98 | $output->writeln(sprintf('<info>Use default bundle <comment>%s</comment></info>', $bundle->getNamespace())); |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | preg_match('#^(.*?)(\w+)$#', $checkPath, $m); |
| 108 | - list($checkNamespace, $checkName) = [$m[1], $m[2]]; |
|
| 108 | + list($checkNamespace, $checkName) = [$m[1], $m[2]]; |
|
| 109 | 109 | |
| 110 | 110 | $checkNamespace = preg_replace('#\\\$#', '', $checkNamespace); |
| 111 | 111 | $bundleNamespace = $bundle->getNamespace(); |
@@ -124,16 +124,16 @@ discard block |
||
| 124 | 124 | $CHECK_ALIAS = strtolower($CHECK_ALIAS); |
| 125 | 125 | |
| 126 | 126 | $group = $input->getOption('group'); |
| 127 | - $CHECK_GROUP = $group ? $group: $CHECK_ALIAS; |
|
| 127 | + $CHECK_GROUP = $group ? $group : $CHECK_ALIAS; |
|
| 128 | 128 | |
| 129 | 129 | $checkPath = sprintf('%s%s%s', $bundle->getPath(), DIRECTORY_SEPARATOR, $checkPath); |
| 130 | 130 | $checkPath = str_replace('\\', DIRECTORY_SEPARATOR, $checkPath); |
| 131 | 131 | |
| 132 | 132 | $noBackup = !$input->getOption('no-backup'); |
| 133 | 133 | |
| 134 | - if(is_dir($checkPath)) { |
|
| 134 | + if (is_dir($checkPath)) { |
|
| 135 | 135 | |
| 136 | - if($noBackup && is_dir($checkPath)) { |
|
| 136 | + if ($noBackup && is_dir($checkPath)) { |
|
| 137 | 137 | $output->writeln(sprintf('<info><error>Check %s exist</error>. Use --no-backup flag to rewrite</info>', $NAMESPACE)); |
| 138 | 138 | exit(1); |
| 139 | 139 | } else { |
@@ -145,17 +145,17 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | foreach ($this->tpls as $f) { |
| 147 | 147 | |
| 148 | - if(in_array($f->getBasename(), ['config.example.yml.twig', 'README.mdpp.twig'])) { |
|
| 148 | + if (in_array($f->getBasename(), ['config.example.yml.twig', 'README.mdpp.twig'])) { |
|
| 149 | 149 | continue; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /* @var SplFileInfo $f */ |
| 153 | 153 | $fName = $f->getBasename('.twig'); |
| 154 | 154 | |
| 155 | - if($fName == 'Test.php.integration') { |
|
| 155 | + if ($fName == 'Test.php.integration') { |
|
| 156 | 156 | |
| 157 | 157 | $testPath = $input->getOption('integration-test-src'); |
| 158 | - if(!$testPath) { |
|
| 158 | + if (!$testPath) { |
|
| 159 | 159 | continue; |
| 160 | 160 | } else { |
| 161 | 161 | $fName = $f->getBasename('.integration.twig'); |
@@ -174,8 +174,8 @@ discard block |
||
| 174 | 174 | $checkName |
| 175 | 175 | ); |
| 176 | 176 | |
| 177 | - if(is_dir($fPath)) { |
|
| 178 | - if($noBackup && is_dir($fPath)) { |
|
| 177 | + if (is_dir($fPath)) { |
|
| 178 | + if ($noBackup && is_dir($fPath)) { |
|
| 179 | 179 | $output->writeln(sprintf('<info>Tests for <error>check %s exist</error>. Use --no-backup flag to rewrite</info>', $NAMESPACE)); |
| 180 | 180 | continue; |
| 181 | 181 | } else { |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | @mkdir($fPath, 0775, true) && !is_dir($fPath); |
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | - $TEST_NAMESPACE = sprintf('%s\%s\%s\%s', $bundleNamespace,'Test', $checkNamespace, $checkName); |
|
| 188 | + $TEST_NAMESPACE = sprintf('%s\%s\%s\%s', $bundleNamespace, 'Test', $checkNamespace, $checkName); |
|
| 189 | 189 | |
| 190 | 190 | $tplData = [ |
| 191 | 191 | 'NAMESPACE' => $TEST_NAMESPACE, |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | $path = sprintf('%s%s%s', $fPath, DIRECTORY_SEPARATOR, $fName); |
| 200 | 200 | file_put_contents($path, $res); |
| 201 | 201 | |
| 202 | - $this->createFile($fPath,'config.example.yml.twig','config.yml', $tplData); |
|
| 202 | + $this->createFile($fPath, 'config.example.yml.twig', 'config.yml', $tplData); |
|
| 203 | 203 | |
| 204 | 204 | } else { |
| 205 | 205 | $path = sprintf('%s%s%s', $checkPath, DIRECTORY_SEPARATOR, $fName); |
@@ -215,21 +215,21 @@ discard block |
||
| 215 | 215 | |
| 216 | 216 | file_put_contents($path, $res); |
| 217 | 217 | |
| 218 | - $this->createFile($checkPath,'config.example.yml.twig','config.example.yml', $tplData); |
|
| 219 | - $this->createFile($checkPath,'README.mdpp.twig','README.mdpp', $tplData); |
|
| 218 | + $this->createFile($checkPath, 'config.example.yml.twig', 'config.example.yml', $tplData); |
|
| 219 | + $this->createFile($checkPath, 'README.mdpp.twig', 'README.mdpp', $tplData); |
|
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | private function createFile($basePath, $from, $to, $data) |
| 225 | 225 | { |
| 226 | - $r = array_filter($this->tpls, function (SplFileInfo $f) use($from) { |
|
| 226 | + $r = array_filter($this->tpls, function(SplFileInfo $f) use($from) { |
|
| 227 | 227 | return $f->getBasename() == $from; |
| 228 | 228 | }); |
| 229 | 229 | |
| 230 | 230 | /* @var SplFileInfo $f */ |
| 231 | 231 | $f = current($r); |
| 232 | - if($f) { |
|
| 232 | + if ($f) { |
|
| 233 | 233 | $res = $this->twig->render($f->getRelativePathname(), $data); |
| 234 | 234 | $savePath = sprintf('%s%s%s', $basePath, DIRECTORY_SEPARATOR, $to); |
| 235 | 235 | file_put_contents($savePath, $res); |