CoreFiles by mySites.guru
VerificationMethodANDCombinations.php58 lines, 1,490 bytes, from Joomla_5.0.0-beta2-Beta-Full_Package.zip
Raw History Compare with 5.0.0-beta1
md5
0a7ff83dea1eb88edd7d1cb673e23221
sha1
eb2743be9179f93c2f09094f95f68a471892bb02
sha256
4c8eb6e630702ed73b7665b23e039fdd17494410bdeeafd519d0c1c62f7f3ea6
<?php

declare(strict_types=1);

namespace Webauthn\MetadataService\Statement;

use function is_array;
use JsonSerializable;
use Webauthn\MetadataService\Exception\MetadataStatementLoadingException;

class VerificationMethodANDCombinations implements JsonSerializable
{
    /**
     * @var VerificationMethodDescriptor[]
     */
    private array $verificationMethods = [];

    public function addVerificationMethodDescriptor(VerificationMethodDescriptor $verificationMethodDescriptor): self
    {
        $this->verificationMethods[] = $verificationMethodDescriptor;

        return $this;
    }

    /**
     * @return VerificationMethodDescriptor[]
     */
    public function getVerificationMethods(): array
    {
        return $this->verificationMethods;
    }

    /**
     * @param array<string, mixed> $data
     */
    public static function createFromArray(array $data): self
    {
        $object = new self();

        foreach ($data as $datum) {
            is_array($datum) || throw MetadataStatementLoadingException::create('Invalid data');
            $object->addVerificationMethodDescriptor(VerificationMethodDescriptor::createFromArray($datum));
        }

        return $object;
    }

    /**
     * @return array<array<mixed>>
     */
    public function jsonSerialize(): array
    {
        return array_map(
            static fn (VerificationMethodDescriptor $object): array => $object->jsonSerialize(),
            $this->verificationMethods
        );
    }
}

The same content is in 6 releases, Joomla 5.0.0-alpha1 to 5.0.0-beta2. See them all, or every version of this file.