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

OAuthPackage::addToContainer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 65
Code Lines 36

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 39
CRAP Score 1.0008

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 65
ccs 39
cts 43
cp 0.907
rs 9.3571
c 1
b 0
f 1
cc 1
eloc 36
nc 1
nop 1
crap 1.0008

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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
}