1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Smoren\Schemator\Structs; |
6
|
|
|
|
7
|
|
|
use Smoren\Schemator\Exceptions\SchematorException; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class ErrorsLevelMask |
11
|
|
|
* @author Smoren <[email protected]> |
12
|
|
|
*/ |
13
|
|
|
class ErrorsLevelMask extends Bitmap |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @param $value |
17
|
|
|
* @return ErrorsLevelMask |
18
|
|
|
*/ |
19
|
|
|
public static function create($value): ErrorsLevelMask |
20
|
|
|
{ |
21
|
|
|
/** @var ErrorsLevelMask $result */ |
22
|
|
|
$result = parent::create($value); |
23
|
|
|
return $result; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Creates bitmap of all errors |
28
|
|
|
* @return ErrorsLevelMask |
29
|
|
|
*/ |
30
|
|
|
public static function all(): ErrorsLevelMask |
31
|
|
|
{ |
32
|
|
|
return static::create([ |
33
|
|
|
SchematorException::FILTER_NOT_FOUND, |
34
|
|
|
SchematorException::FILTER_ERROR, |
35
|
|
|
SchematorException::CANNOT_GET_VALUE, |
36
|
|
|
SchematorException::UNSUPPORTED_SOURCE_TYPE, |
37
|
|
|
SchematorException::UNSUPPORTED_KEY_TYPE, |
38
|
|
|
SchematorException::UNSUPPORTED_FILTER_CONFIG_TYPE, |
39
|
|
|
SchematorException::BAD_FILTER_CONFIG, |
40
|
|
|
SchematorException::BAD_FILTER_SOURCE, |
41
|
|
|
]); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Creates bitmap of default errors |
46
|
|
|
* @return ErrorsLevelMask |
47
|
|
|
*/ |
48
|
|
|
public static function default(): ErrorsLevelMask |
49
|
|
|
{ |
50
|
|
|
return static::create([ |
51
|
|
|
SchematorException::FILTER_NOT_FOUND, |
52
|
|
|
SchematorException::UNSUPPORTED_SOURCE_TYPE, |
53
|
|
|
SchematorException::UNSUPPORTED_KEY_TYPE, |
54
|
|
|
SchematorException::UNSUPPORTED_FILTER_CONFIG_TYPE, |
55
|
|
|
SchematorException::BAD_FILTER_CONFIG, |
56
|
|
|
]); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Creates bitmap of no errors |
61
|
|
|
* @return ErrorsLevelMask |
62
|
|
|
*/ |
63
|
|
|
public static function nothing(): ErrorsLevelMask |
64
|
|
|
{ |
65
|
|
|
return static::create([]); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|