GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

EmployeeRepository::add()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
declare(strict_types=1);
3
4
/*
5
 * This file is part of the AL labs package
6
 *
7
 * (c) Arnaud Langlade
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace Al\ResourceManagement\Infrastructure\Persistence\Doctrine;
14
15
use Al\ResourceManagement\Domain\Employee;
16
use Al\ResourceManagement\Domain\EmployeeInterface;
17
use Al\ResourceManagement\Domain\EmployeeRepositoryInterface;
18
use Al\ResourceManagement\Domain\Exception\NotExistingEmployee;
19
use Doctrine\ORM\EntityManagerInterface;
20
use Ramsey\Uuid\UuidInterface;
21
22
final class EmployeeRepository implements EmployeeRepositoryInterface
23
{
24
    /** @var EntityManagerInterface */
25
    private $entityManager;
26
27
    /**
28
     * @param EntityManagerInterface $entityManager
29
     */
30
    public function __construct(EntityManagerInterface $entityManager)
31
    {
32
        $this->entityManager = $entityManager;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function get(UuidInterface $identifier): EmployeeInterface
39
    {
40
        if (null === $employee = $this->entityManager->find(Employee::class, (string) $identifier->toString())) {
41
            throw new NotExistingEmployee((string) $identifier->toString());
42
        }
43
44
        return $employee;
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function add(EmployeeInterface $employee)
51
    {
52
        $this->entityManager->persist($employee);
53
        $this->entityManager->flush($employee);
0 ignored issues
show
Unused Code introduced by
The call to EntityManagerInterface::flush() has too many arguments starting with $employee.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function remove(EmployeeInterface $employee)
60
    {
61
        $this->entityManager->remove($employee);
62
        $this->entityManager->flush($employee);
0 ignored issues
show
Unused Code introduced by
The call to EntityManagerInterface::flush() has too many arguments starting with $employee.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
63
    }
64
}
65