Fieldelements::getInstance()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace XoopsModules\Modulebuilder;
4
5
use XoopsModules\Modulebuilder;
6
7
/*
8
 You may not change or alter any portion of this comment or credits
9
 of supporting developers from this source code or any supporting source code
10
 which is considered copyrighted (c) material of the original comment or credit authors.
11
12
 This program is distributed in the hope that it will be useful,
13
 but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
 */
16
/**
17
 * modulebuilder module.
18
 *
19
 * @copyright       XOOPS Project (https://xoops.org)
20
 * @license         GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
21
 *
22
 * @since           2.5.5
23
 *
24
 * @author          Txmod Xoops <[email protected]>
25
 *
26
 */
27
28
/**
29
 * Class Fieldelements.
30
 */
31
class Fieldelements extends \XoopsObject
32
{
33
    /**
34
     * @public function constructor class
35
     * @param null
36
     */
37
    public function __construct()
38
    {
39
        $this->initVar('fieldelement_id', XOBJ_DTYPE_INT);
40
        $this->initVar('fieldelement_mid', XOBJ_DTYPE_INT);
41
        $this->initVar('fieldelement_tid', XOBJ_DTYPE_INT);
42
        $this->initVar('fieldelement_name', XOBJ_DTYPE_TXTBOX);
43
        $this->initVar('fieldelement_value', XOBJ_DTYPE_TXTBOX);
44
        $this->initVar('fieldelement_sort', XOBJ_DTYPE_INT);
45
        $this->initVar('fieldelement_deftype', XOBJ_DTYPE_TXTBOX);
46
        $this->initVar('fieldelement_defvalue', XOBJ_DTYPE_TXTBOX);
47
    }
48
49
    /**
50
     * @param string $method
51
     * @param array  $args
52
     *
53
     * @return mixed
54
     */
55
    public function __call($method, $args)
56
    {
57
        $arg = isset($args[0]) ? $args[0] : null;
58
59
        return $this->getVar($method, $arg);
60
    }
61
62
    /**
63
     * @static function getInstance
64
     * @param null
65
     * @return Fieldelements
66
     */
67
    public static function getInstance()
68
    {
69
        static $instance = false;
70
        if (!$instance) {
71
            $instance = new self();
72
        }
73
74
        return $instance;
75
    }
76
77
    /**
78
     * Get Values.
79
     * @param null $keys
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $keys is correct as it would always require null to be passed?
Loading history...
80
     * @param null $format
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $format is correct as it would always require null to be passed?
Loading history...
81
     * @param null $maxDepth
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $maxDepth is correct as it would always require null to be passed?
Loading history...
82
     * @return array
83
     */
84
    public function getValuesFieldelements($keys = null, $format = null, $maxDepth = null)
85
    {
86
        $ret = $this->getValues($keys, $format, $maxDepth);
87
        // Values
88
        $ret['id']       = $this->getVar('fieldelement_id');
89
        $ret['mid']      = $this->getVar('fieldelement_mid');
90
        $ret['tid']      = $this->getVar('fieldelement_tid');
91
        $ret['name']     = $this->getVar('fieldelement_name');
92
        $ret['value']    = $this->getVar('fieldelement_value');
93
        $ret['sort']     = $this->getVar('fieldelement_sort');
94
        $ret['deftype']  = $this->getVar('fieldelement_deftype');
95
        $ret['defvalue'] = $this->getVar('fieldelement_defvalue');
96
97
        return $ret;
98
    }
99
}
100