for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/*
* This file is part of the zibios/wrike-php-library package.
*
* (c) Zbigniew Ślązak
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Zibios\WrikePhpLibrary\Validator;
/**
* Request Id Validator.
class IdValidator
{
* @param mixed $value
* @return bool
public static function isNull($value): bool
return null === $value;
}
* @throws \InvalidArgumentException
public static function assertIsNull($value): void
if (false === self::isNull($value)) {
throw new \InvalidArgumentException('Null expected!');
public static function isValidIdString($value): bool
return \is_string($value) && '' !== trim($value);
public static function assertIsValidIdString($value): void
if (false === self::isValidIdString($value)) {
throw new \InvalidArgumentException(sprintf('Invalid Id, should be not empty string!'));
public static function isValidIdArray($value): bool
if (false === \is_array($value) || 0 === \count($value)) {
return false;
/** @var array $value */
foreach ($value as $id) {
if (false === self::isValidIdString($id)) {
return true;
public static function assertIsValidIdArray($value): void
if (false === self::isValidIdArray($value)) {
throw new \InvalidArgumentException('Invalid Id, should be not empty array!');