47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
namespace KTXF\Resource\Selector;
|
|
|
|
/**
|
|
* Entity-level selector (leaf node)
|
|
*/
|
|
class EntitySelector extends SelectorAbstract {
|
|
|
|
protected array $keyTypes = ['string', 'integer'];
|
|
protected array $valueTypes = ['boolean', 'array', 'string', 'integer'];
|
|
protected string $selectorName = 'EntitySelector';
|
|
|
|
public function append($value): void {
|
|
if (!is_string($value) && !is_int($value)) {
|
|
throw new \InvalidArgumentException('EntitySelector values must be string or int');
|
|
}
|
|
parent::append($value);
|
|
}
|
|
|
|
public function offsetSet($key, $value): void {
|
|
if ($key !== null && !is_int($key)) {
|
|
throw new \InvalidArgumentException('EntitySelector does not support associative keys');
|
|
}
|
|
if (!is_string($value) && !is_int($value)) {
|
|
throw new \InvalidArgumentException('EntitySelector values must be string or int');
|
|
}
|
|
parent::offsetSet($key, $value);
|
|
}
|
|
|
|
/**
|
|
* Get all entity identifiers
|
|
* @return array<string|int>
|
|
*/
|
|
public function identifiers(): array {
|
|
return $this->getArrayCopy();
|
|
}
|
|
|
|
}
|