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

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