Completed
Pull Request — master (#143)
by
unknown
02:35
created

ContactUsServiceFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 4
dl 0
loc 27
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 19 1
1
<?php
2
3
namespace ContactUs\Service;
4
5
use ContactUs\Filter\ContactUsFilter;
6
use ContactUs\Mapper\ContactUsMapper;
7
use Interop\Container\ContainerInterface;
8
use Zend\Paginator\Adapter\DbSelect;
9
use Zend\Paginator\Paginator;
10
11
/**
12
 * Class ContactUsServiceFactory
13
 *
14
 * @package ContactUs\Service
15
 * @author  Djordje Stojiljkovic <[email protected]>
16
 */
17
class ContactUsServiceFactory
18
{
19
    /**
20
     * @param  ContainerInterface $container
21
     *
22
     * @return ContactUsService
23
     */
24
    public function __invoke(ContainerInterface $container)
25
    {
26
        // Create pagination object
27
        $contactUsMapper   = $container->get(ContactUsMapper::class);
28
        $select            = $contactUsMapper->getPaginationSelect();
29
        $pagination        = new Paginator((
30
            new DbSelect(
31
                $select,
32
                $contactUsMapper->getAdapter(),
33
                $contactUsMapper->getResultSetPrototype()
34
            )
35
        ));
36
37
        return new ContactUsService(
38
            $container->get(ContactUsFilter::class),
39
            $container->get(ContactUsMapper::class),
40
            $pagination
41
        );
42
    }
43
}