Passed
Push — master ( be1ae0...39bac6 )
by Craig
08:28
created

ExtensionVarRepository::findAll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the Zikula package.
5
 *
6
 * Copyright Zikula Foundation - http://zikula.org/
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Zikula\ExtensionsModule\Entity\Repository;
13
14
use Doctrine\ORM\EntityRepository;
15
use Zikula\ExtensionsModule\Entity\ExtensionVarEntity;
16
use Zikula\ExtensionsModule\Entity\RepositoryInterface\ExtensionVarRepositoryInterface;
17
18
class ExtensionVarRepository extends EntityRepository implements ExtensionVarRepositoryInterface
19
{
20
    public function remove(ExtensionVarEntity $entity)
21
    {
22
        $this->_em->remove($entity);
23
    }
24
25
    public function persistAndFlush(ExtensionVarEntity $entity)
26
    {
27
        $this->_em->persist($entity);
28
        $this->_em->flush();
29
    }
30
31 View Code Duplication
    public function deleteByExtensionAndName($extensionName, $variableName)
0 ignored issues
show
Duplication introduced by
This method 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...
32
    {
33
        $qb = $this->_em->createQueryBuilder()
34
            ->delete('Zikula\ExtensionsModule\Entity\ExtensionVarEntity', 'v')
35
            ->where('v.modname = :modname')
36
            ->setParameter('modname', $extensionName)
37
            ->andWhere('v.name = :name')
38
            ->setParameter('name', $variableName);
39
        $query = $qb->getQuery();
40
        $result = $query->execute();
41
42
        return (bool)$result;
43
    }
44
45 View Code Duplication
    public function deleteByExtension($extensionName)
0 ignored issues
show
Duplication introduced by
This method 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...
46
    {
47
        $qb = $this->_em->createQueryBuilder()
48
            ->delete('Zikula\ExtensionsModule\Entity\ExtensionVarEntity', 'v')
49
            ->where('v.modname = :modname')
50
            ->setParameter('modname', $extensionName);
51
        $query = $qb->getQuery();
52
        $result = $query->execute();
53
54
        return (bool)$result;
55
    }
56
57 View Code Duplication
    public function updateName($oldName, $newName)
0 ignored issues
show
Duplication introduced by
This method 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...
58
    {
59
        $query = $this->_em->createQueryBuilder()
60
            ->update('Zikula\ExtensionsModule\Entity\ExtensionVarEntity', 'v')
61
            ->set('v.modname', ':newname')
62
            ->setParameter('newname', $newName)
63
            ->where('v.modname = :oldname')
64
            ->setParameter('oldname', $oldName)
65
            ->getQuery();
66
        $query->execute();
67
    }
68
}
69