1 | <?php |
||
18 | class McCabe { |
||
19 | |||
20 | /** |
||
21 | * Tokenizer |
||
22 | * |
||
23 | * @var \Hal\Component\Token\Tokenizer |
||
24 | */ |
||
25 | private $tokenizer; |
||
26 | |||
27 | /** |
||
28 | * Constructor |
||
29 | * |
||
30 | * @param Tokenizer $tokenizer |
||
31 | */ |
||
32 | public function __construct(Tokenizer $tokenizer) { |
||
35 | |||
36 | /** |
||
37 | * Calculate cyclomatic complexity number |
||
38 | * |
||
39 | * We can calculate ccn in two ways (we choose the second): |
||
40 | * |
||
41 | * 1. Cyclomatic complexity (CC) = E - N + 2P |
||
42 | * Where: |
||
43 | * P = number of disconnected parts of the flow graph (e.g. a calling program and a subroutine) |
||
44 | * E = number of edges (transfers of control) |
||
45 | * N = number of nodes (sequential group of statements containing only one transfer of control) |
||
46 | * |
||
47 | * 2. CC = Number of each decision point |
||
48 | * |
||
49 | * @param string $filename |
||
50 | * @return Result |
||
51 | */ |
||
52 | public function calculate($filename) |
||
94 | } |