@@ -60,7 +60,7 @@ |
||
60 | 60 | * @inheritdoc |
61 | 61 | */ |
62 | 62 | public function execute(ResultCollection $collection, ResultCollection $aggregatedResults) { |
63 | - if(!$this->enabled) { |
|
63 | + if (!$this->enabled) { |
|
64 | 64 | return; |
65 | 65 | } |
66 | 66 |
@@ -61,12 +61,12 @@ |
||
61 | 61 | * @inheritdoc |
62 | 62 | */ |
63 | 63 | public function execute(ResultCollection $collection, ResultCollection $aggregatedResults) { |
64 | - if(!$this->destination) { |
|
64 | + if (!$this->destination) { |
|
65 | 65 | return; |
66 | 66 | } |
67 | 67 | |
68 | 68 | $dir = dirname($this->destination); |
69 | - if(!file_exists($dir)) { |
|
69 | + if (!file_exists($dir)) { |
|
70 | 70 | mkdir($dir, 0777, true); |
71 | 71 | } |
72 | 72 | $this->output->writeln(sprintf('Generating %s Report...', $this->formater->getName())); |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | 'path', InputArgument::OPTIONAL, 'Path to explore' |
39 | 39 | ) |
40 | 40 | ->addOption( |
41 | - 'report-html',null, InputOption::VALUE_REQUIRED, 'Path to save report in HTML format. Example: /tmp/report.html' |
|
41 | + 'report-html', null, InputOption::VALUE_REQUIRED, 'Path to save report in HTML format. Example: /tmp/report.html' |
|
42 | 42 | ) |
43 | 43 | ->addOption( |
44 | 44 | 'report-xml', null, InputOption::VALUE_REQUIRED, 'Path to save summary report in XML format. Example: /tmp/report.xml' |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $config = $configFactory->factory($input); |
103 | 103 | |
104 | 104 | // files |
105 | - if(null === $config->getPath()->getBasePath()) { |
|
105 | + if (null === $config->getPath()->getBasePath()) { |
|
106 | 106 | throw new \LogicException('Please provide a path to analyze'); |
107 | 107 | } |
108 | 108 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | |
130 | 130 | // evaluation of success |
131 | 131 | $rule = $config->getFailureCondition(); |
132 | - if(null !== $rule) { |
|
132 | + if (null !== $rule) { |
|
133 | 133 | $evaluator = new Evaluator($collection, $aggregatedResults, $bounds); |
134 | 134 | $result = $evaluator->evaluate($rule); |
135 | 135 | // fail if failure-condition is realized |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $locator = new ConfigLocator(); |
38 | 38 | $filename = $locator->locate($input->getOption('config')); |
39 | 39 | |
40 | - if(null !== $filename) { |
|
40 | + if (null !== $filename) { |
|
41 | 41 | $loader = new Loader($hydrator); |
42 | 42 | $config = $loader->load($filename); |
43 | 43 | } else { |
@@ -46,18 +46,18 @@ discard block |
||
46 | 46 | |
47 | 47 | |
48 | 48 | // then, overwrite configuration by arguments provided in run |
49 | - strlen($input->getArgument('path')) > 0 && $config->getPath()->setBasePath($input->getArgument('path')); |
|
50 | - strlen($input->getOption('extensions')) > 0 && $config->getPath()->setExtensions($input->getOption('extensions')); |
|
51 | - strlen($input->getOption('excluded-dirs')) > 0 && $config->getPath()->setExcludedDirs($input->getOption('excluded-dirs')); |
|
52 | - strlen($input->getOption('symlinks')) > 0 && $config->getPath()->setFollowSymlinks(true); |
|
53 | - strlen($input->getOption('report-xml')) > 0 && $config->getLogging()->setReport('xml', $input->getOption('report-xml')); |
|
54 | - strlen($input->getOption('report-cli')) > 0 && $config->getLogging()->setReport('cli', $input->getOption('report-cli')); |
|
55 | - strlen($input->getOption('report-json')) > 0 && $config->getLogging()->setReport('json', $input->getOption('report-json')); |
|
56 | - strlen($input->getOption('report-html')) > 0 && $config->getLogging()->setReport('html', $input->getOption('report-html')); |
|
57 | - strlen($input->getOption('report-csv')) > 0 && $config->getLogging()->setReport('csv', $input->getOption('report-csv')); |
|
49 | + strlen($input->getArgument('path')) > 0 && $config->getPath()->setBasePath($input->getArgument('path')); |
|
50 | + strlen($input->getOption('extensions')) > 0 && $config->getPath()->setExtensions($input->getOption('extensions')); |
|
51 | + strlen($input->getOption('excluded-dirs')) > 0 && $config->getPath()->setExcludedDirs($input->getOption('excluded-dirs')); |
|
52 | + strlen($input->getOption('symlinks')) > 0 && $config->getPath()->setFollowSymlinks(true); |
|
53 | + strlen($input->getOption('report-xml')) > 0 && $config->getLogging()->setReport('xml', $input->getOption('report-xml')); |
|
54 | + strlen($input->getOption('report-cli')) > 0 && $config->getLogging()->setReport('cli', $input->getOption('report-cli')); |
|
55 | + strlen($input->getOption('report-json')) > 0 && $config->getLogging()->setReport('json', $input->getOption('report-json')); |
|
56 | + strlen($input->getOption('report-html')) > 0 && $config->getLogging()->setReport('html', $input->getOption('report-html')); |
|
57 | + strlen($input->getOption('report-csv')) > 0 && $config->getLogging()->setReport('csv', $input->getOption('report-csv')); |
|
58 | 58 | strlen($input->getOption('violations-xml')) > 0 && $config->getLogging()->setViolation('xml', $input->getOption('violations-xml')); |
59 | - strlen($input->getOption('chart-bubbles')) > 0 && $config->getLogging()->setChart('bubbles', $input->getOption('chart-bubbles')); |
|
60 | - strlen($input->getOption('failure-condition')) > 0 && $config->setFailureCondition($input->getOption('failure-condition')); |
|
59 | + strlen($input->getOption('chart-bubbles')) > 0 && $config->getLogging()->setChart('bubbles', $input->getOption('chart-bubbles')); |
|
60 | + strlen($input->getOption('failure-condition')) > 0 && $config->setFailureCondition($input->getOption('failure-condition')); |
|
61 | 61 | strlen($input->getOption('template-title')) > 0 && $config->getTemplate()->setTitle($input->getOption('template-title')); |
62 | 62 | strlen($input->getOption('ignore-errors')) > 0 && $config->setIgnoreErrors(true); |
63 | 63 |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * @param array $defaults |
29 | 29 | */ |
30 | 30 | public function __construct(array $defaults = null) { |
31 | - if(is_null($defaults)) { |
|
31 | + if (is_null($defaults)) { |
|
32 | 32 | $defaults = array('.phpmetrics.yml', '.phpmetrics.yml.dist', '.phpmetrics-dist.yml'); |
33 | 33 | } |
34 | 34 | $this->defaults = $defaults; |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function locate($filename) { |
44 | 44 | |
45 | - if(null === $filename) { |
|
45 | + if (null === $filename) { |
|
46 | 46 | // try to use default configfile : .phpmetrics.yml or .phpmetrics.yml.dist |
47 | - foreach($this->defaults as $filenameToCheck) { |
|
47 | + foreach ($this->defaults as $filenameToCheck) { |
|
48 | 48 | $filenameToCheck = getcwd().DIRECTORY_SEPARATOR.$filenameToCheck; |
49 | 49 | if (true === $this->isFileAccessible($filenameToCheck)) { |
50 | 50 | return $filenameToCheck; |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | return null; |
54 | 54 | } |
55 | 55 | |
56 | - if(false === $this->isFileAccessible($filename)) { |
|
56 | + if (false === $this->isFileAccessible($filename)) { |
|
57 | 57 | throw new \RuntimeException('configuration file is not accessible'); |
58 | 58 | } |
59 | 59 |
@@ -33,7 +33,7 @@ |
||
33 | 33 | { |
34 | 34 | $available = ['metrics', 'self-update']; |
35 | 35 | $arg = $input->getFirstArgument(); |
36 | - if(!in_array($arg, $available) ||'metrics' === $arg) { |
|
36 | + if (!in_array($arg, $available) || 'metrics' === $arg) { |
|
37 | 37 | // default argument : we don't want to provide the name of the command by default |
38 | 38 | $inputDefinition = $this->getDefinition(); |
39 | 39 | $inputDefinition->setArguments(); |
@@ -51,19 +51,19 @@ discard block |
||
51 | 51 | /** |
52 | 52 | * @inheritdoc |
53 | 53 | */ |
54 | - public function terminate(ResultCollection $collection, ResultCollection $groupedResults){ |
|
54 | + public function terminate(ResultCollection $collection, ResultCollection $groupedResults) { |
|
55 | 55 | |
56 | 56 | $text = 'digraph G {' |
57 | - . PHP_EOL .'bgcolor=white;' |
|
58 | - . PHP_EOL .'node [shape=circle, color=lightblue2, style=filled];'; |
|
57 | + . PHP_EOL.'bgcolor=white;' |
|
58 | + . PHP_EOL.'node [shape=circle, color=lightblue2, style=filled];'; |
|
59 | 59 | |
60 | 60 | $width = 300; |
61 | 61 | |
62 | - foreach($collection as $item) { |
|
62 | + foreach ($collection as $item) { |
|
63 | 63 | |
64 | 64 | // color |
65 | 65 | $valid = $this->validator->validate('maintainabilityIndex', $item->getMaintainabilityIndex()->getMaintainabilityIndex()); |
66 | - switch($valid) { |
|
66 | + switch ($valid) { |
|
67 | 67 | case Validator::CRITICAL: $color = 'red'; break; |
68 | 68 | case Validator::GOOD: $color = 'chartreuse4'; break; |
69 | 69 | case Validator::WARNING: $color = 'gold1'; break; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | // size |
74 | 74 | $size = round($item->getMcCabe()->getCyclomaticComplexityNumber() * $width / 100); |
75 | 75 | |
76 | - $text .= PHP_EOL. sprintf('"%1$s" [color=%2$s, tooltip="%3$s", width=%4$s, height=%4$s, label=""];' |
|
76 | + $text .= PHP_EOL.sprintf('"%1$s" [color=%2$s, tooltip="%3$s", width=%4$s, height=%4$s, label=""];' |
|
77 | 77 | , $item->getName() |
78 | 78 | , $color |
79 | 79 | , $item->getName() |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | /** |
55 | 55 | * @inheritdoc |
56 | 56 | */ |
57 | - public function terminate(ResultCollection $collection, ResultCollection $groupedResults){ |
|
57 | + public function terminate(ResultCollection $collection, ResultCollection $groupedResults) { |
|
58 | 58 | |
59 | 59 | $output = new BufferedOutput(OutputInterface::VERBOSITY_NORMAL, true); |
60 | 60 | // $output->write(str_pad("\x0D", 80, "\x20")); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | )) |
104 | 104 | ->setLayout(TableHelper::LAYOUT_DEFAULT); |
105 | 105 | |
106 | - foreach($groupedResults as $result) { |
|
106 | + foreach ($groupedResults as $result) { |
|
107 | 107 | $table->addRow(array_merge( |
108 | 108 | array( |
109 | 109 | str_repeat(' ', $result->getDepth()).$result->getName() |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | private function getStyle($key, $value) { |
159 | 159 | $score = $this->validator->validate($key, $value); |
160 | 160 | |
161 | - switch($score) { |
|
161 | + switch ($score) { |
|
162 | 162 | case Validator::GOOD: |
163 | 163 | return 'fg=green'; |
164 | 164 | case Validator::WARNING: |
@@ -29,20 +29,20 @@ |
||
29 | 29 | /** |
30 | 30 | * @inheritdoc |
31 | 31 | */ |
32 | - public function terminate(ResultCollection $collection, ResultCollection $groupedResults){ |
|
32 | + public function terminate(ResultCollection $collection, ResultCollection $groupedResults) { |
|
33 | 33 | |
34 | 34 | $fwd = fopen('php://memory', 'w'); |
35 | - if(sizeof($collection, COUNT_NORMAL) > 0) { |
|
35 | + if (sizeof($collection, COUNT_NORMAL) > 0) { |
|
36 | 36 | $r = current($collection->asArray()); |
37 | 37 | $labels = array_keys($r); |
38 | 38 | fputcsv($fwd, $labels); |
39 | 39 | } |
40 | - foreach($collection as $item) { |
|
40 | + foreach ($collection as $item) { |
|
41 | 41 | fputcsv($fwd, $item->asArray()); |
42 | 42 | } |
43 | 43 | |
44 | 44 | rewind($fwd); |
45 | - $r = stream_get_contents($fwd); |
|
45 | + $r = stream_get_contents($fwd); |
|
46 | 46 | fclose($fwd); |
47 | 47 | return $r; |
48 | 48 | } |