Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| XmlWordCounter | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
4 | |
100.00% |
1 / 1 |
| __construct | n/a |
0 / 0 |
n/a |
0 / 0 |
1 | |||||
| isSupported | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| countFromString | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | namespace Apie\CountWords\Strategies; |
| 3 | |
| 4 | use Apie\CountWords\Strategies\Concerns\UseResourceForFile; |
| 5 | use Apie\CountWords\Strategies\Concerns\UseStringForResource; |
| 6 | use Apie\CountWords\WordCounter; |
| 7 | |
| 8 | final class XmlWordCounter implements WordCounterInterface |
| 9 | { |
| 10 | use UseStringForResource; |
| 11 | use UseResourceForFile; |
| 12 | /** |
| 13 | * @codeCoverageIgnore |
| 14 | */ |
| 15 | private function __construct() |
| 16 | { |
| 17 | } |
| 18 | |
| 19 | public static function isSupported(?string $fileExtension, ?string $mimeType): bool |
| 20 | { |
| 21 | return in_array($fileExtension, ['xml']) || in_array($mimeType, ['application/xml', 'text/xml']); |
| 22 | } |
| 23 | |
| 24 | public static function countFromString(string $text, array $counts = []): array |
| 25 | { |
| 26 | $text = strip_tags(str_replace(['<', '>'], [' <', '> '], $text)); |
| 27 | |
| 28 | return WordCounter::countFromString($text, $counts); |
| 29 | } |
| 30 | } |