@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * |
| 66 | 66 | * @return CompositeRuleInterface |
| 67 | 67 | */ |
| 68 | - public static function or(array $rules, string $name = RuleName::OR): CompositeRuleInterface |
|
| 68 | + public static function or(array $rules, string $name = RuleName:: OR ): CompositeRuleInterface |
|
| 69 | 69 | { |
| 70 | 70 | return new OrRule($rules, $name); |
| 71 | 71 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @return CompositeRuleInterface |
| 78 | 78 | */ |
| 79 | - public static function and(array $rules, string $name = RuleName::AND): CompositeRuleInterface |
|
| 79 | + public static function and(array $rules, string $name = RuleName:: AND ): CompositeRuleInterface |
|
| 80 | 80 | { |
| 81 | 81 | return new AndRule($rules, $name); |
| 82 | 82 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | { |
| 36 | 36 | return $this->check( |
| 37 | 37 | CheckBuilder::create(CheckName::EVEN, CheckErrorName::NOT_EVEN) |
| 38 | - ->withPredicate(fn ($value) => $value % 2 === 0) |
|
| 38 | + ->withPredicate(fn ($value) => $value%2 === 0) |
|
| 39 | 39 | ->build() |
| 40 | 40 | ); |
| 41 | 41 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | { |
| 50 | 50 | return $this->check( |
| 51 | 51 | CheckBuilder::create(CheckName::ODD, CheckErrorName::NOT_ODD) |
| 52 | - ->withPredicate(fn ($value) => $value % 2 !== 0) |
|
| 52 | + ->withPredicate(fn ($value) => $value%2 !== 0) |
|
| 53 | 53 | ->build() |
| 54 | 54 | ); |
| 55 | 55 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | { |
| 36 | 36 | return $this->check( |
| 37 | 37 | CheckBuilder::create(CheckName::FRACTIONAL, CheckErrorName::NOT_FRACTIONAL) |
| 38 | - ->withPredicate(fn ($value) => \abs($value - \round($value)) >= \PHP_FLOAT_EPSILON) |
|
| 38 | + ->withPredicate(fn ($value) => \abs($value-\round($value)) >= \PHP_FLOAT_EPSILON) |
|
| 39 | 39 | ->build() |
| 40 | 40 | ); |
| 41 | 41 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | { |
| 50 | 50 | return $this->check( |
| 51 | 51 | CheckBuilder::create(CheckName::NOT_FRACTIONAL, CheckErrorName::FRACTIONAL) |
| 52 | - ->withPredicate(fn ($value) => \abs($value - \round($value)) < \PHP_FLOAT_EPSILON) |
|
| 52 | + ->withPredicate(fn ($value) => \abs($value-\round($value)) < \PHP_FLOAT_EPSILON) |
|
| 53 | 53 | ->build() |
| 54 | 54 | ); |
| 55 | 55 | } |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | { |
| 188 | 188 | return $this->check( |
| 189 | 189 | CheckBuilder::create(CheckName::LENGTH_IS, CheckErrorName::INVALID_LENGTH) |
| 190 | - ->withPredicate(static function ($value) use ($rule) { |
|
| 190 | + ->withPredicate(static function($value) use ($rule) { |
|
| 191 | 191 | /** @var \Countable $value */ |
| 192 | 192 | $rule->validate(\count($value)); |
| 193 | 193 | return true; |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | |
| 211 | 211 | return $this->check( |
| 212 | 212 | CheckBuilder::create(CheckName::HAS_ATTRIBUTE, CheckErrorName::INVALID_ATTRIBUTE) |
| 213 | - ->withPredicate(static function ($value, string $name) use ($rule) { |
|
| 213 | + ->withPredicate(static function($value, string $name) use ($rule) { |
|
| 214 | 214 | $rule->validate(ContainerAccessHelper::getAttributeValue($value, $name)); |
| 215 | 215 | return true; |
| 216 | 216 | }) |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | { |
| 230 | 230 | return $this->check( |
| 231 | 231 | CheckBuilder::create(CheckName::HAS_ATTRIBUTE, CheckErrorName::INVALID_ATTRIBUTE) |
| 232 | - ->withPredicate(static function ($value) use ($name, $rule) { |
|
| 232 | + ->withPredicate(static function($value) use ($name, $rule) { |
|
| 233 | 233 | if (!ContainerAccessHelper::hasAccessibleAttribute($value, $name)) { |
| 234 | 234 | return true; |
| 235 | 235 | } |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | { |
| 251 | 251 | return $this->check( |
| 252 | 252 | CheckBuilder::create(CheckName::ALL_KEYS_ARE, CheckErrorName::SOME_KEYS_INVALID) |
| 253 | - ->withPredicate(static function ($value) use ($rule) { |
|
| 253 | + ->withPredicate(static function($value) use ($rule) { |
|
| 254 | 254 | foreach ($value as $k => $v) { |
| 255 | 255 | $rule->validate($k); |
| 256 | 256 | } |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | { |
| 271 | 271 | return $this->check( |
| 272 | 272 | CheckBuilder::create(CheckName::ALL_VALUES_ARE, CheckErrorName::SOME_VALUES_INVALID) |
| 273 | - ->withPredicate(static function ($value) use ($rule) { |
|
| 273 | + ->withPredicate(static function($value) use ($rule) { |
|
| 274 | 274 | foreach ($value as $v) { |
| 275 | 275 | $rule->validate($v); |
| 276 | 276 | } |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | { |
| 86 | 86 | return $this->check( |
| 87 | 87 | CheckBuilder::create(CheckName::ENDS_WITH, CheckErrorName::NOT_ENDS_WITH) |
| 88 | - ->withPredicate(static function ($value, string $substr) { |
|
| 89 | - return \substr($value, \mb_strlen($value) - \mb_strlen($substr)) === $substr; |
|
| 88 | + ->withPredicate(static function($value, string $substr) { |
|
| 89 | + return \substr($value, \mb_strlen($value)-\mb_strlen($substr)) === $substr; |
|
| 90 | 90 | }) |
| 91 | 91 | ->withParams(['substring' => $substr]) |
| 92 | 92 | ->build() |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | { |
| 98 | 98 | return $this->check( |
| 99 | 99 | CheckBuilder::create(CheckName::LENGTH_IS, CheckErrorName::INVALID_LENGTH) |
| 100 | - ->withPredicate(static function ($value) use ($rule) { |
|
| 100 | + ->withPredicate(static function($value) use ($rule) { |
|
| 101 | 101 | /** @var string $value */ |
| 102 | 102 | $rule->validate(\mb_strlen($value)); |
| 103 | 103 | return true; |