1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the eav package. |
4
|
|
|
* @author Aleksandr Drobotik <[email protected]> |
5
|
|
|
* @copyright 2023 Aleksandr Drobotik |
6
|
|
|
* @license https://opensource.org/license/mit The MIT License |
7
|
|
|
*/ |
8
|
|
|
declare(strict_types=1); |
9
|
|
|
|
10
|
|
|
namespace Drobotik\Eav\Exception; |
11
|
|
|
|
12
|
|
|
use Exception; |
13
|
|
|
|
14
|
|
|
class EntityException extends Exception |
15
|
|
|
{ |
16
|
|
|
public const UNDEFINED_DOMAIN_KEY = 'Undefined domain key'; |
17
|
|
|
public const UNDEFINED_ATTRIBUTE_SET_KEY = 'Undefined attribute set key'; |
18
|
|
|
public const DOMAIN_NOT_FOUND = 'Domain not found'; |
19
|
|
|
public const ATTR_SET_NOT_FOUND = 'Attribute set not found'; |
20
|
|
|
public const UNDEFINED_ENTITY_KEY = "Undefined entity key"; |
21
|
|
|
public const ENTITY_NOT_FOUND = 'Entity not found'; |
22
|
|
|
public const MUST_BE_POSITIVE_AMOUNT = 'Must be positive amount'; |
23
|
|
|
public const MUST_BE_ENTITY_KEY = 'Must be entity key'; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* |
27
|
|
|
* @throws EntityException |
28
|
|
|
*/ |
29
|
1 |
|
public static function undefinedDomainKey() { |
30
|
1 |
|
throw new static(self::UNDEFINED_DOMAIN_KEY); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* |
35
|
|
|
* @throws EntityException |
36
|
|
|
*/ |
37
|
1 |
|
public static function domainNotFound() { |
38
|
1 |
|
throw new static(self::DOMAIN_NOT_FOUND); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* |
43
|
|
|
* @throws EntityException |
44
|
|
|
*/ |
45
|
1 |
|
public static function undefinedAttributeSetKey() { |
46
|
1 |
|
throw new static(self::UNDEFINED_ATTRIBUTE_SET_KEY); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* |
51
|
|
|
* @throws EntityException |
52
|
|
|
*/ |
53
|
1 |
|
public static function attrSetNotFound() { |
54
|
1 |
|
throw new static(self::ATTR_SET_NOT_FOUND); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* |
59
|
|
|
* @throws EntityException |
60
|
|
|
*/ |
61
|
1 |
|
public static function undefinedEntityKey() { |
62
|
1 |
|
throw new static(self::UNDEFINED_ENTITY_KEY); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* |
67
|
|
|
* @throws EntityException |
68
|
|
|
*/ |
69
|
1 |
|
public static function entityNotFound() { |
70
|
1 |
|
throw new static(self::ENTITY_NOT_FOUND); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* |
75
|
|
|
* @throws EntityException |
76
|
|
|
*/ |
77
|
1 |
|
public static function mustBePositiveAmount() { |
78
|
1 |
|
throw new static(self::MUST_BE_POSITIVE_AMOUNT); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* |
83
|
|
|
* @throws EntityException |
84
|
|
|
*/ |
85
|
1 |
|
public static function mustBeEntityKey() { |
86
|
1 |
|
throw new static(self::MUST_BE_ENTITY_KEY); |
87
|
|
|
} |
88
|
|
|
} |