blob: ab878d98dbf1cd916518653fee1127a92b279667 (
plain) (
blame)
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
|
<?php
declare(strict_types=1);
namespace Bakame\Http\StructuredFields;
use OutOfBoundsException;
final class InvalidOffset extends OutOfBoundsException implements StructuredFieldError
{
private function __construct(string $message)
{
parent::__construct($message);
}
public static function dueToIndexNotFound(string|int $index): self
{
if (is_string($index)) {
return new self('The member index can not be the string "'.$index.'".');
}
return new self('No member exists with the index "'.$index.'".');
}
public static function dueToKeyNotFound(string|int $key): self
{
if (is_int($key)) {
return new self('The member key can not be the integer "'.$key.'".');
}
return new self('No member exists with the key "'.$key.'".');
}
public static function dueToMemberNotFound(string|int $offset): self
{
return new self('No member exists with the '.(is_int($offset) ? 'index' : 'key').' "'.$offset.'".');
}
}
|