| Conditions | 7 |
| Paths | 3 |
| Total Lines | 17 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | public static function isValidError(string $name, $node = null): ?ValidationException |
||
| 19 | { |
||
| 20 | if (\strlen($name) > 1 && $name{0} === '_' && $name{1} === '_') { |
||
| 21 | return new ValidationException( |
||
| 22 | sprintf('Name "%s" must not begin with "__", which is reserved by GraphQL introspection.', $name), |
||
| 23 | $node instanceof NodeInterface ? [$node] : null |
||
| 24 | ); |
||
| 25 | } |
||
| 26 | |||
| 27 | if (preg_match("/^[_a-zA-Z][_a-zA-Z0-9]*$/", $name) === 0) { |
||
| 28 | return new ValidationException( |
||
| 29 | sprintf('Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but "%s" does not.', $name), |
||
| 30 | $node instanceof NodeInterface ? [$node] : null |
||
| 31 | ); |
||
| 32 | } |
||
| 33 | |||
| 34 | return null; |
||
| 35 | } |
||
| 37 |