1 | <?php |
||
29 | class Blank implements \Caridea\Validate\Rule |
||
30 | { |
||
31 | /** |
||
32 | * @var string The operator type |
||
33 | */ |
||
34 | private $operator; |
||
35 | |||
36 | /** |
||
37 | * Creates a new EmptyRule. |
||
38 | * |
||
39 | * @param string $operator The operator type |
||
40 | */ |
||
41 | 3 | protected function __construct(string $operator) |
|
45 | |||
46 | /** |
||
47 | * {@inheritDoc} |
||
48 | */ |
||
49 | 3 | public function apply($value, $data = []): ?array |
|
65 | |||
66 | /** |
||
67 | * Gets a rule that requires values to be non-null and not empty string. |
||
68 | * |
||
69 | * @return \Caridea\Validate\Rule\Blank the created rule |
||
70 | */ |
||
71 | 1 | public static function required(): Blank |
|
75 | |||
76 | /** |
||
77 | * Gets a rule that requires strings to be non-empty. |
||
78 | * |
||
79 | * @return \Caridea\Validate\Rule\Blank |
||
80 | */ |
||
81 | 1 | public static function notEmpty(): Blank |
|
85 | |||
86 | /** |
||
87 | * Gets a rule that requires an array or `Countable` to be non-empty. |
||
88 | * |
||
89 | * @return \Caridea\Validate\Rule\Blank |
||
90 | */ |
||
91 | 1 | public static function notEmptyList(): Blank |
|
95 | } |
||
96 |
As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next
break
.There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.