CoreFiles by mySites.guru
PublicKeyCredentialRpEntity.php55 lines, 1,212 bytes, from Joomla_5.2.2-Stable-Full_Package.zip
Raw History Compare with 5.2.1
md5
3ce211eea79ee72ff4b0c5083a884f9e
sha1
48aa8c42ef39b579ffe8cf4e3d928cf7e256f944
sha256
18bd0b4a0b617d6e790c4bbc3f02cfa8277636f0b7929ec164cee130fde4fe49
<?php

declare(strict_types=1);

namespace Webauthn;

use function array_key_exists;
use Webauthn\Exception\InvalidDataException;

class PublicKeyCredentialRpEntity extends PublicKeyCredentialEntity
{
    public function __construct(
        string $name,
        protected ?string $id = null,
        ?string $icon = null
    ) {
        parent::__construct($name, $icon);
    }

    public static function create(string $name, ?string $id = null, ?string $icon = null): self
    {
        return new self($name, $id, $icon);
    }

    public function getId(): ?string
    {
        return $this->id;
    }

    /**
     * @param mixed[] $json
     */
    public static function createFromArray(array $json): self
    {
        array_key_exists('name', $json) || throw InvalidDataException::create(
            $json,
            'Invalid input. "name" is missing.'
        );

        return new self($json['name'], $json['id'] ?? null, $json['icon'] ?? null);
    }

    /**
     * @return mixed[]
     */
    public function jsonSerialize(): array
    {
        $json = parent::jsonSerialize();
        if ($this->id !== null) {
            $json['id'] = $this->id;
        }

        return $json;
    }
}

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.