Passed
Push — master ( 40d774...35f4a7 )
by Vítězslav
23:37 queued 10s
created

Report::loadFromAbraFlexi()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 8
rs 10
cc 3
nc 3
nop 1
1
<?php
2
3
/**
4
 * FlexiPeeHP - Custom Report object.
5
 *
6
 * @author     Vítězslav Dvořák <[email protected]>
7
 * @copyright  (C) 2020 Spoje.Net
8
 */
9
10
namespace FlexiPeeHP;
11
12
/**
13
 * Description of Report
14
 *
15
 * @author vitex
16
 */
17
class Report extends RW {
18
19
    /**
20
     * Evidence užitá objektem.
21
     * Evidence used by object.
22
     *
23
     * @var string
24
     */
25
    public $evidence = 'report';
26
27
    /**
28
     * Načte záznam z FlexiBee a uloží v sobě jeho data
29
     * Read FlexiBee record and store it inside od object
30
     *
31
     * @param int|string $id ID or conditions
32
     *
33
     * @return int počet načtených položek
34
     */
35
    public function loadFromAbraFlexi($id = null) {
36
        if (strstr($id, 'code:')) { //Dirty Hack ⚠ Error 400: Entita 'Report' neobsahuje kód nebo ho nelze použít jako ID (není unikátní)
37
            $candidates = $this->getColumnsFromAbraFlexi(['id', 'kod'], null, 'kod');
38
            if (array_key_exists(\FlexiPeeHP\RO::uncode($id), $candidates)) {
39
                $id = intval($candidates[\FlexiPeeHP\RO::uncode($id)]['id']);
40
            }
41
        }
42
        return parent::loadFromAbraFlexi($id);
43
    }
44
45
    /**
46
     * Update $this->apiURL
47
     */
48
    public function updateApiURL() {
49
        $code = $this->getDataValue('kod');
50
        $this->unsetDataValue('kod');
51
        $result = parent::updateApiURL();
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $result is correct as parent::updateApiURL() targeting FlexiPeeHP\RO::updateApiURL() 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...
52
        $this->setDataValue('kod',$code);
53
        return $result;
54
    }
55
56
}
57