RegstepHandler::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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

48
            return $fieldHandler->updateAll('step_id', 0, new \Criteria('step_id', /** @scrutinizer ignore-type */ $object->getVar('step_id')), $force);
Loading history...
49
        }
50
51
        return false;
52
    }
53
}
54