Passed
Pull Request — master (#146)
by David
02:27
created

TDBMObject::_getRelationshipPathArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
declare(strict_types=1);
3
4
namespace TheCodingMachine\TDBM;
5
6
/*
7
 Copyright (C) 2006-2009 David Négrier - THE CODING MACHINE
8
9
 This program is free software; you can redistribute it and/or modify
10
 it under the terms of the GNU General Public License as published by
11
 the Free Software Foundation; either version 2 of the License, or
12
 (at your option) any later version.
13
14
 This program is distributed in the hope that it will be useful,
15
 but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 GNU General Public License for more details.
18
19
 You should have received a copy of the GNU General Public License
20
 along with this program; if not, write to the Free Software
21
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22
 */
23
24
/**
25
 * Instances of this class represent an object that is bound to a row in a database table.
26
 * You access access the rows using there name, as a property of an object, or as a table.
27
 * For instance:
28
 *    <code>$tdbmObject->myrow</code>
29
 * or
30
 *    <code>$tdbmObject['myrow']</code>
31
 * are both valid.
32
 *
33
 * @author David Negrier
34
 */
35
class TDBMObject extends AbstractTDBMObject
36
{
37
    /**
38
     * @return mixed|null
39
     */
40
    public function getProperty(string $var, string $tableName = null)
41
    {
42
        return $this->get($var, $tableName);
43
    }
44
45
    /**
46
     * @param string $var
47
     * @param mixed $value
48
     * @param string|null $tableName
49
     * @throws TDBMException
50
     */
51
    public function setProperty(string $var, $value, string $tableName = null): void
52
    {
53
        $this->set($var, $value, $tableName);
54
    }
55
56
    /**
57
     * Specify data which should be serialized to JSON.
58
     *
59
     * @link http://php.net/manual/en/jsonserializable.jsonserialize.php
60
     *
61
     * @return mixed data which can be serialized by <b>json_encode</b>,
62
     *               which is a value of any type other than a resource
63
     *
64
     * @since 5.4.0
65
     */
66
    public function jsonSerialize()
67
    {
68
        throw new TDBMException('Json serialization is only implemented for generated beans.');
69
    }
70
71
    /**
72
     * Returns an array of used tables by this bean (from parent to child relationship).
73
     *
74
     * @return string[]
75
     */
76
    protected function getUsedTables() : array
77
    {
78
        $tableNames = array_keys($this->dbRows);
79
        $tableNames = $this->tdbmService->_getLinkBetweenInheritedTables($tableNames);
80
        $tableNames = array_reverse($tableNames);
81
82
        return $tableNames;
83
    }
84
85
    /**
86
     * @return mixed[]
87
     */
88
    protected function _getRelationshipPathArray(): array
89
    {
90
        return [];
91
    }
92
}
93