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

ContactUsMapper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A setDbAdapter() 0 5 1
A getPaginationSelect() 0 6 1
1
<?php
2
3
namespace ContactUs\Mapper;
4
5
use Zend\Db\Adapter\Adapter;
6
use Zend\Db\Adapter\AdapterAwareInterface;
7
use Zend\Db\ResultSet\HydratingResultSet;
8
use Zend\Db\TableGateway\AbstractTableGateway;
9
10
/**
11
 * Class ContactUsMapper
12
 *
13
 * @package ContactUs\Mapper
14
 * @author  Djordje Stojiljkovic <[email protected]>
15
 */
16
class ContactUsMapper extends AbstractTableGateway implements AdapterAwareInterface
17
{
18
    /**
19
     * Table name.
20
     *
21
     * @var string $table
22
     */
23
    protected $table = 'contact_us';
24
25
    /**
26
     * ContactUsMapper constructor.
27
     *
28
     * @param Adapter             $adapter
29
     * @param HydratingResultSet  $resultSet
30
     */
31
    public function __construct(Adapter $adapter, HydratingResultSet $resultSet)
32
    {
33
        $this->resultSetPrototype = $resultSet;
34
        $this->adapter = $adapter;
35
        $this->initialize();
36
    }
37
38
    /**
39
     * @param  Adapter $adapter
40
     *
41
     * @return void
42
     *
43
     * @throws \Exception
44
     */
45
    public function setDbAdapter(Adapter $adapter)
46
    {
47
        $ex = new \Exception('Set DB adapter in constructor.', 400);
48
        throw $ex;
49
    }
50
51
    /**
52
     * @return \Zend\Db\Sql\Select
53
     */
54
    public function getPaginationSelect()
55
    {
56
        return $this->getSql()->select()->order([
57
            'created_at'  => 'desc',
58
        ]);
59
    }
60
}