@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | foreach ($checkServiceMap as $checkId => $check) { |
49 | 49 | |
50 | 50 | $checkServiceId = $check['serviceId']; |
51 | - $checkProxy = new Proxy(function () use ($checkServiceId, $checkId) { |
|
51 | + $checkProxy = new Proxy(function() use ($checkServiceId, $checkId) { |
|
52 | 52 | $this->checks[$checkId] = $this->container->get($checkServiceId); |
53 | 53 | |
54 | 54 | return $this->checks[$checkId]; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | $groups = is_string($groups) ? [$groups] : $groups; |
97 | 97 | |
98 | - return array_filter($this->groups, function ($t) use ($groups) { |
|
98 | + return array_filter($this->groups, function($t) use ($groups) { |
|
99 | 99 | return in_array($t->getName(), $groups); |
100 | 100 | }); |
101 | 101 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | $tags = is_string($tags) ? [$tags] : $tags; |
126 | 126 | |
127 | - return array_filter($this->tags, function ($t) use ($tags) { |
|
127 | + return array_filter($this->tags, function($t) use ($tags) { |
|
128 | 128 | return in_array($t->getName(), $tags); |
129 | 129 | }); |
130 | 130 | } |
@@ -85,19 +85,19 @@ |
||
85 | 85 | */ |
86 | 86 | public function setAdditionParams(array $data) |
87 | 87 | { |
88 | - if(isset($data['id'])) { |
|
88 | + if (isset($data['id'])) { |
|
89 | 89 | $this->setId($data['id']); |
90 | 90 | } |
91 | 91 | |
92 | - if(isset($data['group'])) { |
|
92 | + if (isset($data['group'])) { |
|
93 | 93 | $this->setGroup($data['group']); |
94 | 94 | } |
95 | 95 | |
96 | - if(isset($data['tags'])) { |
|
96 | + if (isset($data['tags'])) { |
|
97 | 97 | $this->setTags($data['tags']); |
98 | 98 | } |
99 | 99 | |
100 | - if(isset($data['label'])) { |
|
100 | + if (isset($data['label'])) { |
|
101 | 101 | $this->/** @scrutinizer ignore-call */setLabel($data['label']); |
102 | 102 | } |
103 | 103 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function offsetGet($offset) |
36 | 36 | { |
37 | - if($this->checks[$offset] instanceof Proxy) { |
|
37 | + if ($this->checks[$offset] instanceof Proxy) { |
|
38 | 38 | $this->checks[$offset] = $this->checks[$offset](); |
39 | 39 | } |
40 | 40 | return $this->checks[$offset]; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function valid() |
92 | 92 | { |
93 | - return (boolean)key($this->checks); |
|
93 | + return (boolean) key($this->checks); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function toArray() |
108 | 108 | { |
109 | - $out = []; |
|
109 | + $out = []; |
|
110 | 110 | foreach ($this as $k => $v) { |
111 | 111 | $out[$k] = $v; |
112 | 112 | } |
@@ -29,7 +29,7 @@ |
||
29 | 29 | $checkDefinition = clone $checkDefinitionTpl; |
30 | 30 | |
31 | 31 | if ($name) { |
32 | - $checkServiceAlias .= '.' . $name; |
|
32 | + $checkServiceAlias .= '.'.$name; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | foreach ($checkDefinition->getArguments() as $argumentIndex => $argument) { |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | //$loader->load('controller.yml'); |
41 | 41 | //$loader->load('telega.yml'); |
42 | 42 | |
43 | - $checksSearchPaths = isset($configs[1]['checks_search_paths'])?$configs[1]['checks_search_paths']:[]; |
|
43 | + $checksSearchPaths = isset($configs[1]['checks_search_paths']) ? $configs[1]['checks_search_paths'] : []; |
|
44 | 44 | unset($configs[1]['checks_search_paths']); |
45 | 45 | |
46 | 46 | $configuration = new Configuration($checksSearchPaths); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | if (isset($config['checks'])) { |
75 | 75 | |
76 | - $config['checks'] = array_filter($config['checks'], function ($i) {return $i;}); |
|
76 | + $config['checks'] = array_filter($config['checks'], function($i) {return $i; }); |
|
77 | 77 | |
78 | 78 | $containerParams = []; |
79 | 79 | $checksLoaded = []; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $checkMatadata = $checkMatadatas[$checkName]; |
85 | 85 | $service = $checkMatadata['service']; |
86 | 86 | |
87 | - $path = $checkMatadata['path']. DIRECTORY_SEPARATOR . $checkMatadata['conf']; |
|
87 | + $path = $checkMatadata['path'].DIRECTORY_SEPARATOR.$checkMatadata['conf']; |
|
88 | 88 | |
89 | 89 | if (!in_array($path, $checksLoaded)) { |
90 | 90 | |
@@ -92,14 +92,14 @@ discard block |
||
92 | 92 | $checksLoaded[] = $path; |
93 | 93 | } |
94 | 94 | |
95 | - if(isset($checkSettings['items'])) { |
|
95 | + if (isset($checkSettings['items'])) { |
|
96 | 96 | |
97 | 97 | $items = $checkSettings['items']; |
98 | 98 | |
99 | 99 | foreach ($items as $itemName => &$item) { |
100 | 100 | $item['tags'] = array_unique(array_merge($item['tags'], $checkSettings['tags'])); |
101 | 101 | |
102 | - if($item['label'] == null && $checkSettings['label'] != null) { |
|
102 | + if ($item['label'] == null && $checkSettings['label'] != null) { |
|
103 | 103 | $label = $checkSettings['label']; |
104 | 104 | $label = sprintf($label, $itemName); |
105 | 105 | $item['label'] = $label; |
@@ -56,8 +56,8 @@ |
||
56 | 56 | ]; |
57 | 57 | |
58 | 58 | $data = $result->getData(); |
59 | - if($data !== null) { |
|
60 | - if($data instanceof \Exception) { |
|
59 | + if ($data !== null) { |
|
60 | + if ($data instanceof \Exception) { |
|
61 | 61 | $res['data'] = $data->getMessage(); |
62 | 62 | } else { |
63 | 63 | $res['data'] = $data; |
@@ -79,10 +79,10 @@ |
||
79 | 79 | $message = $result->getMessage(); |
80 | 80 | if ($message) { |
81 | 81 | $data = $result->getData(); |
82 | - if($data !== null) { |
|
82 | + if ($data !== null) { |
|
83 | 83 | $dataOut = json_encode($data); |
84 | 84 | |
85 | - if(strlen($dataOut) > 100) { |
|
85 | + if (strlen($dataOut) > 100) { |
|
86 | 86 | $dataOut .= "\n"; |
87 | 87 | } |
88 | 88 | } |
@@ -91,10 +91,10 @@ |
||
91 | 91 | $node = $builder |
92 | 92 | ->root('checks', 'array') |
93 | 93 | ->beforeNormalization() |
94 | - ->always(function ($value) { |
|
94 | + ->always(function($value) { |
|
95 | 95 | foreach ($value as $k=>$v) { |
96 | 96 | $newK = str_replace('(s)', '_factory', $k); |
97 | - if($newK != $k) { |
|
97 | + if ($newK != $k) { |
|
98 | 98 | $value[$newK] = $value[$k]; |
99 | 99 | unset($value[$k]); |
100 | 100 | } |
@@ -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', |
@@ -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($bundleName, $checkPath) = (count($r) == 1) ? [null, current($r)] : $r; |
102 | 102 | |
103 | 103 | /* @var $bundle Bundle */ |
104 | - if(!$bundleName) { |
|
104 | + if (!$bundleName) { |
|
105 | 105 | $defaultBundle = 'TviMonitorBundle'; |
106 | 106 | $bundle = $this->getApplication()->getKernel()->getBundle($defaultBundle); |
107 | 107 | $output->writeln(sprintf('<info>Use default bundle <comment>%s</comment></info>', $bundle->getNamespace())); |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | preg_match('#^(.*?)(\w+)$#', $checkPath, $m); |
118 | - list($checkNamespace, $checkName) = [$m[1], $m[2]]; |
|
118 | + list($checkNamespace, $checkName) = [$m[1], $m[2]]; |
|
119 | 119 | |
120 | 120 | $checkNamespace = preg_replace('#\\\$#', '', $checkNamespace); |
121 | 121 | $bundleNamespace = $bundle->getNamespace(); |
@@ -139,14 +139,14 @@ discard block |
||
139 | 139 | |
140 | 140 | //CHECK_GROUP |
141 | 141 | $group = $input->getOption('group'); |
142 | - $CHECK_GROUP = $group ? $group: $CHECK_ALIAS; |
|
142 | + $CHECK_GROUP = $group ? $group : $CHECK_ALIAS; |
|
143 | 143 | |
144 | 144 | $checkPath = sprintf('%s%s%s', $bundle->getPath(), DIRECTORY_SEPARATOR, $checkPath); |
145 | 145 | $checkPath = str_replace('\\', DIRECTORY_SEPARATOR, $checkPath); |
146 | 146 | |
147 | - if(is_dir($checkPath)) { |
|
147 | + if (is_dir($checkPath)) { |
|
148 | 148 | |
149 | - if($noBackup && is_dir($checkPath)) { |
|
149 | + if ($noBackup && is_dir($checkPath)) { |
|
150 | 150 | $output->writeln(sprintf('<info><error>Check %s exist</error>. Use --no-backup flag to rewrite</info>', $NAMESPACE)); |
151 | 151 | exit(1); |
152 | 152 | } else { |
@@ -158,17 +158,17 @@ discard block |
||
158 | 158 | |
159 | 159 | foreach ($this->tpls as $f) { |
160 | 160 | |
161 | - if(in_array($f->getBasename(), ['config.example.yml.twig', 'README.mdpp.twig'])) { |
|
161 | + if (in_array($f->getBasename(), ['config.example.yml.twig', 'README.mdpp.twig'])) { |
|
162 | 162 | continue; |
163 | 163 | } |
164 | 164 | |
165 | 165 | /* @var SplFileInfo $f */ |
166 | 166 | $fName = $f->getBasename('.twig'); |
167 | 167 | |
168 | - if($fName == 'Test.Php.integration') { |
|
168 | + if ($fName == 'Test.Php.integration') { |
|
169 | 169 | |
170 | 170 | $testPath = $input->getOption('integration-test-src'); |
171 | - if(!$testPath) { |
|
171 | + if (!$testPath) { |
|
172 | 172 | continue; |
173 | 173 | } else { |
174 | 174 | $fName = $f->getBasename('.integration.twig'); |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | $checkName |
188 | 188 | ); |
189 | 189 | |
190 | - if(is_dir($fPath)) { |
|
191 | - if($noBackup && is_dir($fPath)) { |
|
190 | + if (is_dir($fPath)) { |
|
191 | + if ($noBackup && is_dir($fPath)) { |
|
192 | 192 | $output->writeln(sprintf('<info>Tests for <error>check %s exist</error>. Use --no-backup flag to rewrite</info>', $NAMESPACE)); |
193 | 193 | continue; |
194 | 194 | } else { |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | @mkdir($fPath, 0775, true) && !is_dir($fPath); |
199 | 199 | } |
200 | 200 | } |
201 | - $TEST_NAMESPACE = sprintf('%s\%s\%s\%s', $bundleNamespace,'Test', $checkNamespace, $checkName); |
|
201 | + $TEST_NAMESPACE = sprintf('%s\%s\%s\%s', $bundleNamespace, 'Test', $checkNamespace, $checkName); |
|
202 | 202 | |
203 | 203 | $tplData = [ |
204 | 204 | 'NAMESPACE' => $TEST_NAMESPACE, |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | $path = sprintf('%s%s%s', $fPath, DIRECTORY_SEPARATOR, $fName); |
213 | 213 | file_put_contents($path, $res); |
214 | 214 | |
215 | - $this->createFile($fPath,'config.example.yml.twig','config.yml', $tplData); |
|
215 | + $this->createFile($fPath, 'config.example.yml.twig', 'config.yml', $tplData); |
|
216 | 216 | |
217 | 217 | } else { |
218 | 218 | $path = sprintf('%s%s%s', $checkPath, DIRECTORY_SEPARATOR, $fName); |
@@ -228,8 +228,8 @@ discard block |
||
228 | 228 | |
229 | 229 | file_put_contents($path, $res); |
230 | 230 | |
231 | - $this->createFile($checkPath,'config.example.yml.twig','config.example.yml', $tplData); |
|
232 | - $this->createFile($checkPath,'README.mdpp.twig','README.mdpp', $tplData); |
|
231 | + $this->createFile($checkPath, 'config.example.yml.twig', 'config.example.yml', $tplData); |
|
232 | + $this->createFile($checkPath, 'README.mdpp.twig', 'README.mdpp', $tplData); |
|
233 | 233 | } |
234 | 234 | } |
235 | 235 | } |
@@ -246,13 +246,13 @@ discard block |
||
246 | 246 | */ |
247 | 247 | private function createFile(string $basePath, string $from, string $to, array $tplData) |
248 | 248 | { |
249 | - $r = array_filter($this->tpls, function (SplFileInfo $f) use($from) { |
|
249 | + $r = array_filter($this->tpls, function(SplFileInfo $f) use($from) { |
|
250 | 250 | return $f->getBasename() == $from; |
251 | 251 | }); |
252 | 252 | |
253 | 253 | /* @var SplFileInfo $f */ |
254 | 254 | $f = current($r); |
255 | - if($f) { |
|
255 | + if ($f) { |
|
256 | 256 | $res = $this->twig->render($f->getRelativePathname(), $tplData); |
257 | 257 | $savePath = sprintf('%s%s%s', $basePath, DIRECTORY_SEPARATOR, $to); |
258 | 258 | file_put_contents($savePath, $res); |