CoreFiles by mySites.guru
CertificateTrustPath.php61 lines, 1,332 bytes, from Joomla_5.2.2-Stable-Full_Package.zip
Raw History Compare with 5.2.1
md5
e34289cd470894e96b0a67b3b407052a
sha1
fbd11079cf87dcf04fb7a1fadd578e5c54600e82
sha256
ce546d34ef3a869751d40d18ac5c1beb2fba5a5672b4d69dfd60cd10f4f7fb9a
<?php

declare(strict_types=1);

namespace Webauthn\TrustPath;

use function array_key_exists;
use function is_array;
use Webauthn\Exception\InvalidTrustPathException;

final class CertificateTrustPath implements TrustPath
{
    /**
     * @param string[] $certificates
     */
    public function __construct(
        private readonly array $certificates
    ) {
    }

    /**
     * @param string[] $certificates
     */
    public static function create(array $certificates): self
    {
        return new self($certificates);
    }

    /**
     * @return string[]
     */
    public function getCertificates(): array
    {
        return $this->certificates;
    }

    /**
     * {@inheritdoc}
     */
    public static function createFromArray(array $data): static
    {
        array_key_exists('x5c', $data) || throw InvalidTrustPathException::create('The trust path type is invalid');
        $x5c = $data['x5c'];
        is_array($x5c) || throw InvalidTrustPathException::create(
            'The trust path type is invalid. The parameter "x5c" shall contain strings.'
        );

        return new self($x5c);
    }

    /**
     * @return mixed[]
     */
    public function jsonSerialize(): array
    {
        return [
            'type' => self::class,
            'x5c' => $this->certificates,
        ];
    }
}

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