File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change 4
4
5
5
namespace StellarWP \Validation ;
6
6
7
- use StellarWP \Exceptions \Primitives \InvalidArgumentException ;
8
7
use StellarWP \Validation \Contracts \ValidationRule ;
9
8
10
9
/**
@@ -32,26 +31,29 @@ public function register(string ...$rules): self
32
31
/**
33
32
* Register a validation rule.
34
33
*
34
+ * @unreleased switch to throwing InvalidArgumentException from Config
35
35
* @since 1.0.0
36
36
*/
37
37
private function registerClass (string $ class ): self
38
38
{
39
39
if (!is_subclass_of ($ class , ValidationRule::class)) {
40
- throw new InvalidArgumentException (
40
+ Config:: throwInvalidArgumentException (
41
41
sprintf (
42
42
'Validation rule must implement %s ' ,
43
43
ValidationRule::class
44
44
)
45
45
);
46
46
}
47
47
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. "
51
53
);
52
54
}
53
55
54
- $ this ->rules [$ class :: id () ] = $ class ;
56
+ $ this ->rules [$ classId ] = $ class ;
55
57
56
58
return $ this ;
57
59
}
You can’t perform that action at this time.
0 commit comments