ProductAttributesRepository::findByScopable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 12
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 12
loc 12
rs 9.4285
cc 1
eloc 9
nc 1
nop 1
1
<?php
2
3
namespace DefaultValue\Bundle\AkeneoInlineEditBundle\Product;
4
5
use Pim\Bundle\CatalogBundle\Doctrine\ORM\Repository\AttributeRepository;
6
7
/**
8
 * Query from database product attributes
9
 */
10
class ProductAttributesRepository extends AttributeRepository
11
{
12
    /**
13
     * Find attributes by `scopable` attribute. By default fetches scopable attributes
14
     *
15
     * @param int $scopable
16
     * @return \Doctrine\ORM\QueryBuilder
17
     */
18 View Code Duplication
    public function findByScopable($scopable = 1)
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...
19
    {
20
        $result = $this->getEntityManager()
21
            ->createQueryBuilder()
22
            ->select('attr')
23
            ->from('PimCatalogBundle:Attribute', 'attr')
24
            ->where('attr.scopable = :scopable')
25
            ->setParameter(':scopable', $scopable)
26
            ->orderBy('attr.id', 'desc');
27
28
        return $result;
29
    }
30
31
    /**
32
     * Find attributes by `localizable` attribute. By default fetches localizable attributes
33
     *
34
     * @param int $localizable
35
     * @return \Doctrine\ORM\QueryBuilder
36
     */
37 View Code Duplication
    public function findByLocalizable($localizable = 1)
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...
38
    {
39
        $result = $this->getEntityManager()
40
            ->createQueryBuilder()
41
            ->select('attr')
42
            ->from('PimCatalogBundle:Attribute', 'attr')
43
            ->where('attr.localizable = :localizable')
44
            ->setParameter(':localizable', $localizable)
45
            ->orderBy('attr.id', 'desc');
46
47
        return $result;
48
    }
49
50
    /**
51
     * Find attributes by attributeType.
52
     *
53
     * @param string $attributeType
54
     * @return \Doctrine\ORM\QueryBuilder
55
     */
56
    public function findByAttributeType($attributeType)
57
    {
58
        $result = $this->getEntityManager()
59
            ->createQueryBuilder()
60
            ->select()
61
            ->from('PimCatalogBundle:Attribute', 'attr')
62
            ->where('attr.attributeType = :attributeType')
63
            ->setParameter(':attributeType', $attributeType);
64
65
        return $result;
66
    }
67
}
68