Passed
Pull Request — master (#81)
by Michael
03:00
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
/**
27
 * Class RegstepHandler
28
 */
29
class RegstepHandler extends \XoopsPersistableObjectHandler
30
{
31
    /**
32
     * @param null|object $db
33
     */
34
35
    public function __construct($db)
36
    {
37
        parent::__construct($db, 'yogurt_profile_regstep', Regstep::class, 'step_id', 'step_name');
38
    }
39
40
    /**
41
     * Delete an object from the database
42
     * @param \XoopsObject $obj
43
     * @param bool         $force
44
     *
45
     * @return bool
46
     * @see XoopsPersistableObjectHandler
47
     */
48
49
    public function delete(\XoopsObject $obj, $force = false)
50
    {
51
        if (parent::delete($obj, $force)) {
52
            $field_handler = \xoops_getModuleHandler('field');
53
54
            return $field_handler->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

54
            return $field_handler->updateAll('step_id', 0, new \Criteria('step_id', /** @scrutinizer ignore-type */ $obj->getVar('step_id')), $force);
Loading history...
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

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