1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Povs\ListerBundle\Exception; |
4
|
|
|
|
5
|
|
|
use Throwable; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* @author Povilas Margaiatis <[email protected]> |
9
|
|
|
*/ |
10
|
|
|
class ListFieldException extends ListException |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @var string |
14
|
|
|
*/ |
15
|
|
|
private $fieldId; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* ListFieldException constructor. |
19
|
|
|
* |
20
|
|
|
* @param string $id fieldId |
21
|
|
|
* @param string $message |
22
|
|
|
* @param int $code |
23
|
|
|
* @param Throwable|null $previous |
24
|
|
|
*/ |
25
|
17 |
|
public function __construct(string $id, string $message = '', $code = 500, Throwable $previous = null) |
26
|
|
|
{ |
27
|
17 |
|
parent::__construct($message, $code, $previous); |
28
|
17 |
|
$this->fieldId = $id; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @param string $id |
33
|
|
|
* @param string $message |
34
|
|
|
* |
35
|
|
|
* @return ListException |
36
|
|
|
*/ |
37
|
4 |
|
public static function invalidFieldConfiguration(string $id, string $message): ListException |
38
|
|
|
{ |
39
|
4 |
|
return new self($id, sprintf('Invalid field "%s" configuration. %s', $id, $message)); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param string $id |
44
|
|
|
* |
45
|
|
|
* @return ListException |
46
|
|
|
*/ |
47
|
4 |
|
public static function fieldNotExists(string $id): ListException |
48
|
|
|
{ |
49
|
4 |
|
return new self($id, sprintf('Field "%s" do not exists', $id)); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @param string $id |
54
|
|
|
* |
55
|
|
|
* @return ListException |
56
|
|
|
*/ |
57
|
3 |
|
public static function invalidPropertiesOption(string $id): ListException |
58
|
|
|
{ |
59
|
3 |
|
return new self($id, sprintf('"%s" - properties can only be set for a single path', $id)); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @param string $path join path |
64
|
|
|
* |
65
|
|
|
* @return ListException |
66
|
|
|
*/ |
67
|
2 |
|
public static function invalidPath(string $path): ListException |
68
|
|
|
{ |
69
|
2 |
|
return new self($path, sprintf('Could not find join for path "%s"', $path)); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @param string $id field id |
74
|
|
|
* @param string $type type fully qualified class name |
75
|
|
|
* @param string $definition type interface fully qualified name |
76
|
|
|
* |
77
|
|
|
* @return ListException |
78
|
|
|
*/ |
79
|
3 |
|
public static function invalidType(string $id, string $type, string $definition): ListException |
80
|
|
|
{ |
81
|
3 |
|
$message = sprintf('Type "%s" does not exist or does not implement %s', $type, $definition); |
82
|
|
|
|
83
|
3 |
|
return new self($id, $message); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @return string |
88
|
|
|
*/ |
89
|
1 |
|
public function getFieldId(): string |
90
|
|
|
{ |
91
|
1 |
|
return $this->fieldId; |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|