Passed
Push — master ( ad7b81...1c3353 )
by Janko
35:52
created

AstroEntryRepository::getByShipLocation()   A

Complexity

Conditions 6
Paths 4

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 42

Importance

Changes 0
Metric Value
cc 6
eloc 9
nc 4
nop 2
dl 0
loc 14
ccs 0
cts 10
cp 0
crap 42
rs 9.2222
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A AstroEntryRepository::delete() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Orm\Repository;
6
7
use Doctrine\ORM\EntityRepository;
8
use Override;
0 ignored issues
show
Bug introduced by
The type Override was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Stu\Orm\Entity\AstronomicalEntry;
10
use Stu\Orm\Entity\AstronomicalEntryInterface;
11
use Stu\Orm\Entity\UserInterface;
12
13
/**
14
 * @extends EntityRepository<AstronomicalEntry>
15
 */
16
final class AstroEntryRepository extends EntityRepository implements AstroEntryRepositoryInterface
17
{
18
    #[Override]
19
    public function prototype(): AstronomicalEntryInterface
20
    {
21
        return new AstronomicalEntry();
22
    }
23
24
    #[Override]
25
    public function save(AstronomicalEntryInterface $entry): void
26
    {
27
        $em = $this->getEntityManager();
28
29
        $em->persist($entry);
30
    }
31
32
    #[Override]
33
    public function delete(AstronomicalEntryInterface $entry): void
34
    {
35
        $em = $this->getEntityManager();
36
37
        $em->remove($entry);
38
        $em->flush(); //TODO really neccessary?
39
    }
40
41
42
    #[Override]
43
    public function truncateAllAstroEntries(): void
44
    {
45
        $this->getEntityManager()->createQuery(
46
            sprintf(
47
                'DELETE FROM %s ae',
48
                AstronomicalEntry::class
49
            )
50
        )->execute();
51
    }
52
53
    /** @return array<AstronomicalEntryInterface> */
54
    #[Override]
55
    public function getByUser(UserInterface $user): array
56
    {
57
        return $this->findBy(
58
            ['user_id' => $user->getId()]
59
        );
60
    }
61
}
62