Test Failed
Push — master ( 0a6b17...c396e6 )
by Vítězslav
07:31
created

Changes   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 89
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 47.62%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
dl 0
loc 89
ccs 10
cts 21
cp 0.4762
rs 10
c 2
b 1
f 0
wmc 9
lcom 2
cbo 1

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getStatus() 0 6 2
A recordExists() 0 4 1
A getGlobalVersion() 0 7 2
A rawXmlToArray() 0 4 1
A getVazby() 0 4 1
A enable() 0 5 1
A disable() 0 5 1
1
<?php
2
/**
3
 * FlexiPeeHP - Objekt záznamu změn.
4
 *
5
 * @author     Vítězslav Dvořák <[email protected]>
6
 * @copyright  (C) 2016-2017 Spoje.Net
7
 */
8
9
namespace FlexiPeeHP;
10
11
/**
12
 * Log změn v evidencích
13
 *
14
 * @link https://www.flexibee.eu/api/dokumentace/ref/changes-api/ Dokumentace
15
 */
16
class Changes extends FlexiBeeRO
17
{
18
    /**
19
     * Evidence užitá objektem.
20
     *
21
     * @var string
22
     */
23
    public $evidence = 'changes';
24
25
    /**
26
     * Povolí oznamování změn
27
     * @return type
28
     */
29 1
    public function enable()
30
    {
31 1
        $this->performRequest('enable.xml', 'POST', 'xml');
32
        return $this->lastResponseCode == 200;
33
    }
34
35
    /**
36
     * Zakáže oznamování změn
37
     * @return type
38
     */
39 1
    public function disable()
40
    {
41 1
        $this->performRequest('disable.xml', 'POST', 'xml');
42
        return $this->lastResponseCode == 200;
43
    }
44
45
    /**
46
     * Vrátí stav zapnutí ChangesAPI
47
     *
48
     * @return boolan
49
     */
50 1
    public function getStatus()
51
    {
52 1
        $status = $this->performRequest('status.xml', 'GET', 'xml');
53 1
        return (($this->lastResponseCode == 200) && ($status['changes'][0]['success']
54 1
            === 'true'));
55
    }
56
57
    /**
58
     * Test if given record exists in FlexiBee .
59
     *
60
     * @param array $data
61
     * @return null Method is disabled for Changes
62
     */
63 1
    public function recordExists($data = null)
64
    {
65 1
        return null;
66
    }
67
68
    /**
69
     * Obtain actual GlobalVersion
70
     * Vrací aktuální globální verzi změn
71
     *
72
     * @link https://www.flexibee.eu/api/dokumentace/ref/changes-api#globalVersion Globální Verze
73
     * @return int
74
     */
75
    public function getGlobalVersion()
76
    {
77
        $this->getColumnsFromFlexibee('*', ['start' => 0, 'limit' => 0]);
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...
78
        $globalVersionRaw = json_decode($this->lastCurlResponse, TRUE);
79
        return isset($globalVersionRaw[$this->nameSpace]['@globalVersion']) ? intval($globalVersionRaw[$this->nameSpace]['@globalVersion'])
80
                : null;
81
    }
82
83
    /**
84
     * Convert FlexiBee Response XML to Array
85
     *
86
     * @param string $rawXML
87
     *
88
     * @return array
89
     */
90
    public function rawXmlToArray($rawXML)
91
    {
92
        return [$this->getEvidence() => parent::rawXmlToArray($rawXML)];
93
    }
94
95
    /**
96
     * Changes has no relations
97
     *
98
     * @return null
99
     */
100
    public function getVazby($id = null)
101
    {
102
        throw new \Exception(_('Changes has no relations'));
103
    }
104
}
105