|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* FlexiPeeHP - Objekt Společnosti. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Vítězslav Dvořák <[email protected]> |
|
6
|
|
|
* @copyright (C) 2015-2017 Spoje.Net |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace FlexiPeeHP; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Firmy/účetní jednotky |
|
13
|
|
|
* |
|
14
|
|
|
* @note Tato položka nemá dostupné položky evidence |
|
15
|
|
|
*/ |
|
16
|
|
|
class Company extends FlexiBeeRO |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* Základní namespace pro komunikaci s FlexiBEE. |
|
20
|
|
|
* |
|
21
|
|
|
* @var string Jmený prostor datového bloku odpovědi |
|
22
|
|
|
*/ |
|
23
|
|
|
public $nameSpace = 'companies'; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Default Line Prefix. |
|
27
|
|
|
* |
|
28
|
|
|
* @var string |
|
29
|
|
|
*/ |
|
30
|
|
|
public $prefix = '/c'; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Company. |
|
34
|
|
|
* |
|
35
|
|
|
* @var string |
|
36
|
|
|
*/ |
|
37
|
|
|
public $evidence = ''; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Tato třída nepracuje sezvolenou firmou. |
|
41
|
|
|
* |
|
42
|
|
|
* @var string |
|
43
|
|
|
*/ |
|
44
|
|
|
public $company = ''; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Vrací základní URL pro užitou evidenci |
|
48
|
|
|
* |
|
49
|
|
|
* @link https://www.flexibee.eu/api/dokumentace/ref/urls/ Sestavování URL |
|
50
|
|
|
* @param string $urlSuffix |
|
51
|
|
|
*/ |
|
52
|
|
|
public function getEvidenceURL($urlSuffix = null) |
|
53
|
|
|
{ |
|
54
|
|
|
if (is_null($urlSuffix)) { |
|
55
|
|
|
$urlSuffix = $this->evidence; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
$url = $this->url.$this->prefix; |
|
59
|
|
|
if (!is_null($urlSuffix)) { |
|
60
|
|
|
$url .= (($urlSuffix[0] == '.') ? '' : '/').$urlSuffix; |
|
61
|
|
|
} |
|
62
|
|
|
return $url; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Vrací název evidence použité v odpovědích z FlexiBee |
|
67
|
|
|
* |
|
68
|
|
|
* @return string |
|
69
|
|
|
*/ |
|
70
|
|
|
public function getResponseEvidence() |
|
71
|
|
|
{ |
|
72
|
|
|
return 'company'; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Parse Raw FlexiBee response in several formats |
|
77
|
|
|
* |
|
78
|
|
|
* @param string $responseRaw raw response body |
|
79
|
|
|
* @param string $format Raw Response format json|xml|etc |
|
80
|
|
|
* |
|
81
|
|
|
* @return array |
|
82
|
|
|
*/ |
|
83
|
|
|
public function rawResponseToArray($responseRaw, $format) |
|
84
|
|
|
{ |
|
85
|
|
|
$response = []; |
|
|
|
|
|
|
86
|
|
|
if (strstr($responseRaw, 'winstrom')) { |
|
87
|
|
|
$nsbackup = $this->nameSpace; |
|
88
|
|
|
$this->nameSpace = 'winstrom'; |
|
89
|
|
|
$response = parent::rawResponseToArray($responseRaw, $format); |
|
90
|
|
|
$this->nameSpace = $nsbackup; |
|
91
|
|
|
} else { |
|
92
|
|
|
$response = parent::rawResponseToArray($responseRaw, $format); |
|
93
|
|
|
} |
|
94
|
|
|
return $response; |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.