Passed
Branch master (5b6d04)
by Michael
03:42
created

TrelloManagement::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php declare(strict_types=1);
2
3
namespace XoopsModules\Publisher;
4
5
use XoopsModules\Publisher\Helper;
6
7
/**
8
 * Class TrelloManagement
9
 */
10
class TrelloManagement
11
{
12
    private $xoopsDb;
13
14
    /**
15
     * TrelloManagement constructor.
16
     * @param $xoopsDb
17
     */
18
    public function __construct($xoopsDb)
19
    {
20
        $this->xoopsDb = $xoopsDb;
21
    }
22
23
    /**
24
     * @param $statusId
25
     * @param $itemId
26
     * @return mixed
27
     */
28
    public function getProjectTaskByStatus($statusId, $itemId)
29
    {
30
        $helper   = Helper::getInstance();
31
        $dbHandle = new TrelloDBController($this->xoopsDb);
32
        $query    = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix($helper->getDirname() . '_items') . 'WHERE status= ? AND itemid = ?';
33
        $result   = $dbHandle->runQuery($query, 'ii', [$statusId, $itemId]);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $result is correct as $dbHandle->runQuery($que...ay($statusId, $itemId)) targeting XoopsModules\Publisher\T...BController::runQuery() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
34
35
        return $result;
36
    }
37
38
    /**
39
     * @return mixed
40
     */
41
    public function getAllStatus()
42
    {
43
        $helper   = Helper::getInstance();
44
        $dbHandle = new TrelloDBController($this->xoopsDb);
45
        $query    = 'SELECT itemid, title, status FROM ' . $GLOBALS['xoopsDB']->prefix($helper->getDirname() . '_items');
46
        $result   = $dbHandle->runBaseQuery($query);
47
48
        return $result;
49
    }
50
51
    /**
52
     * @param $statusId
53
     * @param $itemId
54
     */
55
    public function editTaskStatus($statusId, $itemId)
56
    {
57
        $helper   = Helper::getInstance();
58
        $dbHandle = new TrelloDBController($this->xoopsDb);
59
        $query    = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($helper->getDirname() . '_items') . ' SET status = ? WHERE itemid = ?';
60
        $result   = $dbHandle->update($query, 'ii', [$statusId, $itemId]);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $result is correct as $dbHandle->update($query...ay($statusId, $itemId)) targeting XoopsModules\Publisher\T...oDBController::update() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
61
62
        return $result;
63
    }
64
}
65