Initial xentral_oss_20.3.c9ffacf

This commit is contained in:
Alex
2021-05-21 08:49:41 +02:00
parent 5406e4a551
commit 34e5ac43d9
18884 changed files with 2109867 additions and 0 deletions
@@ -0,0 +1,55 @@
<?php
namespace Xentral\Widgets\SuperSearch\Query;
use Xentral\Widgets\SuperSearch\Exception\InvalidArgumentException;
final class DetailQuery
{
/** @var string $groupKey */
private $groupKey;
/** @var int|string $itemIdentifier */
private $itemIdentifier;
/**
* @param string $groupKey
* @param int|string $itemIdentifier
*
* @throws InvalidArgumentException
*/
public function __construct($groupKey, $itemIdentifier)
{
$groupKeyCleaned = (string)preg_replace('#[^a-z_]#', '', $groupKey);
if ($groupKey !== $groupKeyCleaned) {
throw new InvalidArgumentException(
'Invalid characters in $groupKey. Allowed characters: a-z and underscore.'
);
}
if (!is_int($itemIdentifier) && !is_string($itemIdentifier)) {
throw new InvalidArgumentException(sprintf(
'Invalid argument type for $itemIdentifier. Only integer or string is allowed. Type given: %s.',
gettype($itemIdentifier)
));
}
$this->groupKey = (string)$groupKey;
$this->itemIdentifier = $itemIdentifier;
}
/**
* @return string
*/
public function getGroupKey()
{
return $this->groupKey;
}
/**
* @return int|string
*/
public function getItemIdentifier()
{
return $this->itemIdentifier;
}
}