Code Duplication    Length = 28-45 lines in 3 locations

module/Auth/src/Auth/Factory/Service/ForgotPasswordFactory.php 1 location

@@ 21-65 (lines=45) @@
18
use Zend\ServiceManager\FactoryInterface;
19
use Zend\ServiceManager\ServiceLocatorInterface;
20
21
class ForgotPasswordFactory implements FactoryInterface
22
{
23
    /**
24
     * Create an object
25
     *
26
     * @param  ContainerInterface $container
27
     * @param  string             $requestedName
28
     * @param  null|array         $options
29
     *
30
     * @return ForgotPassword
31
     * @throws ServiceNotFoundException if unable to resolve the service.
32
     * @throws ServiceNotCreatedException if an exception is raised when
33
     *     creating a service.
34
     * @throws ContainerException if any other error occurs
35
     */
36
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
37
    {
38
        /**
39
         * @var Repository\User          $userRepository
40
         * @var UserUniqueTokenGenerator $tokenGenerator
41
         */
42
        $userRepository = $container->get('repositories')->get('Auth/User');
43
        $tokenGenerator = $container->get('Auth\Service\UserUniqueTokenGenerator');
44
        $loginFilter = $container->get('Auth\LoginFilter');
45
        $config = $container->get('Auth/Options');
46
47
        $service = new ForgotPassword($userRepository, $tokenGenerator, $loginFilter, $config);
48
49
        $events = $container->get('Auth/Events');
50
        $service->setEventManager($events);
51
52
        return $service;
53
    }
54
    /**
55
     * Create service
56
     *
57
     * @param ServiceLocatorInterface $serviceLocator
58
     *
59
     * @return ForgotPassword
60
     */
61
    public function createService(ServiceLocatorInterface $serviceLocator)
62
    {
63
        return $this($serviceLocator, ForgotPassword::class);
64
    }
65
}
66

module/Jobs/src/Jobs/Factory/Paginator/ActiveOrganizationsPaginatorFactory.php 1 location

@@ 26-57 (lines=32) @@
23
 * @author Mathias Gelhausen <[email protected]>
24
 * @since 0.30
25
 */
26
class ActiveOrganizationsPaginatorFactory implements FactoryInterface
27
{
28
29
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
30
    {
31
        /* @var RepositoryService $repositories
32
         * @var \Zend\Http\PhpEnvironment\Request $request */
33
        $repositories   = $container->get('repositories');
34
        $repository     = $repositories->get('Jobs');
35
        $request        = $container->get('Request');
36
        $query          = $request->getQuery();
37
        $term           = $query->get('q');
38
        $cursor         = $repository->findActiveOrganizations($term);
39
40
        $adapter        = new \Core\Paginator\Adapter\DoctrineMongoCursor($cursor);
41
        $service        = new Paginator($adapter);
42
43
        return $service;
44
    }
45
46
    /**
47
     * Create service
48
     *
49
     * @param ServiceLocatorInterface|AbstractPluginManager $serviceLocator
50
     *
51
     * @return mixed
52
     */
53
    public function createService(ServiceLocatorInterface $serviceLocator)
54
    {
55
        return $this($serviceLocator->getServiceLocator(), 'Jobs\Paginator\ActiveOrganizations');
56
    }
57
}

module/Applications/src/Applications/Factory/Form/JobSelectFactory.php 1 location

@@ 24-51 (lines=28) @@
21
 * @author Mathias Gelhausen <[email protected]>
22
 * @since 0.29.2
23
 */
24
class JobSelectFactory implements FactoryInterface
25
{
26
    
27
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
28
    {
29
        /* @var \Zend\Http\PhpEnvironment\Request $request */
30
        $request = $container->get('Request');
31
        $query   = $request->getQuery();
32
        $jobId   = $query->get('job');
33
        $select = new JobSelect();
34
35
        if ($jobId) {
36
            /* @var \Jobs\Repository\Job $repository */
37
            $repositories = $container->get('repositories');
38
            $repository   = $repositories->get('Jobs');
39
            $job          = $repository->find($jobId);
40
            $select->setSelectedJob($job);
41
        }
42
43
        return $select;
44
    }
45
    
46
    public function createService(ServiceLocatorInterface $serviceLocator)
47
    {
48
        /* @var \Zend\ServiceManager\AbstractPluginManager $serviceLocator */
49
        return $this($serviceLocator->getServiceLocator(), JobSelect::class);
50
    }
51
}
52