OAuthPackage   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Test Coverage

Coverage 92.68%

Importance

Changes 0
Metric Value
wmc 3
eloc 38
dl 0
loc 77
ccs 38
cts 41
cp 0.9268
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A hasEntityPath() 0 3 1
A getEntityPath() 0 3 1
A addToContainer() 0 62 1
1
<?php
2
namespace OAuth;
3
4
use Del\Common\Container\RegistrationInterface;
5
use Doctrine\ORM\EntityManager;
6
use OAuth\Service\ClientService;
7
use Pimple\Container;
8
9
class OAuthPackage implements RegistrationInterface
10
{
11
    /**
12
     * @param Container $c
13
     */
14 26
    public function addToContainer(Container $c)
15
    {
16
        // AccessToken
17
        $function = function ($c) {
18
            /** @var EntityManager $entityManager */
19 9
            $entityManager = $c['doctrine.entity_manager'];
20 9
            $repository = $entityManager->getRepository(AccessToken::class);
21 9
            return $repository;
22 1
        };
23 26
        $c['repository.AccessToken'] = $c->factory($function);
24
25
        // AuthCode
26
        $function = function ($c) {
27
            /** @var EntityManager $entityManager */
28 8
            $entityManager = $c['doctrine.entity_manager'];
29 8
            $repository = $entityManager->getRepository(AuthCode::class);
30 8
            return $repository;
31 26
        };
32 26
        $c['repository.AuthCode'] = $c->factory($function);
33
34
        // Client
35
        $function = function ($c) {
36
            /** @var EntityManager $entityManager */
37 9
            $entityManager = $c['doctrine.entity_manager'];
38 9
            $repository = $entityManager->getRepository(Client::class);
39 9
            return $repository;
40 26
        };
41 26
        $c['repository.Client'] = $c->factory($function);
42
43
        $function = function ($c) {
44
            $repository = $c['repository.Client'];
45
            $svc = new ClientService($repository);
46
            return $svc;
47 26
        };
48 26
        $c['oauth.service.client'] = $c->factory($function);
49
50
        // RefreshToken
51
        $function = function ($c) {
52
            /** @var EntityManager $entityManager */
53 8
            $entityManager = $c['doctrine.entity_manager'];
54 8
            $repository = $entityManager->getRepository(RefreshToken::class);
55 8
            return $repository;
56 26
        };
57 26
        $c['repository.RefreshToken'] = $c->factory($function);
58
59
        // Scope
60
        $function = function ($c) {
61
            /** @var EntityManager $entityManager */
62 8
            $entityManager = $c['doctrine.entity_manager'];
63 8
            $repository = $entityManager->getRepository(Scope::class);
64 8
            return $repository;
65 26
        };
66 26
        $c['repository.Scope'] = $c->factory($function);
67
68
        // User
69
        $function = function ($c) {
70
            /** @var EntityManager $entityManager */
71 1
            $entityManager = $c['doctrine.entity_manager'];
72 1
            $repository = $entityManager->getRepository(OAuthUser::class);
73 1
            return $repository;
74 26
        };
75 26
        $c['repository.User'] = $c->factory($function);
76 26
    }
77
78 26
    public function getEntityPath()
79
    {
80 26
        return 'src/Entity/OAuth';
81
    }
82
83 26
    public function hasEntityPath()
84
    {
85 26
        return true;
86
    }
87
88
}