Conditions | 6 |
Paths | 6 |
Total Lines | 34 |
Code Lines | 22 |
Lines | 0 |
Ratio | 0 % |
1 | <?php |
||
42 | public function calculate($filename) |
||
43 | { |
||
44 | |||
45 | $info = new Result; |
||
46 | |||
47 | $tokens = $this->tokenizer->tokenize($filename); |
||
48 | $content = file_get_contents($filename); |
||
49 | |||
50 | $cloc = $lloc = 0; |
||
51 | foreach($tokens as $token) { |
||
52 | |||
53 | switch($token->getType()) { |
||
54 | case T_STRING: |
||
55 | if(';' == $token->getValue()) { |
||
56 | $lloc++; |
||
57 | } |
||
58 | break; |
||
59 | case T_COMMENT: |
||
60 | $cloc++; |
||
61 | break; |
||
62 | case T_DOC_COMMENT: |
||
63 | $cloc += count(preg_split('/\r\n|\r|\n/', $token->getValue())); |
||
64 | break; |
||
65 | } |
||
66 | } |
||
67 | |||
68 | $info |
||
69 | ->setLoc(count(preg_split('/\r\n|\r|\n/', $content)) - 1) |
||
70 | ->setCommentLoc($cloc) |
||
71 | ->setLogicalLoc($lloc) |
||
72 | ; |
||
73 | |||
74 | return $info; |
||
75 | } |
||
76 | } |
||
77 |