Conditions | 7 |
Paths | 3 |
Total Lines | 19 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
38 | function isValidError(string $name, $node = null): ?ValidationException |
||
39 | { |
||
40 | invariant(\is_string($name), 'Expected string'); |
||
41 | |||
42 | if (\strlen($name) > 1 && $name{0} === '_' && $name{1} === '_') { |
||
43 | return new ValidationException( |
||
44 | sprintf('Name "%s" must not begin with "__", which is reserved by GraphQL introspection.', $name), |
||
45 | $node instanceof NodeInterface ? [$node] : null |
||
46 | ); |
||
47 | } |
||
48 | |||
49 | if (preg_match("/^[_a-zA-Z][_a-zA-Z0-9]*$/", $name) === 0) { |
||
50 | return new ValidationException( |
||
51 | sprintf('Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but "%s" does not.', $name), |
||
52 | $node instanceof NodeInterface ? [$node] : null |
||
53 | ); |
||
54 | } |
||
55 | |||
56 | return null; |
||
57 | } |
||
59 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.