| Conditions | 6 |
| Paths | 6 |
| Total Lines | 32 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 27 | public function calculate($filename, $tokens) |
||
| 28 | { |
||
| 29 | |||
| 30 | $info = new Result; |
||
| 31 | |||
| 32 | $cloc = $lloc = 0; |
||
| 33 | foreach($tokens as $token) { |
||
| 34 | |||
| 35 | switch($token->getType()) { |
||
| 36 | case T_STRING: |
||
| 37 | if(';' == $token->getValue()) { |
||
| 38 | $lloc++; |
||
| 39 | } |
||
| 40 | break; |
||
| 41 | case T_COMMENT: |
||
| 42 | $cloc++; |
||
| 43 | break; |
||
| 44 | case T_DOC_COMMENT: |
||
| 45 | $cloc += count(preg_split('/\r\n|\r|\n/', $token->getValue())); |
||
| 46 | break; |
||
| 47 | } |
||
| 48 | } |
||
| 49 | |||
| 50 | $content = file_get_contents($filename); |
||
| 51 | $info |
||
| 52 | ->setLoc(count(preg_split('/\r\n|\r|\n/', $content)) - 1) |
||
| 53 | ->setCommentLoc($cloc) |
||
| 54 | ->setLogicalLoc($lloc) |
||
| 55 | ; |
||
| 56 | |||
| 57 | return $info; |
||
| 58 | } |
||
| 59 | } |
||
| 60 |