Completed
Push — master ( d14457...da0e1e )
by Derek Stephen
25:25 queued 19:55
created

OAuthPackage   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Test Coverage

Coverage 47.5%

Importance

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