CoreFiles by mySites.guru
SymmetricKey.php44 lines, 985 bytes, from Joomla_5.0.0-alpha1-Alpha-Full_Package.zip
Raw History Compare with 4.4.0-alpha4
md5
d9b0b45633f840049a689c7ebd7e51b4
sha1
704407c277137d72a6aff103c04b72a6296b7aad
sha256
82a4b216ca8f7a7ec0416fe76636db4e2281c9492fc3d4c34e4833b838fd3bf8
<?php

declare(strict_types=1);

namespace Cose\Key;

use InvalidArgumentException;

/**
 * @final
 */
class SymmetricKey extends Key
{
    final public const DATA_K = -1;

    /**
     * @param array<int|string, mixed> $data
     */
    public function __construct(array $data)
    {
        parent::__construct($data);
        if (! isset($data[self::TYPE]) || (int) $data[self::TYPE] !== self::TYPE_OCT) {
            throw new InvalidArgumentException(
                'Invalid symmetric key. The key type does not correspond to a symmetric key'
            );
        }
        if (! isset($data[self::DATA_K])) {
            throw new InvalidArgumentException('Invalid symmetric key. The parameter "k" is missing');
        }
    }

    /**
     * @param array<int|string, mixed> $data
     */
    public static function create(array $data): self
    {
        return new self($data);
    }

    public function k(): string
    {
        return $this->get(self::DATA_K);
    }
}

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.