TestMapper   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 92
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3
Metric Value
wmc 12
lcom 1
cbo 3
dl 0
loc 92
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A insert() 0 4 1
A getDbAdapter() 0 4 1
A getSchema() 0 4 1
A getServiceManager() 0 4 1
A setup() 0 6 2
A teardown() 0 6 2
A query() 0 8 1
A setDbAdapter() 0 5 1
A setSchema() 0 5 1
A setServiceManager() 0 5 1
1
<?php
2
3
namespace SpeckCatalogTest\Mapper\TestAsset;
4
5
use ZfcBase\Mapper\AbstractDbMapper;
6
7
class TestMapper extends AbstractDbMapper
8
{
9
    protected $schema = array();
10
11
    protected $serviceManager;
12
13
    protected $dbAdapter;
14
15
    public function setup()
16
    {
17
        foreach ($this->getSchema() as $statement) {
18
            $this->getDbAdapter()->query($statement)->execute();
19
        };
20
    }
21
22
    public function teardown()
23
    {
24
        foreach ($this->getSchema() as $tableName => $statement) {
25
            $this->getDbAdapter()->query("drop table {$tableName}")->execute();
26
        };
27
    }
28
29
    //PUBLIC
30
    public function insert($data, $tableName = null, \Zend\Stdlib\Hydrator\HydratorInterface $hydrator = null)
31
    {
32
        return parent::insert($data, $tableName);
33
    }
34
35
    public function query(\Zend\Db\Sql\Select $select)
36
    {
37
        $dbAdapter = $this->getDbAdapter();
38
        $platform = $dbAdapter->getPlatform();
39
        $sql = $select->getSqlString($platform);
40
        $result = $dbAdapter->query($sql)->execute()->current();
41
        return $result;
42
    }
43
44
45
    /**
46
     * @return dbAdapter
47
     */
48
    public function getDbAdapter()
49
    {
50
        return $this->dbAdapter;
51
    }
52
53
    /**
54
     * @param $dbAdapter
55
     * @return self
56
     */
57
    public function setDbAdapter(\Zend\Db\Adapter\Adapter $dbAdapter)
58
    {
59
        $this->dbAdapter = $dbAdapter;
60
        return $this;
61
    }
62
63
    /**
64
     * @return schema
65
     */
66
    public function getSchema()
67
    {
68
        return $this->schema;
69
    }
70
71
    /**
72
     * @param $schema
73
     * @return self
74
     */
75
    public function setSchema($schema)
76
    {
77
        $this->schema = $schema;
78
        return $this;
79
    }
80
81
    /**
82
     * @return serviceManager
83
     */
84
    public function getServiceManager()
85
    {
86
        return $this->serviceManager;
87
    }
88
89
    /**
90
     * @param $serviceManager
91
     * @return self
92
     */
93
    public function setServiceManager($serviceManager)
94
    {
95
        $this->serviceManager = $serviceManager;
96
        return $this;
97
    }
98
}
99