This repository was archived by the owner on Mar 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66
77class GreaterThan extends AbstractRule implements RuleInterface
88{
9+ private string $ message ;
10+
911 public function __construct (
1012 private readonly mixed $ constraint ,
11- private ? string $ message = null )
13+ string $ message = null )
1214 {
13- $ this ->message ??= 'The "{{ name }}" value should be greater than "{{ constraint }}", "{{ value }}" given. ' ;
15+ $ this ->message = $ message ?? 'The "{{ name }}" value should be greater than "{{ constraint }}", "{{ value }}" given. ' ;
1416 }
1517
1618 /**
@@ -40,17 +42,17 @@ public function validate(mixed $value): void
4042 }
4143 }
4244
43- protected function canBeCompared (mixed $ constraint , mixed $ value ): bool
45+ protected function canBeCompared (mixed $ value1 , mixed $ value2 ): bool
4446 {
45- if ($ constraint instanceof \DateTimeInterface && $ value instanceof \DateTimeInterface) {
47+ if ($ value1 instanceof \DateTimeInterface && $ value2 instanceof \DateTimeInterface) {
4648 return true ;
4749 }
4850
49- if (\is_numeric ($ constraint ) && \is_numeric ($ value )) {
51+ if (\is_numeric ($ value1 ) && \is_numeric ($ value2 )) {
5052 return true ;
5153 }
5254
53- if (\is_string ($ constraint ) && \is_string ($ value )) {
55+ if (\is_string ($ value1 ) && \is_string ($ value2 )) {
5456 return true ;
5557 }
5658
Original file line number Diff line number Diff line change 66
77class NotBlank extends AbstractRule implements RuleInterface
88{
9- public function __construct (private ?string $ message = null )
9+ private string $ message ;
10+
11+ public function __construct (string $ message = null )
1012 {
11- $ this ->message ??= 'The "{{ name }}" value should not be blank, "{{ value }}" given. ' ;
13+ $ this ->message = $ message ?? 'The "{{ name }}" value should not be blank, "{{ value }}" given. ' ;
1214 }
1315
1416 /**
1517 * @throws NotBlankException
1618 */
1719 public function validate (mixed $ value ): void
1820 {
19- // Keep value unchanged for parameters
20- $ input = $ value ;
21-
2221 // Do not allow null, false, [] and ''
23- if ($ input === false || (empty ($ input ) && $ input != '0 ' )) {
22+ if ($ value === false || (empty ($ value ) && $ value != '0 ' )) {
2423 throw new NotBlankException (
2524 message: $ this ->message ,
2625 parameters: [
You can’t perform that action at this time.
0 commit comments