PageMapper   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 3

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setDbAdapter() 0 4 1
A __construct() 0 6 1
A getPaginationSelect() 0 9 1
A getActivePage() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Page\Mapper;
6
7
use Zend\Db\Adapter\Adapter;
8
use Zend\Db\Adapter\AdapterAwareInterface;
9
use Zend\Db\ResultSet\HydratingResultSet;
10
use Zend\Db\TableGateway\AbstractTableGateway;
11
12
class PageMapper extends AbstractTableGateway implements AdapterAwareInterface
13
{
14
    protected $table = 'page';
15
16
    public function setDbAdapter(Adapter $adapter)
17
    {
18
        throw new \Exception('Set DB adapter in constructor.', 400);
19
    }
20
21
    public function __construct(Adapter $adapter, HydratingResultSet $resultSet)
22
    {
23
        $this->resultSetPrototype = $resultSet;
24
        $this->adapter = $adapter;
25
        $this->initialize();
26
    }
27
28
    public function getPaginationSelect()
29
    {
30
        return $this->getSql()->select()->order(
31
            [
32
            'is_homepage' => 'desc',
33
            'created_at'  => 'desc',
34
            ]
35
        );
36
    }
37
38
    public function getActivePage($urlSlug)
39
    {
40
        return $this->select(['slug' => $urlSlug, 'is_active' => true]);
41
    }
42
}
43