Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
8 / 8 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| FromPhoneNumber | |
100.00% |
8 / 8 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| support | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getIndexes | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | namespace Apie\Core\Indexing; |
| 3 | |
| 4 | use Apie\Core\Context\ApieContext; |
| 5 | use Apie\CountryAndPhoneNumber\PhoneNumber; |
| 6 | |
| 7 | final class FromPhoneNumber implements IndexingStrategyInterface |
| 8 | { |
| 9 | public function support(object $object): bool |
| 10 | { |
| 11 | return $object instanceof PhoneNumber; |
| 12 | } |
| 13 | |
| 14 | /** |
| 15 | * @return array<string, int> |
| 16 | */ |
| 17 | public function getIndexes(object $class, ApieContext $context, Indexer $indexer): array |
| 18 | { |
| 19 | assert($class instanceof PhoneNumber); |
| 20 | return [ |
| 21 | $class->toE164() => 3, |
| 22 | str_replace(' ', '', $class->toInternational()) => 3, |
| 23 | str_replace(' ', '', $class->toNational()) => 1, |
| 24 | $class->toRFC3966() => 2, |
| 25 | ]; |
| 26 | } |
| 27 | } |