AppleDevicesProvider::getMetadata()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 8
ccs 0
cts 4
cp 0
crap 6
rs 10
1
<?php
2
3
namespace MadWizard\WebAuthn\Metadata\Provider\Apple;
4
5
use MadWizard\WebAuthn\Attestation\Statement\AppleAttestationStatement;
6
use MadWizard\WebAuthn\Attestation\TrustAnchor\MetadataInterface;
7
use MadWizard\WebAuthn\Metadata\Provider\MetadataProviderInterface;
8
use MadWizard\WebAuthn\Server\Registration\RegistrationResultInterface;
9
10
final class AppleDevicesProvider implements MetadataProviderInterface
11
{
12
    public function getMetadata(RegistrationResultInterface $registrationResult): ?MetadataInterface
13
    {
14
        // NOTE: Apple always used a zero AAGUID but has changed this to a specific AAGUID later, which might be
15
        // resolved using a metadata service.
16
        if ($registrationResult->getAttestationObject()->getFormat() === AppleAttestationStatement::FORMAT_ID) {
17
            return new AppleDeviceMetadata();
18
        }
19
        return null;
20
    }
21
22
    public function getDescription(): string
23
    {
24
        return 'Apple devices metadata provider';
25
    }
26
}
27