Passed
Push — master ( 6209eb...36ba5e )
by Michael
51s queued 14s
created

YogurtRegstepHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 0
f 0
dl 0
loc 28
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A delete() 0 9 2
A __construct() 0 3 1
1
<?php
2
/**
3
 * Extended User Profile
4
 *
5
 * You may not change or alter any portion of this comment or credits
6
 * of supporting developers from this source code or any supporting source code
7
 * which is considered copyrighted (c) material of the original comment or credit authors.
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * @copyright       (c) 2000-2016 XOOPS Project (www.xoops.org)
13
 * @license             GNU GPL 2 (http://www.gnu.org/licenses/gpl-2.0.html)
14
 * @package             profile
15
 * @since               2.3.0
16
 * @author              Jan Pedersen
17
 * @author              Taiwen Jiang <[email protected]>
18
 */
19
20
// defined('XOOPS_ROOT_PATH') || exit("XOOPS root path not defined");
21
22
/**
23
 * Class YogurtRegstep
24
 */
25
class YogurtRegstep extends XoopsObject
26
{
27
    /**
28
     *
29
     */
30
    public function __construct()
31
    {
32
        $this->initVar('step_id', XOBJ_DTYPE_INT);
33
        $this->initVar('step_name', XOBJ_DTYPE_TXTBOX);
34
        $this->initVar('step_desc', XOBJ_DTYPE_TXTAREA);
35
        $this->initVar('step_order', XOBJ_DTYPE_INT, 1);
36
        $this->initVar('step_save', XOBJ_DTYPE_INT, 0);
37
    }
38
}
39
40
/**
41
 * Class YogurtRegstepHandler
42
 */
43
class YogurtRegstepHandler extends XoopsPersistableObjectHandler
44
{
45
    /**
46
     * @param null|object $db
47
     */
48
    public function __construct($db)
49
    {
50
        parent::__construct($db, 'yogurt_profile_regstep', 'yogurtregstep', 'step_id', 'step_name');
51
    }
52
53
    /**
54
     * Delete an object from the database
55
     * @see XoopsPersistableObjectHandler
56
     *
57
     * @param XoopsObject $obj
58
     * @param bool           $force
59
     *
60
     * @return bool
61
     */
62
    public function delete(XoopsObject $obj, $force = false)
63
    {
64
        if (parent::delete($obj, $force)) {
65
            $field_handler = xoops_getModuleHandler('field');
66
67
            return $field_handler->updateAll('step_id', 0, new Criteria('step_id', $obj->getVar('step_id')), $force);
0 ignored issues
show
Bug introduced by
The method updateAll() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

67
            return $field_handler->/** @scrutinizer ignore-call */ updateAll('step_id', 0, new Criteria('step_id', $obj->getVar('step_id')), $force);
Loading history...
Bug introduced by
It seems like $obj->getVar('step_id') can also be of type array and array; however, parameter $value of Criteria::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

67
            return $field_handler->updateAll('step_id', 0, new Criteria('step_id', /** @scrutinizer ignore-type */ $obj->getVar('step_id')), $force);
Loading history...
68
        }
69
70
        return false;
71
    }
72
}
73