-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathInvalidArgument.php
More file actions
48 lines (39 loc) · 1.14 KB
/
InvalidArgument.php
File metadata and controls
48 lines (39 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
declare(strict_types=1);
namespace SimPod\GraphQLUtils\Exception;
use Exception;
use GraphQL\Error\ClientAware;
use GraphQL\Utils\Utils;
use SimPod\GraphQLUtils\Builder\TypeBuilder;
use Throwable;
use function sprintf;
final class InvalidArgument extends Exception implements ClientAware
{
private function __construct(string $message = '', int $code = 0, Throwable|null $previous = null)
{
parent::__construct($message, $code, $previous);
}
public static function invalidNameFormat(string $invalidName): self
{
return new self(sprintf(
'Name "%s" does not match pattern "%s"',
$invalidName,
TypeBuilder::VALID_NAME_PATTERN,
));
}
public static function valueNotIso8601Compliant(mixed $invalidValue): self
{
return new self(sprintf(
'DateTime type expects input value to be ISO 8601 compliant. Given invalid value "%s"',
Utils::printSafeJson($invalidValue),
));
}
public function isClientSafe(): bool
{
return true;
}
public function getCategory(): string
{
return '';
}
}