Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
UseTempFileForString | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
countFromString | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | namespace Apie\CountWords\Strategies\Concerns; |
3 | |
4 | trait UseTempFileForString |
5 | { |
6 | public static function countFromString(string $text, array $counts = []): array |
7 | { |
8 | $tempFile = tempnam(sys_get_temp_dir(), 'UseTempFileString'); |
9 | file_put_contents($tempFile, $text); |
10 | try { |
11 | return self::countFromFile($tempFile, $counts); |
12 | } finally { |
13 | @unlink($tempFile); |
14 | } |
15 | } |
16 | } |