Completed
Push — master ( a3cce1...d6fbcc )
by Marcel
09:39
created

ApplicationRepository   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 35%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 14
c 1
b 0
f 1
dl 0
loc 33
ccs 7
cts 20
cp 0.35
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A persist() 0 3 1
A remove() 0 3 1
A findOneByApiKey() 0 4 1
A findAll() 0 5 1
A __construct() 0 2 1
1
<?php
2
3
namespace App\Repository;
4
5
use App\Entity\Application;
6
use Doctrine\ORM\EntityManagerInterface;
7
8
class ApplicationRepository implements ApplicationRepositoryInterface {
9
10
    private $em;
11
12 12
    public function __construct(EntityManagerInterface $entityManager) {
13 12
        $this->em = $entityManager;
14 12
    }
15
16
    /**
17
     * @inheritDoc
18
     */
19
    public function findAll() {
20
        return $this->em
21
            ->getRepository(Application::class)
22
            ->findBy([], [
23
                'name' => 'asc'
24
            ]);
25
    }
26
27
    public function persist(Application $application) {
28
        $this->em->persist($application);
29
        $this->em->flush();
30
    }
31
32
    public function remove(Application $application) {
33
        $this->em->remove($application);
34
        $this->em->flush();
35
    }
36
37 2
    public function findOneByApiKey($key): ?Application {
38 2
        return $this->em
39 2
            ->getRepository(Application::class)
40 2
            ->findOneBy(['apiKey' => $key]);
41
    }
42
}