@@ -33,8 +33,9 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function __construct(Rule... $rules) |
35 | 35 | { |
36 | - if (empty($rules)) |
|
37 | - throw new InvalidAggregateRule("No rules specified for aggregate rule", ForAll::class); |
|
36 | + if (empty($rules)) { |
|
37 | + throw new InvalidAggregateRule("No rules specified for aggregate rule", ForAll::class); |
|
38 | + } |
|
38 | 39 | $this->rules = $rules; |
39 | 40 | } |
40 | 41 | |
@@ -65,9 +66,9 @@ discard block |
||
65 | 66 | |
66 | 67 | } |
67 | 68 | |
68 | - if (!($errors)) |
|
69 | - return new Success(); |
|
70 | - else { |
|
69 | + if (!($errors)) { |
|
70 | + return new Success(); |
|
71 | + } else { |
|
71 | 72 | return new Failure(...$errors); // Use the splat operator |
72 | 73 | |
73 | 74 | } |
@@ -44,12 +44,14 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function __construct(int $numOfRules, Rule... $rules) |
46 | 46 | { |
47 | - if (empty($rules)) |
|
48 | - throw new InvalidAggregateRule("No rules specified for aggregate rule", ForAtLeast::class); |
|
47 | + if (empty($rules)) { |
|
48 | + throw new InvalidAggregateRule("No rules specified for aggregate rule", ForAtLeast::class); |
|
49 | + } |
|
49 | 50 | |
50 | - if (count($rules) < $numOfRules) |
|
51 | - throw new InvalidAggregateRule('Minimum passing rule number is greater than supplied rules', |
|
51 | + if (count($rules) < $numOfRules) { |
|
52 | + throw new InvalidAggregateRule('Minimum passing rule number is greater than supplied rules', |
|
52 | 53 | ForAtLeast::class); |
54 | + } |
|
53 | 55 | |
54 | 56 | $this->rules = $rules; |
55 | 57 | $this->minimum = $numOfRules; |
@@ -74,13 +76,13 @@ discard block |
||
74 | 76 | foreach ($result->getErrors() as $error) { |
75 | 77 | $errors[] = $error; |
76 | 78 | } |
77 | - } |
|
78 | - else { |
|
79 | + } else { |
|
79 | 80 | $passed++; |
80 | 81 | } |
81 | 82 | |
82 | - if ($passed >= $this->minimum) |
|
83 | - return new Success(); |
|
83 | + if ($passed >= $this->minimum) { |
|
84 | + return new Success(); |
|
85 | + } |
|
84 | 86 | } |
85 | 87 | return new Failure(...$errors); |
86 | 88 | } |