Test Failed
Push — master ( 237146...d3d5d7 )
by Vítězslav
05:39
created

Zurnal   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 54
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAllChanges() 0 16 3
A getLastChange() 0 9 2
1
<?php
2
/**
3
 * FlexiPeeHP - Objekt Žurnálu.
4
 *
5
 * @author     Vítězslav Dvořák <[email protected]>
6
 * @copyright  (C) 2017 Spoje.Net
7
 */
8
9
namespace FlexiPeeHP;
10
11
/**
12
 * Žurnál změn
13
 * Journal of Changes
14
 *
15
 * @link https://demo.flexibee.eu/c/demo/adresar/properties položky evidence
16
 */
17
class Zurnal extends FlexiBeeRO
18
{
19
    /**
20
     * Evidence užitá objektem.
21
     *
22
     * @var string
23
     */
24
    public $evidence = 'zurnal';
25
26
    /**
27
     *
28
     * @var type
29
     */
30
    public static $evidenceToDb = ['faktura-vydana' => 'ddoklfak'];
31
32
    /**
33
     * obtain all record changes array
34
     *
35
     * @param FlexiBeeRO $object
36
     * @return array changes history
37
     */
38
    public function getAllChanges($object)
39
    {
40
        $changesArray = [];
41
42
        $evidence = $object->getEvidence();
43
        if (array_key_exists($evidence, self::$evidenceToDb)) {
44
            $dbTable = self::$evidenceToDb[$evidence];
45
            $changes = $this->getColumnsFromFlexibee('*',
0 ignored issues
show
Documentation introduced by
'*' is of type string, but the function expects a array<integer,string>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
46
                ['tabulka' => $dbTable, 'idZaznamu' => $object->getMyKey()]);
47
48
            foreach ($changes as $change) {
49
                $changesArray[$change['datCas']][$change['sloupec']] = $change;
50
            }
51
        }
52
        return $changesArray;
53
    }
54
55
    /**
56
     * obtain last change array
57
     *
58
     * @param FlexiBeeRO $object
59
     * @return array Old/New values pairs
60
     */
61
    public function getLastChange($object)
62
    {
63
        $lastChange = null;
64
        $allChanges = $this->getAllChanges($object);
65
        if (count($allChanges)) {
66
            $lastChange = end($allChanges);
67
        }
68
        return $lastChange;
69
    }
70
}
71