| Conditions | 6 |
| Paths | 6 |
| Total Lines | 28 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 6.0852 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 25 | 3 | public function getMetadata(RegistrationResultInterface $registrationResult): ?MetadataInterface |
|
| 26 | { |
||
| 27 | 3 | $identifier = $registrationResult->getIdentifier(); |
|
| 28 | 3 | if ($identifier === null) { |
|
| 29 | 1 | return null; |
|
| 30 | } |
||
| 31 | |||
| 32 | 2 | $iterator = new GlobIterator($this->source->getMetadataDir() . DIRECTORY_SEPARATOR . '*.json'); |
|
| 33 | |||
| 34 | /** |
||
| 35 | * @var SplFileInfo $fileInfo |
||
| 36 | */ |
||
| 37 | 2 | foreach ($iterator as $fileInfo) { |
|
| 38 | 2 | if (!$fileInfo->isFile()) { |
|
| 39 | continue; |
||
| 40 | } |
||
| 41 | |||
| 42 | 2 | $data = file_get_contents($fileInfo->getPathname()); |
|
| 43 | 2 | if ($data === false) { |
|
| 44 | throw new WebAuthnException(sprintf('Cannot read file %s.', $fileInfo->getPathname())); |
||
| 45 | } |
||
| 46 | 2 | $statement = MetadataStatement::decodeString($data); |
|
| 47 | |||
| 48 | 2 | if ($statement->matchesIdentifier($identifier)) { |
|
| 49 | 1 | return $statement; |
|
| 50 | } |
||
| 51 | } |
||
| 52 | 1 | return null; |
|
| 53 | } |
||
| 60 |