Completed
Push — master ( fea5ff...68f225 )
by Vítězslav
04:39
created

FlexiBeeRW   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 69
rs 10
wmc 4
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A insertToFlexiBee() 0 8 2
A getLastInsertedId() 0 4 1
A deleteFromFlexiBee() 0 6 1
1
<?php
2
/**
3
 * FlexiPeeHP - Třída pro zápis do FlexiBee.
4
 *
5
 * @author     Vítězslav Dvořák <[email protected]>
6
 * @copyright  (C) 2015,2016 Spoje.Net
7
 */
8
9
namespace FlexiPeeHP;
10
11
class FlexiBeeRW extends FlexiBeeRO
12
{
13
    /**
14
     * Sloupeček obsahující datum vložení záznamu do shopu.
15
     *
16
     * @var string
17
     */
18
    public $myCreateColumn = 'false';
19
20
    /**
21
     * Slopecek obsahujici datum poslení modifikace záznamu do shopu.
22
     *
23
     * @var string
24
     */
25
    public $myLastModifiedColumn = 'lastUpdate';
26
27
    /**
28
     * Last Inserted ID.
29
     *
30
     * @var int
31
     */
32
    public $lastInsertedID = null;
33
34
    /**
35
     * Array of fields for next curl POST operation
36
     * 
37
     * @var array
38
     */
39
    protected $postFields = [];
40
41
    /**
42
     * Uloží záznam.
43
     *
44
     * @param array $data
45
     *
46
     * @return array odpověď
47
     */
48
    public function insertToFlexiBee($data = null)
49
    {
50
        if (is_null($data)) {
51
            $data = $this->getData();
52
        }
53
        $this->postFields = $this->jsonizeData($data);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->jsonizeData($data) of type string is incompatible with the declared type array of property $postFields.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
54
        return $this->performRequest($this->evidence.'.'.$this->format, 'PUT');
55
    }
56
57
    /**
58
     * Give you last inserted record ID.
59
     * 
60
     * @return int
61
     */
62
    public function getLastInsertedId()
63
    {
64
        return $this->lastInsertedID;
65
    }
66
67
    /**
68
     * Smaže záznam
69
     *
70
     * @param int|string $id identifikátor záznamu
71
     * @return boolean Response code is 200 ?
72
     */
73
    public function deleteFromFlexiBee($id)
74
    {
75
        $this->performRequest($this->evidence.'/'.$id.'.'.$this->format,
76
            'DELETE');
77
        return $this->lastResponseCode == 200;
78
    }
79
}