OledrionObject::toArray()   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
eloc 4
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace XoopsModules\Oledrion;
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
/**
16
 * oledrion
17
 *
18
 * @copyright   {@link https://xoops.org/ XOOPS Project}
19
 * @license     {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
20
 * @author      Hervé Thouzard (http://www.herve-thouzard.com/)
21
 */
22
// defined('XOOPS_ROOT_PATH') || die('Restricted access');
23
24
class OledrionObject extends \XoopsObject
25
{
26
    /**
27
     * @param  string $format
28
     * @return array
29
     */
30
    public function toArray($format = 's')
31
    {
32
        $ret = [];
33
        foreach ($this->vars as $k => $v) {
34
            $ret[$k] = $this->getVar($k, $format);
35
        }
36
37
        return $ret;
38
    }
39
40
    // TODO: Add an insert() method and delete()
41
42
    /**
43
     * Permet de valoriser un champ de la table comme si c'était une propriété de la classe
44
     *
45
     * @example $enregistrement->nom_du_champ = 'ma chaine'
46
     *
47
     * @param  string $key   Le nom du champ à traiter
48
     * @param  mixed  $value La valeur à lui attribuer
49
     */
50
    public function __set($key, $value)
51
    {
52
        return $this->setVar($key, $value);
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->setVar($key, $value) targeting XoopsObject::setVar() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
53
    }
54
55
    /**
56
     * Permet d'accéder aux champs de la table comme à des propriétés de la classe
57
     *
58
     * @example echo $enregistrement->nom_du_champ;
59
     *
60
     * @param  string $key Le nom du champ que l'on souhaite récupérer
61
     * @return mixed
62
     */
63
    public function __get($key)
64
    {
65
        return $this->getVar($key);
66
    }
67
}
68