MissingTypeHintException::missingTypeHint()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
1
<?php
2
namespace TheCodingMachine\GraphQL\Controllers;
3
4
use ReflectionMethod;
5
use \ReflectionParameter;
6
7
class MissingTypeHintException extends GraphQLException
8
{
9
    public static function missingTypeHint(ReflectionParameter $parameter): self
10
    {
11
        return new self(sprintf('Parameter "%s" of method "%s::%s" is missing a type-hint', $parameter->getName(), $parameter->getDeclaringClass()->getName(), $parameter->getDeclaringFunction()->getName()));
12
    }
13
14
    public static function missingReturnType(ReflectionMethod $method): self
15
    {
16
        return new self(sprintf('Factory "%s::%s" must have a return type.', $method->getDeclaringClass()->getName(), $method->getName()));
17
    }
18
19
    public static function invalidReturnType(ReflectionMethod $method): self
20
    {
21
        return new self(sprintf('The return type of factory "%s::%s" must be an object, "%s" passed instead.', $method->getDeclaringClass()->getName(), $method->getName(), $method->getReturnType()));
22
    }
23
24
    public static function nullableReturnType(ReflectionMethod $method): self
25
    {
26
        return new self(sprintf('Factory "%s::%s" must have a non nullable return type.', $method->getDeclaringClass()->getName(), $method->getName()));
27
    }
28
}
29