|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Povs\ListerBundle\Exception; |
|
4
|
|
|
|
|
5
|
|
|
use Povs\ListerBundle\Type\ListType\ListTypeInterface; |
|
6
|
|
|
use RuntimeException; |
|
7
|
|
|
use Throwable; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* @author Povilas Margaiatis <[email protected]> |
|
11
|
|
|
*/ |
|
12
|
|
|
class ListException extends RuntimeException |
|
13
|
|
|
{ |
|
14
|
38 |
|
public function __construct($message = '', $code = 500, Throwable $previous = null) |
|
15
|
|
|
{ |
|
16
|
38 |
|
parent::__construct($message, $code, $previous); |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @return ListException |
|
21
|
|
|
*/ |
|
22
|
2 |
|
public static function listNotConfigured(): ListException |
|
23
|
|
|
{ |
|
24
|
2 |
|
return new self(sprintf('List is not yet configured to be copied.')); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @param string $typeName |
|
29
|
|
|
* |
|
30
|
|
|
* @return ListException |
|
31
|
|
|
*/ |
|
32
|
2 |
|
public static function listTypeNotConfigured(string $typeName): ListException |
|
33
|
|
|
{ |
|
34
|
2 |
|
return new self(sprintf('List type "%s" is not configured', $typeName)); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @return ListException |
|
39
|
|
|
*/ |
|
40
|
3 |
|
public static function listNotBuilt(): ListException |
|
41
|
|
|
{ |
|
42
|
3 |
|
return new self(sprintf('List is not built. BuiltList method is required before generating')); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @param string $typeClassName |
|
47
|
|
|
* |
|
48
|
|
|
* @return ListException |
|
49
|
|
|
*/ |
|
50
|
2 |
|
public static function invalidListType(string $typeClassName): ListException |
|
51
|
|
|
{ |
|
52
|
2 |
|
return new self(sprintf( |
|
53
|
2 |
|
'List type "%s" does not exists or does not implements %s', |
|
54
|
2 |
|
$typeClassName, |
|
55
|
2 |
|
ListTypeInterface::class |
|
56
|
2 |
|
)); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @param string $typeName |
|
61
|
|
|
* @param string $message |
|
62
|
|
|
* |
|
63
|
|
|
* @return ListException |
|
64
|
|
|
*/ |
|
65
|
2 |
|
public static function invalidTypeConfiguration(string $typeName, string $message): ListException |
|
66
|
|
|
{ |
|
67
|
2 |
|
return new self(sprintf('Invalid type "%s" configuration. %s', $typeName, $message)); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @param string $typeName |
|
72
|
|
|
* @param string $message |
|
73
|
|
|
* |
|
74
|
|
|
* @return ListException |
|
75
|
|
|
*/ |
|
76
|
2 |
|
public static function invalidTypeOptions(string $typeName, string $message): ListException |
|
77
|
|
|
{ |
|
78
|
2 |
|
return new self(sprintf('Invalid type "%s" options. %s', $typeName, $message)); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @return ListException |
|
83
|
|
|
*/ |
|
84
|
2 |
|
public static function missingTranslator(): ListException |
|
85
|
|
|
{ |
|
86
|
2 |
|
$message = 'Translator could not be found. Please install it running "composer require symfony/translation" or change list configuration'; |
|
87
|
|
|
|
|
88
|
2 |
|
return new self($message); |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|