1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace GraphQL\Doctrine\Definition; |
||
6 | |||
7 | use Doctrine\ORM\EntityManager; |
||
8 | use GraphQL\Error\Error; |
||
9 | |||
10 | /** |
||
11 | * A object used to fetch the entity from DB on demand. |
||
12 | * |
||
13 | * @template T |
||
14 | */ |
||
15 | class EntityID |
||
16 | { |
||
17 | /** |
||
18 | * @var EntityManager |
||
19 | */ |
||
20 | private $entityManager; |
||
21 | |||
22 | /** |
||
23 | * The entity class name. |
||
24 | * |
||
25 | * @var class-string<T> |
||
26 | */ |
||
27 | private $className; |
||
28 | |||
29 | /** |
||
30 | * The entity id. |
||
31 | * |
||
32 | * @var null|string |
||
33 | */ |
||
34 | private $id; |
||
35 | |||
36 | /** |
||
37 | * @param class-string<T> $className |
||
38 | */ |
||
39 | 6 | public function __construct(EntityManager $entityManager, string $className, ?string $id) |
|
40 | { |
||
41 | 6 | $this->entityManager = $entityManager; |
|
42 | 6 | $this->className = $className; |
|
43 | 6 | $this->id = $id; |
|
44 | 6 | } |
|
45 | |||
46 | /** |
||
47 | * Get the ID. |
||
48 | */ |
||
49 | 2 | public function getId(): ?string |
|
50 | { |
||
51 | 2 | return $this->id; |
|
52 | } |
||
53 | |||
54 | /** |
||
55 | * Get the entity from DB. |
||
56 | * |
||
57 | * @return T entity |
||
1 ignored issue
–
show
|
|||
58 | */ |
||
59 | 4 | public function getEntity() |
|
60 | { |
||
61 | /** @var null|T $entity */ |
||
62 | 4 | $entity = $this->entityManager->getRepository($this->className)->find($this->id); |
|
63 | 4 | if (!$entity) { |
|
64 | 2 | throw new Error('Entity not found for class `' . $this->className . '` and ID `' . $this->id . '`.'); |
|
65 | } |
||
66 | |||
67 | 2 | return $entity; |
|
68 | } |
||
69 | } |
||
70 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths