Skip to content

Commit a79536d

Browse files
committed
Merge branch 'develop'
2 parents a293d6f + 7dc73b8 commit a79536d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/ValidationRulesRegistrar.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace StellarWP\Validation;
66

7-
use StellarWP\Exceptions\Primitives\InvalidArgumentException;
87
use StellarWP\Validation\Contracts\ValidationRule;
98

109
/**
@@ -32,26 +31,29 @@ public function register(string ...$rules): self
3231
/**
3332
* Register a validation rule.
3433
*
34+
* @unreleased switch to throwing InvalidArgumentException from Config
3535
* @since 1.0.0
3636
*/
3737
private function registerClass(string $class): self
3838
{
3939
if (!is_subclass_of($class, ValidationRule::class)) {
40-
throw new InvalidArgumentException(
40+
Config::throwInvalidArgumentException(
4141
sprintf(
4242
'Validation rule must implement %s',
4343
ValidationRule::class
4444
)
4545
);
4646
}
4747

48-
if (isset($this->rules[$class::id()])) {
49-
throw new InvalidArgumentException(
50-
"A validation rule with the id {$class::id()} has already been registered."
48+
$classId = $class::id();
49+
50+
if (isset($this->rules[$classId])) {
51+
Config::throwInvalidArgumentException(
52+
"A validation rule with the id $classId has already been registered."
5153
);
5254
}
5355

54-
$this->rules[$class::id()] = $class;
56+
$this->rules[$classId] = $class;
5557

5658
return $this;
5759
}

0 commit comments

Comments
 (0)