Passed
Push — master ( dfb12b...5aafb2 )
by Janko
26:27
created

ColonyClassRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 25
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A save() 0 6 1
A getWithoutDatabaseEntry() 0 15 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\Component\Database\DatabaseCategoryTypeEnum;
0 ignored issues
show
Bug introduced by
The type Stu\Component\Database\DatabaseCategoryTypeEnum 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...
10
use Stu\Orm\Entity\ColonyClass;
11
use Stu\Orm\Entity\ColonyClassInterface;
12
use Stu\Orm\Entity\DatabaseEntry;
13
14
/**
15
 * @extends EntityRepository<ColonyClass>
16
 */
17
final class ColonyClassRepository extends EntityRepository implements ColonyClassRepositoryInterface
18
{
19
    #[Override]
20
    public function save(ColonyClassInterface $obj): void
21
    {
22
        $em = $this->getEntityManager();
23
24
        $em->persist($obj);
25
    }
26
27
    #[Override]
28
    public function getWithoutDatabaseEntry(): array
29
    {
30
        return $this->getEntityManager()
31
            ->createQuery(
32
                sprintf(
33
                    'SELECT p FROM %s p WHERE p.database_id NOT IN (SELECT d.id FROM %s d WHERE d.category_id = :categoryId)',
34
                    ColonyClass::class,
35
                    DatabaseEntry::class
36
                )
37
            )
38
            ->setParameters([
39
                'categoryId' => DatabaseCategoryTypeEnum::DATABASE_CATEGORY_COLONY_CLASS
40
            ])
41
            ->getResult();
42
    }
43
}
44