Code Duplication    Length = 51-53 lines in 2 locations

module/Core/src/Core/Paginator/PaginatorFactoryAbstract.php 1 location

@@ 23-73 (lines=51) @@
20
 * Class PaginatorFactoryAbstract
21
 * @package Core\Paginator
22
 */
23
abstract class PaginatorFactoryAbstract implements FactoryInterface, MutableCreationOptionsInterface
24
{
25
26
    protected $options = [];
27
28
    /**
29
     * Set creation options
30
     *
31
     * @param  array $options
32
     *
33
     * @return void
34
     */
35
    public function setCreationOptions(array $options)
36
    {
37
        $this->options = $options;
38
    }
39
40
41
    /**
42
     * @param ServiceLocatorInterface $serviceLocator
43
     * @return mixed|Paginator
44
     */
45
    public function createService(ServiceLocatorInterface $serviceLocator)
46
    {
47
        /* @var PaginatorService $serviceLocator */
48
        /* @var RepositoryService $repositories */
49
        $repositories   = $serviceLocator->getServiceLocator()->get('repositories');
50
        $repository     = $repositories->get($this->getRepository());
51
        $queryBuilder   = $repository->createQueryBuilder();
52
        $filter         = $serviceLocator->getServiceLocator()->get('filterManager')->get($this->getFilter());
53
        $adapter       = new \Core\Paginator\Adapter\DoctrineMongoLateCursor($queryBuilder, $filter, $this->options);
54
        $service        = new Paginator($adapter);
55
56
        $this->setCreationOptions([]);
57
        return $service;
58
    }
59
60
    /**
61
     * pagination service name
62
     *
63
     * @return string
64
     */
65
    abstract protected function getFilter();
66
67
    /**
68
     * repository name
69
     *
70
     * @return string
71
     */
72
    abstract protected function getRepository();
73
}

module/Solr/src/Solr/Paginator/PaginatorFactoryAbstract.php 1 location

@@ 26-78 (lines=53) @@
23
 * @since   0.27
24
 * @package Solr\Paginator
25
 */
26
abstract class PaginatorFactoryAbstract implements FactoryInterface,MutableCreationOptionsInterface
27
{
28
    /**
29
     * @var array
30
     */
31
    protected $options = [];
32
33
    /**
34
     * Set creation options
35
     *
36
     * @param  array $options
37
     *
38
     * @return void
39
     */
40
    public function setCreationOptions(array $options)
41
    {
42
        $this->options = $options;
43
    }
44
45
    /**
46
     * @return array
47
     */
48
    public function getCreationOptions()
49
    {
50
        return $this->options;
51
    }
52
53
    /**
54
     * @param ServiceLocatorInterface $serviceLocator
55
     * @return mixed|Paginator
56
     */
57
    public function createService(ServiceLocatorInterface $serviceLocator)
58
    {
59
        /* @var PaginatorService $serviceLocator */
60
        $filter             = $serviceLocator->getServiceLocator()->get('filterManager')->get($this->getFilter());
61
        $connectPath        = $this->getConnectPath();
62
        $solrClient         = $serviceLocator->getServiceLocator()->get('Solr/Manager')->getClient($connectPath);
63
        $resultConverter    = $serviceLocator->getServiceLocator()->get('Solr/ResultConverter');
64
        $adapter            = new SolrAdapter($solrClient,$filter,$resultConverter,$this->options);
65
        $service            = new Paginator($adapter);
66
67
        $this->setCreationOptions([]);
68
        return $service;
69
    }
70
71
    /**
72
     * pagination service name
73
     *
74
     * @return string
75
     */
76
    abstract protected function getFilter();
77
78
    /**
79
     * Get Solr Connect Path for this paginator
80
     *
81
     * @return string