@@ -41,35 +41,35 @@ |
||
41 | 41 | */ |
42 | 42 | public function aggregates(ResultCollection $results) { |
43 | 43 | $array = new ResultCollection(); |
44 | - foreach($results as $result) { |
|
44 | + foreach ($results as $result) { |
|
45 | 45 | $basename = dirname($result->getFilename()); |
46 | 46 | |
47 | 47 | // from 'folder1/folder2/file.php', we want an array with ('folder1', 'folder2') |
48 | 48 | $namespaces = explode(DIRECTORY_SEPARATOR, $basename); |
49 | 49 | |
50 | - if($this->depth) { |
|
50 | + if ($this->depth) { |
|
51 | 51 | array_splice($namespaces, $this->depth); |
52 | 52 | } |
53 | 53 | |
54 | 54 | // merge infos for each namespace in the DirectoryResultCollection |
55 | 55 | $len = sizeof($namespaces, COUNT_NORMAL); |
56 | 56 | |
57 | - for($i = 0; $i < $len; $i++) { |
|
57 | + for ($i = 0; $i < $len; $i++) { |
|
58 | 58 | |
59 | 59 | $namespace = $namespaces[$i]; |
60 | - if(0 === strlen($namespace)) { |
|
60 | + if (0 === strlen($namespace)) { |
|
61 | 61 | $namespace = '.'; |
62 | 62 | } |
63 | 63 | |
64 | - if(0 === $i) { |
|
64 | + if (0 === $i) { |
|
65 | 65 | // root |
66 | - if(!isset($array[$namespace])) { |
|
66 | + if (!isset($array[$namespace])) { |
|
67 | 67 | $array[$namespace] = new ResultCollection(); |
68 | 68 | } |
69 | 69 | $parent = &$array[$namespace]; |
70 | 70 | } else { |
71 | 71 | // namespace |
72 | - if(!isset($parent[$namespace])) { |
|
72 | + if (!isset($parent[$namespace])) { |
|
73 | 73 | $parent[$namespace] = new ResultCollection(); // ResultRecursiveCollection -> has getOOP(), etc. |
74 | 74 | } |
75 | 75 | $parent = &$parent[$namespace]; |
@@ -28,12 +28,12 @@ |
||
28 | 28 | $arrayMerged = call_user_func_array('array_merge_recursive', $array); |
29 | 29 | |
30 | 30 | $min = $max = $average = $sum = array(); |
31 | - foreach($arrayMerged as $key => $values) { |
|
31 | + foreach ($arrayMerged as $key => $values) { |
|
32 | 32 | $values = (array) $values; |
33 | 33 | $max[$key] = max($values); |
34 | 34 | $min[$key] = min($values); |
35 | 35 | $sum[$key] = array_sum($values); |
36 | - $average[$key] = round($sum[$key] / count($values, COUNT_NORMAL),2); |
|
36 | + $average[$key] = round($sum[$key] / count($values, COUNT_NORMAL), 2); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | return new BoundsResult($min, $max, $average, $sum); |
@@ -52,10 +52,10 @@ |
||
52 | 52 | */ |
53 | 53 | public function __construct($min, $max, $average, $sum) |
54 | 54 | { |
55 | - $this->min = $min; |
|
56 | - $this->max = $max; |
|
57 | - $this->average = $average; |
|
58 | - $this->sum = $sum; |
|
55 | + $this->min = $min; |
|
56 | + $this->max = $max; |
|
57 | + $this->average = $average; |
|
58 | + $this->sum = $sum; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -110,7 +110,7 @@ |
||
110 | 110 | */ |
111 | 111 | public function get($type, $key) |
112 | 112 | { |
113 | - switch($type) { |
|
113 | + switch ($type) { |
|
114 | 114 | case 'max': |
115 | 115 | return $this->getMax($key); |
116 | 116 | case 'sum': |
@@ -24,7 +24,7 @@ |
||
24 | 24 | */ |
25 | 25 | public function checkInstallation() { |
26 | 26 | $result = shell_exec('circo -V 2>&1'); |
27 | - if(!preg_match('!graphviz version!', $result)) { |
|
27 | + if (!preg_match('!graphviz version!', $result)) { |
|
28 | 28 | throw new \RuntimeException('Graphviz not installed'); |
29 | 29 | } |
30 | 30 | } |
@@ -53,7 +53,7 @@ |
||
53 | 53 | ; |
54 | 54 | |
55 | 55 | $config |
56 | - ->setRuleSet(new RuleSet( (array) $array['rules'])) |
|
56 | + ->setRuleSet(new RuleSet((array) $array['rules'])) |
|
57 | 57 | ->setFailureCondition($array['failure']) |
58 | 58 | ->setPath($path) |
59 | 59 | ->setLogging(new LoggingConfiguration($array['logging'])) |
@@ -43,7 +43,7 @@ |
||
43 | 43 | */ |
44 | 44 | public function load($filename) { |
45 | 45 | |
46 | - if(!\file_exists($filename) ||!\is_readable($filename)) { |
|
46 | + if (!\file_exists($filename) || !\is_readable($filename)) { |
|
47 | 47 | throw new \RuntimeException('configuration file is not accessible'); |
48 | 48 | } |
49 | 49 | $content = file_get_contents($filename); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | public function evaluate($rule) { |
61 | 61 | $result = new Evaluation; |
62 | 62 | |
63 | - if(0 == strlen($rule) ||is_null($rule)) { |
|
63 | + if (0 == strlen($rule) || is_null($rule)) { |
|
64 | 64 | return $result; |
65 | 65 | } |
66 | 66 | |
@@ -69,16 +69,16 @@ discard block |
||
69 | 69 | $context = new \Hoa\Ruler\Context(); |
70 | 70 | |
71 | 71 | // general |
72 | - foreach($bounds->asArray() as $category => $values) { |
|
72 | + foreach ($bounds->asArray() as $category => $values) { |
|
73 | 73 | $context[$category] = (object) $values; |
74 | 74 | } |
75 | 75 | |
76 | 76 | // by package |
77 | - foreach($this->aggregatedResults as $aggregate) { |
|
77 | + foreach ($this->aggregatedResults as $aggregate) { |
|
78 | 78 | $array = $aggregate->asArray(); |
79 | 79 | $c = array(); |
80 | - foreach($array as $k => $v) { |
|
81 | - if(is_array($v)) { |
|
80 | + foreach ($array as $k => $v) { |
|
81 | + if (is_array($v)) { |
|
82 | 82 | $v = (object) $v; |
83 | 83 | } |
84 | 84 | $c[$k] = $v; |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | |
90 | 90 | try { |
91 | 91 | $result->setValid(true === $ruler->assert($rule, $context)); |
92 | - } catch(\Hoa\Ruler\Exception\Asserter $e) { |
|
92 | + } catch (\Hoa\Ruler\Exception\Asserter $e) { |
|
93 | 93 | throw new \LogicException(sprintf('Cannot evaluate rule : %s', $e->getMessage())); |
94 | 94 | } |
95 | 95 | return $result; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | public function find($path) |
69 | 69 | { |
70 | 70 | $files = array(); |
71 | - if(is_dir($path)) { |
|
71 | + if (is_dir($path)) { |
|
72 | 72 | $path = rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; |
73 | 73 | $directory = new RecursiveDirectoryIterator($path, $this->flags); |
74 | 74 | $iterator = new RecursiveIteratorIterator($directory); |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $filterRegex = sprintf( |
77 | 77 | '`^%s%s$`', |
78 | 78 | !empty($this->excludedDirs) ? '((?!'.$this->excludedDirs.').)+' : '.+', |
79 | - '\.(' . $this->extensions . ')' |
|
79 | + '\.('.$this->extensions.')' |
|
80 | 80 | ); |
81 | 81 | |
82 | 82 | $filteredIterator = new RegexIterator( |
@@ -85,10 +85,10 @@ discard block |
||
85 | 85 | \RecursiveRegexIterator::GET_MATCH |
86 | 86 | ); |
87 | 87 | |
88 | - foreach($filteredIterator as $file) { |
|
88 | + foreach ($filteredIterator as $file) { |
|
89 | 89 | $files[] = $file[0]; |
90 | 90 | } |
91 | - } elseif(is_file($path)) { |
|
91 | + } elseif (is_file($path)) { |
|
92 | 92 | $files = array($path); |
93 | 93 | } |
94 | 94 | return $files; |
@@ -31,7 +31,7 @@ |
||
31 | 31 | $php = 'php'; |
32 | 32 | |
33 | 33 | if (0 >= version_compare('5.4.0', PHP_VERSION)) { |
34 | - $php = PHP_BINARY; |
|
34 | + $php = PHP_BINARY; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | $output = shell_exec(sprintf('"%s" -l %s 2>&1', $php, escapeshellarg($filename))); |
@@ -24,7 +24,7 @@ |
||
24 | 24 | * @return int |
25 | 25 | */ |
26 | 26 | public function isCorrect($filename) { |
27 | - if(1 === version_compare('5.0.4', PHP_VERSION)) { |
|
27 | + if (1 === version_compare('5.0.4', PHP_VERSION)) { |
|
28 | 28 | return php_check_syntax($filename); |
29 | 29 | } |
30 | 30 |