@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | if (!isset($tokens[$next])) { |
47 | 47 | throw new IncorrectSyntaxException; |
48 | 48 | } |
49 | - $this->currentNamespace = '\\' . $tokens[$next]; |
|
49 | + $this->currentNamespace = '\\'.$tokens[$next]; |
|
50 | 50 | continue; |
51 | 51 | } |
52 | 52 | |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | if ('\\' === $alias[0]) { |
107 | 107 | return $alias; |
108 | 108 | } |
109 | - if ($this->has('\\' . $alias)) { |
|
110 | - return '\\' . $alias; |
|
109 | + if ($this->has('\\'.$alias)) { |
|
110 | + return '\\'.$alias; |
|
111 | 111 | } |
112 | 112 | if ($this->has($alias)) { |
113 | 113 | return sprintf('%s\\%s', $this->currentNamespace, $this->namespaces[$alias]); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | public function resolve($token) |
29 | 29 | { |
30 | 30 | |
31 | - if(strlen($token) == 0) { |
|
31 | + if (strlen($token) == 0) { |
|
32 | 32 | return Token::T_VALUE_VOID; |
33 | 33 | } |
34 | 34 | |
@@ -36,35 +36,35 @@ discard block |
||
36 | 36 | return $token; |
37 | 37 | } |
38 | 38 | |
39 | - if(preg_match('!^\d+$!', $token)) { |
|
39 | + if (preg_match('!^\d+$!', $token)) { |
|
40 | 40 | return Token::T_VALUE_INTEGER; |
41 | 41 | } |
42 | 42 | |
43 | - if(preg_match('!^\d+\.\d+$!', $token)) { |
|
43 | + if (preg_match('!^\d+\.\d+$!', $token)) { |
|
44 | 44 | return Token::T_VALUE_FLOAT; |
45 | 45 | } |
46 | 46 | |
47 | - if('null' == $token) { |
|
47 | + if ('null' == $token) { |
|
48 | 48 | return Token::T_VALUE_NULL; |
49 | 49 | } |
50 | 50 | |
51 | - if(preg_match('!^\$\w+$!', $token)) { |
|
51 | + if (preg_match('!^\$\w+$!', $token)) { |
|
52 | 52 | return Token::T_VAR; |
53 | 53 | } |
54 | 54 | |
55 | - if(preg_match('!(^\[|^array\()!', $token)) { |
|
55 | + if (preg_match('!(^\[|^array\()!', $token)) { |
|
56 | 56 | return Token::T_VALUE_ARRAY; |
57 | 57 | } |
58 | 58 | |
59 | - if(preg_match('!^(true|false)!', $token)) { |
|
59 | + if (preg_match('!^(true|false)!', $token)) { |
|
60 | 60 | return Token::T_VALUE_BOOLEAN; |
61 | 61 | } |
62 | 62 | |
63 | - if(preg_match('!^function!', $token)) { |
|
63 | + if (preg_match('!^function!', $token)) { |
|
64 | 64 | return Token::T_FUNCTION; |
65 | 65 | } |
66 | 66 | |
67 | - if(preg_match('!^["\']!', $token)) { |
|
67 | + if (preg_match('!^["\']!', $token)) { |
|
68 | 68 | return Token::T_VALUE_STRING; |
69 | 69 | } |
70 | 70 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function isObject($value) |
88 | 88 | { |
89 | - return !$this->isScalar($value) &&Token::T_VALUE_ARRAY !== $this->resolve($value); |
|
89 | + return !$this->isScalar($value) && Token::T_VALUE_ARRAY !== $this->resolve($value); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | } |
93 | 93 | \ No newline at end of file |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function setIsItself($isItself) |
80 | 80 | { |
81 | - $this->isItself = (bool)$isItself; |
|
81 | + $this->isItself = (bool) $isItself; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function setIsStatic($isStatic) |
96 | 96 | { |
97 | - $this->isStatic = (bool)$isStatic; |
|
97 | + $this->isStatic = (bool) $isStatic; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function setIsParent($isParent) |
113 | 113 | { |
114 | - $this->isParent = (bool)$isParent; |
|
114 | + $this->isParent = (bool) $isParent; |
|
115 | 115 | return $this; |
116 | 116 | } |
117 | 117 |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | public function getDependencies($unique = true) |
68 | 68 | { |
69 | 69 | $dependencies = array(); |
70 | - foreach($this->methods as $method) { |
|
70 | + foreach ($this->methods as $method) { |
|
71 | 71 | $dependencies = array_merge($dependencies, $method->getDependencies()); |
72 | 72 | } |
73 | 73 | |
74 | - if($unique) { |
|
74 | + if ($unique) { |
|
75 | 75 | $dependencies = array_unique($dependencies); |
76 | 76 | } |
77 | 77 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | */ |
170 | 170 | public function setIsAbstract($isAbstract) |
171 | 171 | { |
172 | - $this->isAbstract = (bool)$isAbstract; |
|
172 | + $this->isAbstract = (bool) $isAbstract; |
|
173 | 173 | return $this; |
174 | 174 | } |
175 | 175 |
@@ -63,19 +63,19 @@ discard block |
||
63 | 63 | $typeResolver = new TypeResolver(); |
64 | 64 | |
65 | 65 | $dependencies = array(); |
66 | - foreach($this->returns as $return) { |
|
67 | - if($typeResolver->isObject($return->getType())) { |
|
66 | + foreach ($this->returns as $return) { |
|
67 | + if ($typeResolver->isObject($return->getType())) { |
|
68 | 68 | array_push($dependencies, $return->getType()); |
69 | 69 | } |
70 | 70 | } |
71 | - foreach($this->arguments as $argument) { |
|
71 | + foreach ($this->arguments as $argument) { |
|
72 | 72 | array_push($dependencies, $argument->getType()); |
73 | 73 | } |
74 | - foreach($this->calls as $call) { |
|
74 | + foreach ($this->calls as $call) { |
|
75 | 75 | array_push($dependencies, $call->getType()); |
76 | 76 | } |
77 | 77 | |
78 | - if($unique) { |
|
78 | + if ($unique) { |
|
79 | 79 | $dependencies = array_unique($dependencies); |
80 | 80 | } |
81 | 81 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function setIsStatic($isStatic) |
167 | 167 | { |
168 | - $this->isStatic = (bool)$isStatic; |
|
168 | + $this->isStatic = (bool) $isStatic; |
|
169 | 169 | return $this; |
170 | 170 | } |
171 | 171 |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | |
30 | 30 | $ac = $cc = $abstractness = 0; |
31 | 31 | |
32 | - foreach($graph->all() as $node) { |
|
32 | + foreach ($graph->all() as $node) { |
|
33 | 33 | $class = $node->getData(); |
34 | - if (($class->isAbstract() ||$class->isInterface())) { |
|
34 | + if (($class->isAbstract() || $class->isInterface())) { |
|
35 | 35 | $ac++; |
36 | 36 | } else { |
37 | 37 | $cc++; |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | $result = new Result; |
42 | - if($ac + $cc > 0) { |
|
42 | + if ($ac + $cc > 0) { |
|
43 | 43 | $abstractness = round($ac / ($ac + $cc), 2); |
44 | 44 | } |
45 | 45 | $result->setAbstractness($abstractness); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | $ca = $ce = $i = 0; |
32 | 32 | |
33 | 33 | $coupling = new Coupling(); |
34 | - foreach($graph->all() as $node) { |
|
34 | + foreach ($graph->all() as $node) { |
|
35 | 35 | |
36 | 36 | $r = $coupling->calculate($node); |
37 | 37 | $ce += $r->getEfferentCoupling(); |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | $result = new Result; |
42 | - if($ca + $ce > 0) { |
|
42 | + if ($ca + $ce > 0) { |
|
43 | 43 | $i = round($ce / ($ca + $ce), 2); |
44 | 44 | } |
45 | 45 | $result->setInstability($i); |
@@ -28,14 +28,14 @@ discard block |
||
28 | 28 | public function calculate(Node $node) |
29 | 29 | { |
30 | 30 | $efferent = $afferent = 0; |
31 | - foreach($node->getEdges() as $edge) { |
|
31 | + foreach ($node->getEdges() as $edge) { |
|
32 | 32 | |
33 | - if($edge->getFrom()->getKey() == $node->getKey()) { |
|
33 | + if ($edge->getFrom()->getKey() == $node->getKey()) { |
|
34 | 34 | // affects |
35 | 35 | $afferent++; |
36 | 36 | } |
37 | 37 | |
38 | - if($edge->getTo()->getKey() == $node->getKey()) { |
|
38 | + if ($edge->getTo()->getKey() == $node->getKey()) { |
|
39 | 39 | // receive effects |
40 | 40 | $efferent++; |
41 | 41 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | ->setAfferentCoupling($afferent) |
47 | 47 | ->setEfferentCoupling($efferent); |
48 | 48 | |
49 | - if($efferent + $afferent > 0) { |
|
49 | + if ($efferent + $afferent > 0) { |
|
50 | 50 | $result->setInstability($efferent / ($afferent + $efferent)); |
51 | 51 | } |
52 | 52 | return $result; |
@@ -30,27 +30,27 @@ discard block |
||
30 | 30 | $graph = new Graph(); |
31 | 31 | |
32 | 32 | // attributes in graph are prefixed with '_attr_' string |
33 | - foreach($class->getMethods() as $method) { |
|
33 | + foreach ($class->getMethods() as $method) { |
|
34 | 34 | |
35 | 35 | // avoid getters and setters |
36 | - if($method->isGetter() ||$method->isSetter()) { |
|
36 | + if ($method->isGetter() || $method->isSetter()) { |
|
37 | 37 | continue; |
38 | 38 | } |
39 | 39 | |
40 | - if(null === ($from = $graph->get($method->getName()))) { |
|
40 | + if (null === ($from = $graph->get($method->getName()))) { |
|
41 | 41 | $from = new Node($method->getName()); |
42 | 42 | $graph->insert($from); |
43 | 43 | } |
44 | 44 | |
45 | 45 | // calls |
46 | - foreach($method->getCalls() as $call) { |
|
46 | + foreach ($method->getCalls() as $call) { |
|
47 | 47 | |
48 | - if(!$call->isItself()) { |
|
48 | + if (!$call->isItself()) { |
|
49 | 49 | continue; |
50 | 50 | |
51 | 51 | } |
52 | 52 | |
53 | - if(null === ($to = $graph->get($call->getMethodName()))) { |
|
53 | + if (null === ($to = $graph->get($call->getMethodName()))) { |
|
54 | 54 | $to = new Node($call->getMethodName()); |
55 | 55 | $graph->insert($to); |
56 | 56 | } |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | } |
59 | 59 | |
60 | 60 | // attributes |
61 | - foreach($method->getTokens() as $token) { |
|
62 | - if(preg_match('!\$this\->(\w+)$!', $token, $matches)) { |
|
61 | + foreach ($method->getTokens() as $token) { |
|
62 | + if (preg_match('!\$this\->(\w+)$!', $token, $matches)) { |
|
63 | 63 | list(, $attribute) = $matches; |
64 | 64 | |
65 | - if(null === ($to = $graph->get('_attr_' . $attribute))) { |
|
66 | - $to = new Node('_attr_' . $attribute); |
|
65 | + if (null === ($to = $graph->get('_attr_'.$attribute))) { |
|
66 | + $to = new Node('_attr_'.$attribute); |
|
67 | 67 | $graph->insert($to); |
68 | 68 | } |
69 | 69 | $graph->addEdge($from, $to); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | // iterate over nodes, and count paths |
76 | 76 | $paths = 0; |
77 | - foreach($graph->all() as $node) { |
|
77 | + foreach ($graph->all() as $node) { |
|
78 | 78 | $paths += $this->traverse($node); |
79 | 79 | } |
80 | 80 | |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | */ |
94 | 94 | private function traverse(Node $node) |
95 | 95 | { |
96 | - if($node->visited) { |
|
96 | + if ($node->visited) { |
|
97 | 97 | return 0; |
98 | 98 | } |
99 | 99 | $node->visited = true; |
100 | 100 | |
101 | - foreach($node->getAdjacents() as $adjacent) { |
|
101 | + foreach ($node->getAdjacents() as $adjacent) { |
|
102 | 102 | $this->traverse($adjacent); |
103 | 103 | } |
104 | 104 |