FieldElements::getInstance()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 8
rs 10
c 1
b 0
f 0
1
<?php namespace XoopsModules\Tdmcreate;
2
3
use XoopsModules\Tdmcreate;
4
5
/*
6
 You may not change or alter any portion of this comment or credits
7
 of supporting developers from this source code or any supporting source code
8
 which is considered copyrighted (c) material of the original comment or credit authors.
9
10
 This program is distributed in the hope that it will be useful,
11
 but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 */
14
/**
15
 * tdmcreate module.
16
 *
17
 * @copyright       XOOPS Project (https://xoops.org)
18
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
19
 *
20
 * @since           2.5.5
21
 *
22
 * @author          Txmod Xoops <[email protected]>
23
 *
24
 * @version         $Id: 1.91 fieldelements.php 11297 2014-03-24 09:11:10Z timgno $
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
38
    public function __construct()
39
    {
40
        $this->initVar('fieldelement_id', XOBJ_DTYPE_INT);
41
        $this->initVar('fieldelement_mid', XOBJ_DTYPE_INT);
42
        $this->initVar('fieldelement_tid', XOBJ_DTYPE_INT);
43
        $this->initVar('fieldelement_name', XOBJ_DTYPE_TXTBOX);
44
        $this->initVar('fieldelement_value', XOBJ_DTYPE_TXTBOX);
45
    }
46
47
    /**
48
     * @param string $method
49
     * @param array  $args
50
     *
51
     * @return mixed
52
     */
53
    public function __call($method, $args)
54
    {
55
        $arg = isset($args[0]) ? $args[0] : null;
56
57
        return $this->getVar($method, $arg);
58
    }
59
60
    /**
61
    *  @static function getInstance
62
    *  @param null
63
     * @return FieldElements
64
     */
65
    public static function getInstance()
66
    {
67
        static $instance = false;
68
        if (!$instance) {
69
            $instance = new self();
70
        }
71
72
        return $instance;
73
    }
74
75
    /**
76
     * Get Values.
77
     * @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...
78
     * @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...
79
     * @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...
80
     * @return array
81
     */
82
    public function getValuesFieldElements($keys = null, $format = null, $maxDepth = null)
83
    {
84
        $ret = $this->getValues($keys, $format, $maxDepth);
85
        // Values
86
        $ret['id'] = $this->getVar('fieldelement_id');
87
        $ret['mid'] = $this->getVar('fieldelement_mid');
88
        $ret['tid'] = $this->getVar('fieldelement_tid');
89
        $ret['name'] = $this->getVar('fieldelement_name');
90
        $ret['value'] = $this->getVar('fieldelement_value');
91
92
        return $ret;
93
    }
94
}
95