CharacterRepository::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace App\Repository;
4
5
use App\Entity\Character;
6
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
7
use Doctrine\ORM\QueryBuilder;
8
use Symfony\Bridge\Doctrine\RegistryInterface;
9
10
/**
11
 * Class CharacterRepository
12
 * @package App\Repository
13
 */
14 View Code Duplication
class CharacterRepository extends ServiceEntityRepository
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
15
{
16
    /**
17
     * CharacterRepository constructor.
18
     * @param RegistryInterface $registry
19
     */
20
    public function __construct(RegistryInterface $registry)
21
    {
22
        parent::__construct($registry, Character::class);
23
    }
24
25
    /**
26
     * @param $qb
27
     * @param string $phrase
28
     *
29
     * @return QueryBuilder
30
     */
31
    public function findByPhrase($qb, string $phrase): QueryBuilder
32
    {
33
        return $qb->andWhere('name = :phrase')
34
            ->setParameter('phrase', $phrase)
35
            ;
36
    }
37
38
    public function remove(): void
39
    {
40
        $this->createQueryBuilder('u')
41
            ->delete()
42
            ->getQuery()
43
            ->execute()
44
        ;
45
    }
46
}
47