Completed
Push — develop ( 975a05...8c983c )
by
unknown
07:04
created

AcceptInvitationHandlerFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 40
loc 40
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 14 14 1
A createService() 5 5 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @license    MIT
7
 * @copyright  2013 - 2016 Cross Solution <http://cross-solution.de>
8
 */
9
10
/** */
11
namespace Organizations\Factory\Controller\Plugin;
12
13
use Interop\Container\ContainerInterface;
14
use Organizations\Controller\Plugin\AcceptInvitationHandler;
15
use Zend\ServiceManager\FactoryInterface;
16
use Zend\ServiceManager\ServiceLocatorInterface;
17
18
/**
19
 * Factory for an InvitationHandler.
20
 *
21
 * @author Mathias Gelhausen <[email protected]>
22
 * @since  0.19
23
 */
24 View Code Duplication
class AcceptInvitationHandlerFactory implements FactoryInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
25
{
26
27
    /**
28
     * Create a AcceptInvitationHandler controller plugin
29
     *
30
     * @param  ContainerInterface $container
31
     * @param  string             $requestedName
32
     * @param  null|array         $options
33
     *
34
     * @return AcceptInvitationHandler
35
     */
36
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
37
    {
38
        $repositories           = $container->get('repositories');
39
        $userRepository         = $repositories->get('Auth/User');
40
        $organizationRepository = $repositories->get('Organizations');
41
        $authenticationService  = $container->get('AuthenticationService');
42
43
        $plugin = new AcceptInvitationHandler();
44
        $plugin->setUserRepository($userRepository)
45
               ->setOrganizationRepository($organizationRepository)
46
               ->setAuthenticationService($authenticationService);
47
48
        return $plugin;
49
    }
50
51
    /**
52
     * Creates an AcceptInvitationHandler
53
     *
54
     * @param ServiceLocatorInterface $serviceLocator
55
     *
56
     * @return AcceptInvitationHandler
57
     */
58
    public function createService(ServiceLocatorInterface $serviceLocator)
59
    {
60
        /* @var $serviceLocator \Zend\Mvc\Controller\PluginManager */
61
        return $this($serviceLocator->getServiceLocator(), AcceptInvitationHandler::class);
62
    }
63
}
64