Completed
Push — master ( eaf36c...f92548 )
by Marcel
03:19
created

ServiceAttributeRepository::findAll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
namespace App\Repository;
4
5
use App\Entity\ServiceAttribute;
6
use Doctrine\ORM\EntityManagerInterface;
7
8
class ServiceAttributeRepository implements ServiceAttributeRepositoryInterface {
9
10
    private $em;
11
12 9
    public function __construct(EntityManagerInterface $objectManager) {
13 9
        $this->em = $objectManager;
14 9
    }
15
16
    /**
17
     * @inheritDoc
18
     */
19
    public function getAttributes() {
20
        return $this->findAll();
21
    }
22
23
    public function getAttributesForServiceProvider($entityId) {
24
        $queryBuilder = $this->em
25
            ->createQueryBuilder()
26
            ->select(['a', 's'])
27
            ->from(ServiceAttribute::class, 'a')
28
            ->leftJoin('a.services', 's')
29
            ->where('s.entityId = :entityId')
30
            ->setParameter('entityId', $entityId);
31
32
        return $queryBuilder->getQuery()->getResult();
33
    }
34
35
    /**
36
     * @inheritDoc
37
     */
38 1
    public function findAll() {
39 1
        return $this->em
40 1
            ->getRepository(ServiceAttribute::class)
41 1
            ->findAll();
42
    }
43
44
    public function persist(ServiceAttribute $attribute) {
45
        $this->em->persist($attribute);
46
        $this->em->flush();
47
    }
48
49
    public function remove(ServiceAttribute $attribute) {
50
        $this->em->remove($attribute);
51
        $this->em->flush();
52
    }
53
}