2121
2222namespace WikibaseSolutions \CypherDSL \Clauses ;
2323
24- use InvalidArgumentException ;
24+ use WikibaseSolutions \ CypherDSL \ Traits \ ErrorTrait ;
2525use WikibaseSolutions \CypherDSL \Types \AnyType ;
2626use WikibaseSolutions \CypherDSL \Variable ;
2727
3232 */
3333class CallProcedureClause extends Clause
3434{
35+ use ErrorTrait;
36+
3537 /**
3638 * @var string|null The procedure to call
3739 */
@@ -74,9 +76,7 @@ public function setProcedure(string $procedure): self
7476 public function withArguments (array $ arguments ): self
7577 {
7678 foreach ($ arguments as $ argument ) {
77- if (!($ argument instanceof AnyType)) {
78- throw new InvalidArgumentException ("\$arguments should only consist of AnyType objects " );
79- }
79+ $ this ->assertClass ('argument ' , AnyType::class, $ argument );
8080 }
8181
8282 $ this ->arguments = $ arguments ;
@@ -107,9 +107,7 @@ public function addArgument(AnyType $argument): self
107107 public function yields (array $ variables ): self
108108 {
109109 foreach ($ variables as $ variable ) {
110- if (!($ variable instanceof Variable)) {
111- throw new InvalidArgumentException ("\$variables should only consist of Variable objects " );
112- }
110+ $ this ->assertClass ('variable ' , Variable::class, $ variable );
113111 }
114112
115113 $ this ->yieldVariables = $ variables ;
@@ -150,4 +148,4 @@ protected function getSubject(): string
150148 return sprintf ("%s(%s) " , $ this ->procedure , $ arguments );
151149 }
152150 }
153- }
151+ }
0 commit comments