Completed
Push — develop ( b8f7b1...cea6ad )
by
unknown
07:05
created

__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 6

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
dl 14
loc 14
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 3
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @license MIT
7
 * @copyright  2013 - 2016 Cross Solution <http://cross-solution.de>
8
 */
9
10
namespace Jobs\Factory\Controller;
11
12
use Interop\Container\ContainerInterface;
13
use Jobs\Controller\ApiJobListByOrganizationController;
14
use Zend\ServiceManager\FactoryInterface;
15
use Zend\ServiceManager\ServiceLocatorInterface;
16
17 View Code Duplication
class ApiJobListByOrganizationControllerFactory 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...
18
{
19
    /**
20
     * Create an object
21
     *
22
     * @param  ContainerInterface $container
23
     * @param  string             $requestedName
24
     * @param  null|array         $options
25
     *
26
     * @return object
27
     * @throws ServiceNotFoundException if unable to resolve the service.
28
     * @throws ServiceNotCreatedException if an exception is raised when
29
     *     creating a service.
30
     * @throws ContainerException if any other error occurs
31
     */
32
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
33
    {
34
        $repositories = $container->get('repositories');
35
36
        /** @var \Jobs\Repository\Job $jobRepository */
37
        $jobRepository = $repositories->get('Jobs');
38
39
        /** @var \Jobs\Model\ApiJobDehydrator $apiJobDehydrator */
40
        $apiJobDehydrator = $container->get('Jobs\Model\ApiJobDehydrator');
41
42
        $controller = new ApiJobListByOrganizationController($jobRepository, $apiJobDehydrator);
43
44
        return $controller;
45
    }
46
47
    /**
48
     * Create service
49
     *
50
     * @param ServiceLocatorInterface $serviceLocator
51
     *
52
     * @return ApiJobListByOrganizationController
53
     */
54
    public function createService(ServiceLocatorInterface $serviceLocator)
55
    {
56
        /* @var $serviceLocator \Zend\Mvc\Controller\PluginManager */
57
        return $this($serviceLocator->getServiceLocator(), ApiJobListByOrganizationController::class);
58
    }
59
}
60