Passed
Pull Request — master (#81)
by Michael
02:58
created

RegstepHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 6
dl 0
loc 29
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A delete() 0 9 2
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace XoopsModules\Yogurt;
6
7
/**
8
 * Extended User Profile
9
 *
10
 * You may not change or alter any portion of this comment or credits
11
 * of supporting developers from this source code or any supporting source code
12
 * which is considered copyrighted (c) material of the original comment or credit authors.
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
 *
17
 * @copyright       (c) 2000-2016 XOOPS Project (www.xoops.org)
18
 * @license             GNU GPL 2 (http://www.gnu.org/licenses/gpl-2.0.html)
19
 * @package             profile
20
 * @since               2.3.0
21
 * @author              Jan Pedersen
22
 * @author              Taiwen Jiang <[email protected]>
23
 */
24
25
/**
26
 * Class RegstepHandler
27
 */
28
class RegstepHandler extends \XoopsPersistableObjectHandler
29
{
30
    /**
31
     * @param null|object $db
32
     */
33
34
    public function __construct($db)
35
    {
36
        parent::__construct($db, 'yogurt_profile_regstep', Regstep::class, 'step_id', 'step_name');
37
    }
38
39
    /**
40
     * Delete an object from the database
41
     * @param \XoopsObject $obj
42
     * @param bool         $force
43
     *
44
     * @return bool
45
     * @see XoopsPersistableObjectHandler
46
     */
47
48
    public function delete(\XoopsObject $obj, $force = false)
49
    {
50
        if (parent::delete($obj, $force)) {
51
            $fieldHandler = \XoopsModules\Yogurt\Helper::getInstance()->getHandler('Field');
52
53
            return $fieldHandler->updateAll('step_id', 0, new \Criteria('step_id', $obj->getVar('step_id')), $force);
0 ignored issues
show
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

53
            return $fieldHandler->updateAll('step_id', 0, new \Criteria('step_id', /** @scrutinizer ignore-type */ $obj->getVar('step_id')), $force);
Loading history...
54
        }
55
56
        return false;
57
    }
58
}
59