Completed
Pull Request — master (#24)
by David
01:48
created

FieldNotFoundException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 5
dl 0
loc 12
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A missingField() 0 4 1
A wrapWithCallerInfo() 0 4 1
1
<?php
2
3
4
namespace TheCodingMachine\GraphQL\Controllers;
5
6
7
class FieldNotFoundException extends \RuntimeException
8
{
9
    public static function missingField(string $className, string $fieldName): self
10
    {
11
        throw new self(sprintf('Could not find a getter or a isser for field "%s". Looked for: "%s::get%s()", "%s::is%s()"',
12
            $fieldName, $className, \ucfirst($fieldName), $className, \ucfirst($fieldName)));
13
    }
14
15
    public static function wrapWithCallerInfo(self $e, string $className): self
16
    {
17
        throw new self(sprintf('There is an issue with a @SourceField annotation in class "%s": %s',
18
            $className, $e->getMessage()), 0, $e);
19
    }
20
}
21