CoreFiles by mySites.guru
TrustPathLoader.php33 lines, 998 bytes, from Joomla_5.0.0-alpha1-Alpha-Full_Package.zip
Raw History Compare with 4.4.0-alpha4
md5
86af79a46d7645bb20c4a0d48c9e6155
sha1
cfc9c3d909a1d251c49fb8d1520105b3781f7863
sha256
679a810805fdc27ad97062ebb0ea42b0cdea8f9e686c247011f2776ea278acf9
<?php

declare(strict_types=1);

namespace Webauthn\TrustPath;

use function array_key_exists;
use function class_implements;
use function in_array;
use Webauthn\Exception\InvalidTrustPathException;

abstract class TrustPathLoader
{
    /**
     * @param mixed[] $data
     */
    public static function loadTrustPath(array $data): TrustPath
    {
        array_key_exists('type', $data) || throw InvalidTrustPathException::create('The trust path type is missing');
        $type = $data['type'];
        if (class_exists($type) !== true) {
            throw InvalidTrustPathException::create(
                sprintf('The trust path type "%s" is not supported', $data['type'])
            );
        }

        $implements = class_implements($type);
        if (in_array(TrustPath::class, $implements, true)) {
            return $type::createFromArray($data);
        }
        throw InvalidTrustPathException::create(sprintf('The trust path type "%s" is not supported', $data['type']));
    }
}

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.