@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @return RuleSet[] |
17 | 17 | * @throws ReflectionException if the class does not exist |
18 | 18 | */ |
19 | - public static function fromProperties(string|object $objectOrClass, ?int $filter = null): array |
|
19 | + public static function fromProperties(string | object $objectOrClass, ?int $filter = null): array |
|
20 | 20 | { |
21 | 21 | $ruleSets = []; |
22 | 22 | foreach ((new ReflectionClass($objectOrClass))->getProperties($filter) as $property) { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @return RuleSet[] |
33 | 33 | * @throws ReflectionException |
34 | 34 | */ |
35 | - public static function fromMethods(string|object $objectOrClass, ?int $filter = null): array |
|
35 | + public static function fromMethods(string | object $objectOrClass, ?int $filter = null): array |
|
36 | 36 | { |
37 | 37 | $ruleSets = []; |
38 | 38 | foreach ((new ReflectionClass($objectOrClass))->getMethods($filter) as $method) { |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @return RuleSet |
49 | 49 | * @throws ReflectionException if the class or property does not exist. |
50 | 50 | */ |
51 | - public static function fromProperty(string|object $objectOrClass, string $property): RuleSet |
|
51 | + public static function fromProperty(string | object $objectOrClass, string $property): RuleSet |
|
52 | 52 | { |
53 | 53 | return self::fromReflectionProperty(new ReflectionProperty($objectOrClass, $property)); |
54 | 54 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @return RuleSet |
60 | 60 | * @throws ReflectionException |
61 | 61 | */ |
62 | - public static function fromMethod(string|object $objectOrClass, string $method): RuleSet |
|
62 | + public static function fromMethod(string | object $objectOrClass, string $method): RuleSet |
|
63 | 63 | { |
64 | 64 | return self::fromReflectionMethod(new ReflectionMethod($objectOrClass, $method)); |
65 | 65 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | $number = substr($stringInput, 0, -1); |
33 | 33 | $digit = (int) substr($stringInput, -1); |
34 | 34 | return |
35 | - $digit === match ($this->algorithm) { |
|
35 | + $digit === match($this->algorithm) { |
|
36 | 36 | self::MOD11 => self::mod11($number), |
37 | 37 | self::MOD10 => self::mod10($number), |
38 | 38 | default => throw new InvalidArgumentException('Algoritmo de cálculo de dígito inválido') |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $sum += $number * $factor[$i++ % $size]; |
50 | 50 | } |
51 | 51 | |
52 | - $mod11 = ($sum * 10 ) % 11; |
|
52 | + $mod11 = ($sum * 10) % 11; |
|
53 | 53 | return $modReturn[$mod11] ?? 11 - $mod11; |
54 | 54 | } |
55 | 55 | |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | |
76 | 76 | $modReturn = [0 => 0, 1 => 0]; |
77 | 77 | $digit1 = DigitoVerificador::mod11($number, $modReturn); |
78 | - $digit2 = DigitoVerificador::mod11($number . $digit1, $modReturn); |
|
78 | + $digit2 = DigitoVerificador::mod11($number.$digit1, $modReturn); |
|
79 | 79 | |
80 | - return $digits === ($digit1 . $digit2); |
|
80 | + return $digits === ($digit1.$digit2); |
|
81 | 81 | } |
82 | 82 | } |
@@ -16,11 +16,11 @@ |
||
16 | 16 | */ |
17 | 17 | trait RuleChain |
18 | 18 | { |
19 | - abstract public function add(Rule|RuleSet ...$rules): static; |
|
19 | + abstract public function add(Rule | RuleSet ...$rules): static; |
|
20 | 20 | |
21 | 21 | public function __call($name, $arguments): static |
22 | 22 | { |
23 | - $namespace = __NAMESPACE__ . '\\Rules'; |
|
23 | + $namespace = __NAMESPACE__.'\\Rules'; |
|
24 | 24 | $class = sprintf("%s\%s", $namespace, ucfirst($name)); |
25 | 25 | if (!class_exists($class)) { |
26 | 26 | throw new RuntimeException(sprintf('Rule not found: (%s).', $name)); |
@@ -7,7 +7,7 @@ |
||
7 | 7 | { |
8 | 8 | private static TranslatorInterface $default; |
9 | 9 | |
10 | - public static function setDefault(TranslatorInterface|callable $translator, bool $compose = true): void |
|
10 | + public static function setDefault(TranslatorInterface | callable $translator, bool $compose = true): void |
|
11 | 11 | { |
12 | 12 | if ($translator instanceof TranslatorInterface) { |
13 | 13 | self::$default = $translator; |
@@ -33,7 +33,7 @@ |
||
33 | 33 | $error['field'] ?? '_error', |
34 | 34 | $error['message'], |
35 | 35 | $error['type'] ?? '' |
36 | - ) . PHP_EOL; |
|
36 | + ).PHP_EOL; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | return $errors; |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @param Rule|RuleSet ...$rules |
40 | 40 | * @return $this |
41 | 41 | */ |
42 | - public function field(string $field, Rule|RuleSet ...$rules): self |
|
42 | + public function field(string $field, Rule | RuleSet ...$rules): self |
|
43 | 43 | { |
44 | 44 | $ruleSet = $this->ruleSets[$field] ?? RuleSet::of($field); |
45 | 45 | $this->ruleSets[$field] = $ruleSet->add(...$rules); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $errorReporting = new ErrorReporting; |
53 | 53 | foreach ($this->ruleSets as $field => $fieldRuleSet) { |
54 | 54 | $fieldRuleSet = $fieldRuleSet->withField($field); |
55 | - if (! $this->shouldValidate($fieldRuleSet, $data)) { |
|
55 | + if (!$this->shouldValidate($fieldRuleSet, $data)) { |
|
56 | 56 | continue; |
57 | 57 | } |
58 | 58 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @return static |
118 | 118 | * @throws ReflectionException if the class does not exist |
119 | 119 | */ |
120 | - public static function fromProperties(string|object $objectOrClass, ?int $filter = null): self |
|
120 | + public static function fromProperties(string | object $objectOrClass, ?int $filter = null): self |
|
121 | 121 | { |
122 | 122 | $instance = new self; |
123 | 123 | $instance->ruleSets = RuleSetFactory::fromProperties($objectOrClass, $filter); |
@@ -41,8 +41,7 @@ discard block |
||
41 | 41 | { |
42 | 42 | return |
43 | 43 | $this->hasOwnMessage() ? |
44 | - Translator::translate(static::MESSAGE) : |
|
45 | - Translator::translate(static::MESSAGE, $this->className()); |
|
44 | + Translator::translate(static::MESSAGE) : Translator::translate(static::MESSAGE, $this->className()); |
|
46 | 45 | } |
47 | 46 | |
48 | 47 | /** @inheritDoc */ |
@@ -50,8 +49,7 @@ discard block |
||
50 | 49 | { |
51 | 50 | return |
52 | 51 | $this->isValid($input, $context) ? |
53 | - ErrorReporting::success() : |
|
54 | - (new ErrorReporting)->addError($this->message(), $this->getField(), $this); |
|
52 | + ErrorReporting::success() : (new ErrorReporting)->addError($this->message(), $this->getField(), $this); |
|
55 | 53 | } |
56 | 54 | |
57 | 55 | protected function className(): string |
@@ -28,7 +28,7 @@ |
||
28 | 28 | |
29 | 29 | public static function sortByPriority(array &$haystack): void |
30 | 30 | { |
31 | - uasort($haystack, function ($a, $b) { |
|
31 | + uasort($haystack, function($a, $b) { |
|
32 | 32 | $prorityOfA = $a instanceof Prioritable ? $a->getPriority() : Prioritable::LOWEST_PRIORITY; |
33 | 33 | $prorityOfB = $b instanceof Prioritable ? $b->getPriority() : Prioritable::LOWEST_PRIORITY; |
34 | 34 |
@@ -34,8 +34,7 @@ |
||
34 | 34 | $other = new DateTimeImmutable($this->datetime); |
35 | 35 | $datetime = |
36 | 36 | $input instanceof DateTimeInterface ? |
37 | - $input : |
|
38 | - new DateTimeImmutable($input); |
|
37 | + $input : new DateTimeImmutable($input); |
|
39 | 38 | |
40 | 39 | return $this->compare($datetime, $this->operator, $other); |
41 | 40 | } catch (Throwable) { |