Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — master (#750)
by Timur
22:37
created

EntityConverter::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 6
c 2
b 0
f 0
dl 0
loc 11
rs 10
cc 2
nc 2
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Overblog\GraphQLBundle\Hydrator\Converters;
6
7
use Doctrine\ORM\EntityManager;
8
use Doctrine\ORM\EntityManagerInterface;
9
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
10
11
class EntityConverter extends Converter
12
{
13
    private EntityManagerInterface $em;
14
15
    public function __construct(?EntityManager $entityManager)
16
    {
17
        if (null === $entityManager) {
18
            throw new ServiceNotFoundException(
19
                "Couldn't convert value, because no EntityManager service is found. 
20
                To use the 'EntityConverter' you need to install Doctrine ORM first. 
21
                See: 'https://symfony.com/doc/current/doctrine.html'"
22
            );
23
        }
24
25
        $this->em = $entityManager;
26
    }
27
28
    /**
29
     * @param $value
30
     * @param Entity $entityAnnotation
31
     *
32
     * @return object|null
33
     */
34
    function convert($value, $entityAnnotation)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
35
    {
36
        return $this->em->getRepository($entityAnnotation->value)->find($value);
37
    }
38
}