DeliveryPaymentHandler::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
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      Hossein Azizabadi ([email protected])
21
 */
22
23
use XoopsModules\Oledrion;
24
25
/**
26
 * Class DeliveryPaymentHandler
27
 */
28
class DeliveryPaymentHandler extends OledrionPersistableObjectHandler
29
{
30
    /**
31
     * DeliveryPaymentHandler constructor.
32
     * @param \XoopsDatabase|null $db
33
     */
34
    public function __construct(\XoopsDatabase $db = null)
35
    {
36
        //                                          Table                           Classe                    Id
37
        parent::__construct($db, 'oledrion_delivery_payment', DeliveryPayment::class, 'dp_id');
0 ignored issues
show
Bug introduced by
It seems like $db can also be of type null; however, parameter $db of XoopsModules\Oledrion\Ol...tHandler::__construct() does only seem to accept XoopsDatabase, 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

37
        parent::__construct(/** @scrutinizer ignore-type */ $db, 'oledrion_delivery_payment', DeliveryPayment::class, 'dp_id');
Loading history...
38
    }
39
40
    /**
41
     * @param $parameters
42
     * @return array
43
     */
44
    public function getDeliveryPaymantId($parameters)
45
    {
46
        $ret = [];
47
        if (!$parameters['delivery']) {
48
            return $ret;
49
        }
50
        $critere = new \CriteriaCompo();
51
        $critere->add(new \Criteria('dp_delivery', $parameters['delivery']));
52
        $obj = $this->getObjects($critere);
53
        if ($obj) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $obj of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
54
            foreach ($obj as $root) {
55
                $tab                              = [];
0 ignored issues
show
Unused Code introduced by
The assignment to $tab is dead and can be removed.
Loading history...
56
                $tab                              = $root->toArray();
57
                $ret[$root->getVar('dp_payment')] = $tab;
58
            }
59
        }
60
61
        return $ret;
62
    }
63
}
64