PageServiceFactory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 5
dl 0
loc 21
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 18 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Page\Service;
6
7
use Interop\Container\ContainerInterface;
8
use Page\Filter\PageFilter;
9
use Page\Mapper\PageMapper;
10
use UploadHelper\Upload;
11
use Zend\Paginator\Adapter\DbSelect;
12
use Zend\Paginator\Paginator;
13
14
class PageServiceFactory
15
{
16
    public function __invoke(ContainerInterface $container)
17
    {
18
        $config = $container->get('config')['upload'];
19
        $upload = new Upload($config['public_path'], $config['non_public_path']);
20
21
        // Create pagination object
22
        $pageMapper = $container->get(PageMapper::class);
23
        $select = $pageMapper->getPaginationSelect();
24
        $paginationAdapter = new DbSelect($select, $pageMapper->getAdapter(), $pageMapper->getResultSetPrototype());
25
        $pagination = new Paginator($paginationAdapter);
26
27
        return new PageService(
28
            $container->get(PageFilter::class),
29
            $pageMapper,
30
            $pagination,
31
            $upload
32
        );
33
    }
34
}
35