Base   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 25 2
A serial() 0 4 1
1
<?php
2
3
/**
4
 * Provides a layer for persistency
5
 *
6
 * PHP Version 5
7
 *
8
 * @category  Core
9
 * @package   Datamapper
10
 * @author    Hans-Joachim Piepereit <[email protected]>
11
 * @copyright 2013 cSphere Team
12
 * @license   http://opensource.org/licenses/bsd-license Simplified BSD License
13
 * @link      http://www.csphere.eu
14
 **/
15
16
namespace csphere\core\datamapper;
17
18
/**
19
 * Provides a layer for persistency
20
 *
21
 * @category  Core
22
 * @package   Datamapper
23
 * @author    Hans-Joachim Piepereit <[email protected]>
24
 * @copyright 2013 cSphere Team
25
 * @license   http://opensource.org/licenses/bsd-license Simplified BSD License
26
 * @link      http://www.csphere.eu
27
 **/
28
29
abstract class Base
30
{
31
    /**
32
     * Database service object
33
     **/
34
    protected $database = null;
35
36
    /**
37
     * Name of target plugin
38
     **/
39
    protected $plugin;
40
41
    /**
42
     * Name of plugin table
43
     **/
44
    protected $table;
45
46
    /**
47
     * Name of ID column in that table
48
     **/
49
    protected $serial;
50
51
    /**
52
     * Combination of plugin and table that is generated automatically
53
     **/
54
    protected $schema;
55
56
    /**
57
     * Construction details of schema
58
     **/
59
    protected $structure;
60
61
    /**
62
     * Construction details of schema
63
     **/
64
    protected $joins = [];
65
66
    /**
67
     * Prepare values that are needed for later usage
68
     *
69
     * @param string $plugin Plugin name
70
     * @param string $table  Table name without plugin_ prefix
71
     *
72
     * @return \csphere\core\datamapper\Base
73
     **/
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
Coding Style introduced by
There must be no blank lines after the function comment
Loading history...
74
75
    public function __construct($plugin, $table = '')
76
    {
77
        // Get database service object
78
        $loader = \csphere\core\service\Locator::get();
79
80
        $this->database = $loader->load('database');
81
82
        // Set plugin, table and schema to work with
83
        $this->plugin = $plugin;
84
        $this->table  = $table;
85
86
        $this->schema = $plugin;
87
88
        if ($this->table != '') {
89
90
            $this->schema .= '_' . $this->table;
91
        }
92
93
        // Load schema details, e.g. for creating new entries
94
        $this->structure = \csphere\core\datamapper\Schema::load(
95
            $this->plugin, $this->table
96
        );
97
98
        $this->serial = $this->structure['serial'];
99
    }
100
101
    /**
102
     * Name of serial column in this table
103
     *
104
     * @return string
105
     **/
0 ignored issues
show
Coding Style introduced by
There must be no blank lines after the function comment
Loading history...
106
107
    public function serial()
108
    {
109
        return $this->serial;
110
    }
111
}
112