| Conditions | 3 |
| Paths | 3 |
| Total Lines | 22 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 25 | public function tokenize($filename) { |
||
| 26 | // |
||
| 27 | // fixes memory problems with large files |
||
| 28 | // https://github.com/Halleck45/PhpMetrics/issues/13 |
||
| 29 | $size = filesize($filename); |
||
| 30 | $limit = 102400; // around 100 Ko |
||
| 31 | if($size > $limit) { |
||
| 32 | $tokens = array(); |
||
| 33 | $hwnd = fopen($filename, 'r'); |
||
| 34 | while (!feof($hwnd)) { |
||
| 35 | $content = stream_get_line($hwnd, $limit); |
||
| 36 | // string is arbitrary splitted, so content can be incorrect |
||
| 37 | // for example: "Unterminated comment starting..." |
||
| 38 | $content .= '/* */'; |
||
| 39 | $tokens = array_merge($tokens, token_get_all($this->cleanup($content))); |
||
| 40 | unset($content); |
||
| 41 | } |
||
| 42 | return new TokenCollection($tokens); |
||
| 43 | } |
||
| 44 | |||
| 45 | return new TokenCollection(token_get_all($this->cleanup(file_get_contents($filename)))); |
||
| 46 | } |
||
| 47 | |||
| 61 | } |