Skip to content

Commit 91dfa12

Browse files
author
Wout Gevaert
committed
Actually include the ErrorTextHelper code
1 parent e4cc5a4 commit 91dfa12

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/ErrorHandling/ErrorTextHelper.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace WikibaseSolutions\CypherDSL\ErrorHandling;
4+
5+
class ErrorTextHelper {
6+
public static function getTypeErrorObjectArrayText(
7+
string $varName,
8+
$typeNames,
9+
$userInput
10+
) {
11+
$userInputInfo = self::getUserInputInfo($userInput);
12+
13+
if (is_array($typeNames)) {
14+
$typeNames = implode( ' or ', $typeNames );
15+
}
16+
17+
return "\$$varName should consist of only $typeNames objects, $userInputInfo given.";
18+
}
19+
20+
public static function getUserInputInfo($userInput) : string {
21+
$info = gettype( $userInput );
22+
if ( $info === 'object' ) {
23+
$info = get_class( $userInput );
24+
} else {
25+
$givenType .= ' "' . (string) $userInput . '"';
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)