Issues (19)

src/Metadata/MetadataResolver.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace MadWizard\WebAuthn\Metadata;
4
5
use MadWizard\WebAuthn\Attestation\TrustAnchor\MetadataInterface;
6
use MadWizard\WebAuthn\Exception\WebAuthnException;
7
use MadWizard\WebAuthn\Metadata\Provider\MetadataProviderInterface;
8
use MadWizard\WebAuthn\Server\Registration\RegistrationResultInterface;
9
use Psr\Log\LoggerAwareInterface;
10
use Psr\Log\LoggerAwareTrait;
11
use Psr\Log\NullLogger;
12
13
final class MetadataResolver implements MetadataResolverInterface, LoggerAwareInterface
14
{
15
    use LoggerAwareTrait;
16
17
    /**
18
     * @var MetadataProviderInterface[]
19
     */
20
    private $providers;
21
22
    public function __construct(array $providers)
23
    {
24
        $this->providers = $providers;
25
        $this->logger = new NullLogger();
26
    }
27
28
    public function getMetadata(RegistrationResultInterface $registrationResult): ?MetadataInterface
29
    {
30
        foreach ($this->providers as $provider) {
31
            try {
32
                $metadata = $provider->getMetadata($registrationResult);
33
                if ($metadata !== null) {
34
                    $this->logger->info('Found metadata for authenticator in provider {provider}.', ['provider' => $provider->getDescription()]);
0 ignored issues
show
The method info() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

34
                    $this->logger->/** @scrutinizer ignore-call */ 
35
                                   info('Found metadata for authenticator in provider {provider}.', ['provider' => $provider->getDescription()]);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
35
                    return $metadata;
36
                }
37
            } catch (WebAuthnException $e) {
38
                $this->logger->warning('Error retrieving metadata ({error}) - ignoring provider {provider}.', ['error' => $e->getMessage(), 'provider' => $provider->getDescription(), 'exception' => $e]);
39
                continue;
40
            }
41
        }
42
        return null;
43
    }
44
}
45