Passed
Push — master ( f62223...75b16c )
by Michael
02:33
created

LocationHandler::__construct()   A

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 namespace XoopsModules\Extcal;
2
3
/*
4
 * You may not change or alter any portion of this comment or credits
5
 * of supporting developers from this source code or any supporting source code
6
 * which is considered copyrighted (c) material of the original comment or credit authors.
7
 *
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
13
/**
14
 * @copyright    {@link https://xoops.org/ XOOPS Project}
15
 * @license      {@link http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
16
 * @package      extcal
17
 * @since
18
 * @author       XOOPS Development Team,
19
 */
20
21
//Kraven 30
22
// defined('XOOPS_ROOT_PATH') || die('Restricted access');
23
24
require_once XOOPS_ROOT_PATH . '/kernel/object.php';
0 ignored issues
show
Bug introduced by
The constant XoopsModules\Extcal\XOOPS_ROOT_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
25
26
/**
27
 * Class LocationHandler.
28
 */
29
class LocationHandler extends ExtcalPersistableObjectHandler
30
{
31
    /**
32
     * @param \XoopsDatabase|null $db
33
     */
34
    public function __construct(\XoopsDatabase $db = null)
0 ignored issues
show
Bug introduced by
The type XoopsDatabase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
35
    {
36
        parent::__construct($db, 'extcal_location', Location::class, 'id', 'nom');
0 ignored issues
show
Bug introduced by
It seems like $db can also be of type null; however, parameter $db of XoopsModules\Extcal\Extc...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

36
        parent::__construct(/** @scrutinizer ignore-type */ $db, 'extcal_location', Location::class, 'id', 'nom');
Loading history...
Bug introduced by
'nom' of type string is incompatible with the type boolean expected by parameter $idenfierName of XoopsModules\Extcal\Extc...tHandler::__construct(). ( Ignorable by Annotation )

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

36
        parent::__construct($db, 'extcal_location', Location::class, 'id', /** @scrutinizer ignore-type */ 'nom');
Loading history...
37
    }
38
39
    /**
40
     * @param      $locationId
41
     * @param bool $skipPerm
42
     *
43
     * @return bool
44
     */
45
    public function getLocation($locationId, $skipPerm = false)
46
    {
47
        $user = $GLOBALS['xoopsUser'];
48
49
        $criteriaCompo = new \CriteriaCompo();
0 ignored issues
show
Bug introduced by
The type CriteriaCompo was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
50
        $criteriaCompo->add(new \Criteria('id', $locationId));
0 ignored issues
show
Bug introduced by
The type Criteria was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
51
52
        if (!$skipPerm) {
53
            $this->addCatPermCriteria($criteriaCompo, $user);
54
        }
55
        $ret = $this->getObjects($criteriaCompo);
56
        if (isset($ret[0])) {
57
            return $ret[0];
58
        } else {
59
            return false;
60
        }
61
    }
62
63
    /**
64
     * @param \CriteriaElement $criteria
65
     * @param null             $fields
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $fields is correct as it would always require null to be passed?
Loading history...
66
     * @param bool             $asObject
67
     * @param bool             $id_as_key
68
     *
69
     * @return array
70
     */
71
    public function &getAll(
72
        \CriteriaElement $criteria = null,
0 ignored issues
show
Bug introduced by
The type CriteriaElement was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
73
        $fields = null,
74
        $asObject = true,
75
        $id_as_key = true
76
    ) //getAll($criteria = null, $asObject = false)
77
    {
78
        $rst = $this->getObjects($criteria, $asObject);
79
        if ($asObject) {
80
            return $rst;
81
        } else {
82
            return $this->objectToArray($rst);
83
        }
84
    }
85
}
86