Completed
Push — master ( a551e2...7bb49b )
by Derek Stephen
04:03
created

OAuthPackage   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 65.96%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 0
cbo 3
dl 0
loc 80
ccs 31
cts 47
cp 0.6596
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getEntityPath() 0 4 1
A hasEntityPath() 0 4 1
A addToContainer() 0 63 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
    public function addToContainer(Container $c)
16
    {
17
        // AccessToken
18 1
        $function = function ($c) {
19
            /** @var EntityManager $entityManager */
20 1
            $entityManager = $c['doctrine.entity_manager'];
21 1
            $repository = $entityManager->getRepository('OAuth\AccessToken');
22 1
            return $repository;
23 1
        };
24 1
        $c['repository.AccessToken'] = $c->factory($function);
25
26
        // AuthCode
27 1
        $function = function ($c) {
28
            /** @var EntityManager $entityManager */
29 1
            $entityManager = $c['doctrine.entity_manager'];
30 1
            $repository = $entityManager->getRepository('OAuth\AuthCode');
31
            return $repository;
32 1
        };
33 1
        $c['repository.AuthCode'] = $c->factory($function);
34
35
        // Client
36 1
        $function = function ($c) {
37
            /** @var EntityManager $entityManager */
38
            $entityManager = $c['doctrine.entity_manager'];
39
            $repository = $entityManager->getRepository('OAuth\Client');
40
            return $repository;
41 1
        };
42 1
        $c['repository.Client'] = $c->factory($function);
43
44 1
        $function = function ($c) {
45
            $repository = $c['repository.Client'];
46
            $svc = new ClientService($repository);
47
            return $svc;
48 1
        };
49 1
        $c['oauth.service.client'] = $c->factory($function);
50
51
        // RefreshToken
52 1
        $function = function ($c) {
53
            /** @var EntityManager $entityManager */
54
            $entityManager = $c['doctrine.entity_manager'];
55
            $repository = $entityManager->getRepository('OAuth\RefreshToken');
56
            return $repository;
57 1
        };
58 1
        $c['repository.RefreshToken'] = $c->factory($function);
59
60
        // Scope
61 1
        $function = function ($c) {
62
            /** @var EntityManager $entityManager */
63
            $entityManager = $c['doctrine.entity_manager'];
64
            $repository = $entityManager->getRepository('OAuth\Scope');
65
            return $repository;
66 1
        };
67 1
        $c['repository.Scope'] = $c->factory($function);
68
69
        // User
70 1
        $function = function ($c) {
71
            /** @var EntityManager $entityManager */
72
            $entityManager = $c['doctrine.entity_manager'];
73
            $repository = $entityManager->getRepository('OAuth\User');
74
            return $repository;
75 1
        };
76 1
        $c['repository.User'] = $c->factory($function);
77 1
    }
78
79 1
    public function getEntityPath()
80
    {
81 1
        return 'src/Entity/OAuth';
82
    }
83
84 1
    public function hasEntityPath()
85
    {
86 1
        return true;
87
    }
88
89
}