Test Failed
Push — master ( 3df79e...07268c )
by Szymon
02:05
created

MysqlCategoryRepository   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A oneByUuid() 0 8 1
A __construct() 0 4 1
A delete() 0 6 1
A add() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Infrastructure\Category\Query\Repository;
6
7
use App\Domain\Common\ValueObject\AggregateRootId;
8
use App\Infrastructure\Category\Query\Projections\CategoryView;
9
use App\Infrastructure\Common\Query\MysqlRepository;
10
use Doctrine\ORM\EntityManagerInterface;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\EntityManagerInterface 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...
11
12
/**
13
 * @method stack(string $string, array $array)
14
 */
15
class MysqlCategoryRepository extends MysqlRepository
16
{
17
    public function add(CategoryView $postView): void
18
    {
19
        $this->register($postView);
20
    }
21
22
    /**
23
     * @throws \Doctrine\ORM\NonUniqueResultException
24
     */
25
    public function oneByUuid(AggregateRootId $id)
26
    {
27
        $qb = $this->repository
28
            ->createQueryBuilder('book')
29
            ->where('book.id = :id')
30
            ->setParameter('id', $id->toString());
31
32
        return $this->oneOrException($qb);
33
    }
34
35
    public function delete(string $id)
36
    {
37
        /** @var object $post */
38
        $post = $this->repository->find($id);
39
        $this->entityManager->remove($post);
40
        $this->entityManager->flush();
41
    }
42
43
    /**
44
     * MysqlUserReadModelRepository constructor.
45
     */
46
    public function __construct(EntityManagerInterface $entityManager)
47
    {
48
        $this->class = CategoryView::class;
49
        parent::__construct($entityManager);
50
    }
51
}
52