Skip to content

Commit d548355

Browse files
committed
fix: use config for throwing exception
1 parent 01f5662 commit d548355

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/Models/ValueObjects/Relationship.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace StellarWP\Models\ValueObjects;
44

5-
use InvalidArgumentException;
5+
use StellarWP\Models\Config;
66

77
/**
88
* Model Relationship Value Object
@@ -56,12 +56,10 @@ private function __construct( string $value ) {
5656
* @param string $value The relationship type value.
5757
*
5858
* @return self
59-
*
60-
* @throws InvalidArgumentException When the value is invalid.
6159
*/
6260
private static function getInstance( string $value ): self {
6361
if ( ! self::isValid( $value ) ) {
64-
throw new InvalidArgumentException( "Invalid relationship type: {$value}" );
62+
Config::throwInvalidArgumentException( "Invalid relationship type: {$value}" );
6563
}
6664

6765
if ( ! isset( self::$instances[ $value ] ) ) {
@@ -77,8 +75,6 @@ private static function getInstance( string $value ): self {
7775
* @param string $value The relationship type value.
7876
*
7977
* @return self
80-
*
81-
* @throws InvalidArgumentException When the value is invalid.
8278
*/
8379
public static function from( string $value ): self {
8480
return self::getInstance( $value );
@@ -91,8 +87,6 @@ public static function from( string $value ): self {
9187
* @param array<mixed> $arguments The method arguments (none expected).
9288
*
9389
* @return self
94-
*
95-
* @throws InvalidArgumentException When the method name doesn't match a valid relationship type.
9690
*/
9791
public static function __callStatic( string $name, array $arguments ): self {
9892
$value = strtolower( str_replace( '_', '-', $name ) );
@@ -115,8 +109,6 @@ public function getValue(): string {
115109
* @param array<mixed> $arguments The method arguments (none expected).
116110
*
117111
* @return bool
118-
*
119-
* @throws InvalidArgumentException When the method name doesn't match a valid relationship type.
120112
*/
121113
public function __call( string $name, array $arguments ): bool {
122114
if ( strpos( $name, 'is' ) === 0 ) {
@@ -130,7 +122,7 @@ public function __call( string $name, array $arguments ): bool {
130122
}
131123
}
132124

133-
throw new InvalidArgumentException( "Method {$name} does not exist on Relationship." );
125+
Config::throwInvalidArgumentException( "Method {$name} does not exist on Relationship." );
134126
}
135127

136128
/**

0 commit comments

Comments
 (0)