Completed
Push — master ( 36f73c...56dc59 )
by Derek Stephen
04:32
created

OAuthPackage   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 91.49%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 82
ccs 43
cts 47
cp 0.9149
rs 10
c 1
b 0
f 1

3 Methods

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