Complex classes like FlexiBeeRO often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use FlexiBeeRO, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
16 | class FlexiBeeRO extends \Ease\Sand |
||
17 | { |
||
18 | |||
19 | use \Ease\RecordKey; |
||
20 | /** |
||
21 | * Where to get JSON files with evidence stricture etc. |
||
22 | * @var string |
||
23 | */ |
||
24 | public static $infoDir = __DIR__.'/../../static'; |
||
25 | |||
26 | /** |
||
27 | * Version of FlexiPeeHP library |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | public static $libVersion = '1.32'; |
||
32 | |||
33 | /** |
||
34 | * Základní namespace pro komunikaci s FlexiBee. |
||
35 | * Basic namespace for communication with FlexiBee |
||
36 | * |
||
37 | * @var string Jmený prostor datového bloku odpovědi |
||
38 | */ |
||
39 | public $nameSpace = 'winstrom'; |
||
40 | |||
41 | /** |
||
42 | * URL of object data in FlexiBee |
||
43 | * @var string url |
||
44 | */ |
||
45 | public $apiURL = null; |
||
46 | |||
47 | /** |
||
48 | * Datový blok v poli odpovědi. |
||
49 | * Data block in response field. |
||
50 | * |
||
51 | * @var string |
||
52 | */ |
||
53 | public $resultField = 'results'; |
||
54 | |||
55 | /** |
||
56 | * Verze protokolu použitého pro komunikaci. |
||
57 | * Communication protocol version used. |
||
58 | * |
||
59 | * @var string Verze použitého API |
||
60 | */ |
||
61 | public $protoVersion = '1.0'; |
||
62 | |||
63 | /** |
||
64 | * Evidence užitá objektem. |
||
65 | * Evidence used by object |
||
66 | * |
||
67 | * @link https://demo.flexibee.eu/c/demo/evidence-list Přehled evidencí |
||
68 | * @var string |
||
69 | */ |
||
70 | public $evidence = null; |
||
71 | |||
72 | /** |
||
73 | * Detaily evidence užité objektem |
||
74 | * |
||
75 | * @var array |
||
76 | */ |
||
77 | public $evidenceInfo = []; |
||
78 | |||
79 | /** |
||
80 | * Výchozí formát pro komunikaci. |
||
81 | * Default communication format. |
||
82 | * |
||
83 | * @link https://www.flexibee.eu/api/dokumentace/ref/format-types Přehled možných formátů |
||
84 | * |
||
85 | * @var string json|xml|... |
||
86 | */ |
||
87 | public $format = 'json'; |
||
88 | |||
89 | /** |
||
90 | * formát příchozí odpovědi |
||
91 | * response format |
||
92 | * |
||
93 | * @link https://www.flexibee.eu/api/dokumentace/ref/format-types Přehled možných formátů |
||
94 | * |
||
95 | * @var string json|xml|... |
||
96 | */ |
||
97 | public $responseFormat = 'json'; |
||
98 | |||
99 | /** |
||
100 | * Curl Handle. |
||
101 | * |
||
102 | * @var resource |
||
103 | */ |
||
104 | public $curl = null; |
||
105 | |||
106 | /** |
||
107 | * @link https://demo.flexibee.eu/devdoc/company-identifier Identifikátor firmy |
||
108 | * @var string |
||
109 | */ |
||
110 | public $company = null; |
||
111 | |||
112 | /** |
||
113 | * [protocol://]Server[:port] |
||
114 | * @var string |
||
115 | */ |
||
116 | public $url = null; |
||
117 | |||
118 | /** |
||
119 | * REST API Username |
||
120 | * @var string |
||
121 | */ |
||
122 | public $user = null; |
||
123 | |||
124 | /** |
||
125 | * REST API Password |
||
126 | * @var string |
||
127 | */ |
||
128 | public $password = null; |
||
129 | |||
130 | /** |
||
131 | * @var array Pole HTTP hlaviček odesílaných s každým požadavkem |
||
132 | */ |
||
133 | public $defaultHttpHeaders = ['User-Agent' => 'FlexiPeeHP']; |
||
134 | |||
135 | /** |
||
136 | * Default additional request url parameters after question mark |
||
137 | * |
||
138 | * @link https://www.flexibee.eu/api/dokumentace/ref/urls Common params |
||
139 | * @link https://www.flexibee.eu/api/dokumentace/ref/paging Paging params |
||
140 | * @var array |
||
141 | */ |
||
142 | public $defaultUrlParams = []; |
||
143 | |||
144 | /** |
||
145 | * Identifikační řetězec. |
||
146 | * |
||
147 | * @var string |
||
148 | */ |
||
149 | public $init = null; |
||
150 | |||
151 | /** |
||
152 | * Sloupeček s názvem. |
||
153 | * |
||
154 | * @var string |
||
155 | */ |
||
156 | public $nameColumn = 'nazev'; |
||
157 | |||
158 | /** |
||
159 | * Sloupeček obsahující datum vložení záznamu do shopu. |
||
160 | * |
||
161 | * @var string |
||
162 | */ |
||
163 | public $myCreateColumn = 'false'; |
||
164 | |||
165 | /** |
||
166 | * Slopecek obsahujici datum poslení modifikace záznamu do shopu. |
||
167 | * |
||
168 | * @var string |
||
169 | */ |
||
170 | public $myLastModifiedColumn = 'lastUpdate'; |
||
171 | |||
172 | /** |
||
173 | * Klíčový idendifikátor záznamu. |
||
174 | * |
||
175 | * @var string |
||
176 | */ |
||
177 | public $fbKeyColumn = 'id'; |
||
178 | |||
179 | /** |
||
180 | * Informace o posledním HTTP requestu. |
||
181 | * |
||
182 | * @var * |
||
183 | */ |
||
184 | public $curlInfo; |
||
185 | |||
186 | /** |
||
187 | * Informace o poslední HTTP chybě. |
||
188 | * |
||
189 | * @var string |
||
190 | */ |
||
191 | public $lastCurlError = null; |
||
192 | |||
193 | /** |
||
194 | * Used codes storage. |
||
195 | * |
||
196 | * @var array |
||
197 | */ |
||
198 | public $codes = null; |
||
199 | |||
200 | /** |
||
201 | * Last Inserted ID. |
||
202 | * |
||
203 | * @var int |
||
204 | */ |
||
205 | public $lastInsertedID = null; |
||
206 | |||
207 | /** |
||
208 | * Default Line Prefix. |
||
209 | * |
||
210 | * @var string |
||
211 | */ |
||
212 | public $prefix = '/c/'; |
||
213 | |||
214 | /** |
||
215 | * Raw Content of last curl response |
||
216 | * |
||
217 | * @var string |
||
218 | */ |
||
219 | public $lastCurlResponse; |
||
220 | |||
221 | /** |
||
222 | * HTTP Response code of last request |
||
223 | * |
||
224 | * @var int |
||
225 | */ |
||
226 | public $lastResponseCode = null; |
||
227 | |||
228 | /** |
||
229 | * Body data for next curl POST operation |
||
230 | * |
||
231 | * @var string |
||
232 | */ |
||
233 | protected $postFields = null; |
||
234 | |||
235 | /** |
||
236 | * Last operation result data or message(s) |
||
237 | * |
||
238 | * @var array |
||
239 | */ |
||
240 | public $lastResult = null; |
||
241 | |||
242 | /** |
||
243 | * Number from @rowCount in response |
||
244 | * @var int |
||
245 | */ |
||
246 | public $rowCount = null; |
||
247 | |||
248 | /** |
||
249 | * Number from @globalVersion |
||
250 | * @var int |
||
251 | */ |
||
252 | public $globalVersion = null; |
||
253 | |||
254 | /** |
||
255 | * @link https://www.flexibee.eu/api/dokumentace/ref/zamykani-odemykani/ |
||
256 | * @var string filter query |
||
257 | */ |
||
258 | public $filter; |
||
259 | |||
260 | /** |
||
261 | * @link https://demo.flexibee.eu/devdoc/actions Provádění akcí |
||
262 | * @var string |
||
263 | */ |
||
264 | protected $action; |
||
265 | |||
266 | /** |
||
267 | * Pole akcí které podporuje ta která evidence |
||
268 | * @link https://demo.flexibee.eu/c/demo/faktura-vydana/actions.json Např. Akce faktury |
||
269 | * @var array |
||
270 | */ |
||
271 | public $actionsAvailable = null; |
||
272 | |||
273 | /** |
||
274 | * Parmetry pro URL |
||
275 | * @link https://www.flexibee.eu/api/dokumentace/ref/urls/ Všechny podporované parametry |
||
276 | * @var array |
||
277 | */ |
||
278 | public $urlParams = [ |
||
279 | 'add-global-version' => ['type' => 'boolean', 'description' => 'The response will contain the global version number of the current export'], |
||
280 | 'add-row-count' => ['type' => 'boolean', 'description' => 'Adding Total Records to Output (Pagination)'], |
||
281 | 'as-gui' => ['type' => 'boolean', 'description' => 'Turns on functions that complement the GUI processing outputs'], |
||
282 | 'auth' => ['type' => 'string', 'description' => 'http: Forces login using HTTP authentication, for example, to change the default WUI login method. html: Force HTML form authentication. This can be useful to suppress automatic SSO authentication.'], |
||
283 | 'authSessionId' => ['type' => 'string', 'description' => 'Authentification Session ID'], |
||
284 | 'code-as-id' => ['type' => 'boolean', 'description' => 'If an object has unique code, it is also exported (except for the <code> element) as <id> code: ... </id>'], |
||
285 | 'code-in-response' => ['type' => 'boolean', 'description' => 'The response will contain not only ID and URL for each object, but also code.'], |
||
286 | 'delimeter' => ['type' => 'string', 'description' => 'Specifies the input / output file separator in CSV format.', |
||
287 | 'example' => ';'], |
||
288 | 'detail' => ['type' => 'string', 'description' => 'Definition of the level of detail'], //See: https://www.flexibee.eu/api/dokumentace/ref/detail-levels |
||
289 | 'dir' => ['type' => 'string', 'description' => 'Sorting direction.', 'example' => 'desc'], |
||
290 | 'dry-run' => ['type' => 'boolean', 'description' => 'Test run (dry-run)'], // See: https://www.flexibee.eu/api/dokumentace/ref/dry-run/ |
||
291 | 'encoding' => ['type' => 'string', 'description' => 'Specifies the encoding of the input / output file in CSV format.'], |
||
292 | 'export-settings' => ['type' => 'boolean', 'description' => 'Export one extra entry with current settings at the beginning'], |
||
293 | 'fail-on-warning' => ['type' => 'boolean', 'description' => 'If a warning occurs, do not save a record (Data Validation)'], |
||
294 | 'filter' => ['type' => 'string', 'description' => 'filter results by this param'], |
||
295 | 'format' => ['type' => 'string', 'description' => 'One of the compiled XSL transforms will be applied to the output XML.'], |
||
296 | 'idUcetniObdobi' => ['type' => 'string', 'description' => ''], //See: https://www.flexibee.eu/api/dokumentace/ref/stavy-uctu/ |
||
297 | 'includes' => ['type' => 'string', 'description' => 'Include related detail level object ', |
||
298 | 'example' => 'faktura-vydana/stredisko'], |
||
299 | 'inDesktopApp' => ['type' => 'boolean', 'description' => 'Hide menu and navigation in html format'], // Note: Undocumented function (html only) |
||
300 | 'limit' => ['type' => 'integer', 'description' => 'number of requested results'], |
||
301 | 'mode' => ['type' => 'string', 'description' => 'Support for RubyOnRails', |
||
302 | 'example' => 'ruby'], |
||
303 | 'no-ext-ids' => ['type' => 'boolean', 'description' => 'The answer will not contain external identifiers (performance optimization)'], |
||
304 | 'no-http-errors' => ['type' => 'boolean', 'description' => 'If a 4xx error occurs while processing a request, the server sends 200 OK anyway'], |
||
305 | 'no-ids' => ['type' => 'boolean', 'description' => 'The response will not contain any primary identifiers (performance optimization). It only affects the main records.'], |
||
306 | 'only-ext-ids' => ['type' => 'boolean', 'description' => 'The primary key will not be exported, the <id> elements will only contain the external ID. Similar no-ids, but also affects subevidencies.'], |
||
307 | 'order' => ['type' => 'string', 'description' => 'Sorting records', 'example' => 'nazev@A'], |
||
308 | 'relations' => ['type' => 'string', 'description' => 'Adding session data (see detail levels) A session overview can be obtained for each record (/ relations).'], |
||
309 | 'report-lang' => ['type' => 'string', 'description' => 'The language in which to print the output when exporting to PDF', |
||
310 | 'example' => 'en'], |
||
311 | 'report-name' => ['type' => 'string', 'description' => 'The name of the printout when exporting to PDF', |
||
312 | 'example' => 'invoice'], |
||
313 | 'report-sign' => ['type' => 'string', 'description' => 'Whether the PDF should be exported electronically signed'], |
||
314 | 'skupina-stitku' => ['type' => 'string', 'description' => 'Enables grouping of labels when exporting by group (multiple labels)'], |
||
315 | 'sort' => ['type' => 'string', 'description' => 'Sorting records for ExtJS'], |
||
316 | 'start' => ['type' => 'integer', 'description' => 'Pagination'], |
||
317 | 'stitky-as-ids' => ['type' => 'boolean', 'description' => 'Labels will be exported and imported not as a code list but as a list of numeric IDs'], |
||
318 | 'use-ext-id' => ['type' => 'boolean', 'description' => 'If the object contains an external ESHOP or MY ID, use it as a bind.'], |
||
319 | 'use-internal-id' => ['type' => 'boolean', 'description' => 'In addition to the ref and showAs for objects, it also supplies an internalId attribute that contains the internal record ID'], |
||
320 | 'xpath' => ['type' => 'string', 'description' => 'Apply XPATH to result', |
||
321 | 'example' => '//winstrom/adresar/email/text()'] // See: https://www.flexibee.eu/api/dokumentace/ref/xpath/ |
||
322 | ]; |
||
323 | |||
324 | /** |
||
325 | * Session ID |
||
326 | * @var string |
||
327 | */ |
||
328 | public $authSessionId = null; |
||
329 | |||
330 | /** |
||
331 | * Token obtained during login procedure |
||
332 | * @var string |
||
333 | */ |
||
334 | public $refreshToken = null; |
||
335 | |||
336 | /** |
||
337 | * Save 404 results to log ? |
||
338 | * @var boolean |
||
339 | */ |
||
340 | protected $ignoreNotFound = false; |
||
341 | |||
342 | /** |
||
343 | * Array of errors caused by last request |
||
344 | * @var array |
||
345 | */ |
||
346 | private $errors = []; |
||
347 | |||
348 | /** |
||
349 | * List of Error500 reports sent |
||
350 | * @var array |
||
351 | */ |
||
352 | private $reports = []; |
||
353 | |||
354 | /** |
||
355 | * Send Error500 Report to |
||
356 | * @var string email address |
||
357 | */ |
||
358 | public $reportRecipient = '[email protected]'; |
||
359 | |||
360 | /** |
||
361 | * Formating string for \DateTime::format() for datetime columns |
||
362 | * @var string |
||
363 | */ |
||
364 | static public $DateTimeFormat = 'Y-m-d\TH:i:s.u+P'; |
||
365 | |||
366 | /** |
||
367 | * Formating string for \DateTime::format() for date columns |
||
368 | * @var string |
||
369 | */ |
||
370 | static public $DateFormat = 'Y-m-d'; |
||
371 | |||
372 | /** |
||
373 | * Last Request response stats |
||
374 | * @var array |
||
375 | */ |
||
376 | protected $responseStats = null; |
||
377 | |||
378 | /** |
||
379 | * Chained Objects |
||
380 | * @var array |
||
381 | */ |
||
382 | public $chained = []; |
||
383 | |||
384 | /** |
||
385 | * We Connect to server by default |
||
386 | * @var boolean |
||
387 | */ |
||
388 | public $offline = false; |
||
389 | |||
390 | /** |
||
391 | * Override cURL timeout |
||
392 | * @var int seconds |
||
393 | */ |
||
394 | public $timeout = null; |
||
395 | |||
396 | /** |
||
397 | * Columns Info for serveral evidencies |
||
398 | * @var array |
||
399 | */ |
||
400 | private $columnsInfo = []; |
||
401 | |||
402 | /** |
||
403 | * Class for read only interaction with FlexiBee. |
||
404 | * |
||
405 | * @param mixed $init default record id or initial data. See processInit() |
||
406 | * @param array $options Connection settings and other options override |
||
407 | */ |
||
408 | public function __construct($init = null, $options = []) |
||
418 | |||
419 | /** |
||
420 | * Set internal Object name |
||
421 | * |
||
422 | * @param string $objectName |
||
423 | * |
||
424 | * @return string Jméno objektu |
||
425 | */ |
||
426 | public function setObjectName($objectName = null) |
||
432 | |||
433 | /** |
||
434 | * SetUp Object to be ready for work |
||
435 | * |
||
436 | * @param array $options Object Options ( user,password,authSessionId |
||
437 | * company,url,evidence, |
||
438 | * prefix,defaultUrlParams,debug, |
||
439 | * detail,offline,filter,ignore404 |
||
440 | * timeout,companyUrl,ver |
||
441 | */ |
||
442 | public function setUp($options = []) |
||
484 | |||
485 | /** |
||
486 | * Set up one of properties |
||
487 | * |
||
488 | * @param array $options array of given properties |
||
489 | * @param string $name name of property to process |
||
490 | * @param string $constant load default property value from constant |
||
491 | */ |
||
492 | public function setupProperty($options, $name, $constant = null) |
||
504 | |||
505 | /** |
||
506 | * Convert companyUrl provided by CustomButton to options array |
||
507 | * |
||
508 | * @param string $companyUrl |
||
509 | * |
||
510 | * @return array Options |
||
511 | */ |
||
512 | public static function companyUrlToOptions($companyUrl) |
||
524 | |||
525 | /** |
||
526 | * Get Current connection options for use in another object |
||
527 | * |
||
528 | * @return array usable as second constructor parameter |
||
529 | */ |
||
530 | public function getConnectionOptions() |
||
548 | |||
549 | /** |
||
550 | * Inicializace CURL |
||
551 | * |
||
552 | * @return boolean Online Status |
||
553 | */ |
||
554 | public function curlInit() |
||
574 | |||
575 | /** |
||
576 | * Zinicializuje objekt dle daných dat. Možné hodnoty: |
||
577 | * |
||
578 | * * 234 - interní číslo záznamu k načtení |
||
579 | * * code:LOPATA - kód záznamu |
||
580 | * * BAGR - kód záznamu k načtení |
||
581 | * * ['id'=>24,'nazev'=>'hoblík'] - pole hodnot k předvyplnění |
||
582 | * * 743.json?relations=adresa,vazby - část url s parametry k načtení |
||
583 | * |
||
584 | * @param mixed $init číslo/"(code:)kód"/(část)URI záznamu k načtení | pole hodnot k předvyplnění |
||
585 | */ |
||
586 | public function processInit($init) |
||
599 | |||
600 | /** |
||
601 | * Set Data Field value |
||
602 | * |
||
603 | * @param string $columnName field name |
||
604 | * @param mixed $value field data value |
||
605 | * |
||
606 | * @return bool Success |
||
607 | */ |
||
608 | public function setDataValue($columnName, $value) |
||
635 | |||
636 | /** |
||
637 | * PHP Date object to FlexiBee date format |
||
638 | * |
||
639 | * @param \DateTime $date |
||
640 | */ |
||
641 | public static function dateToFlexiDate($date) |
||
645 | |||
646 | /** |
||
647 | * PHP Date object to FlexiBee date format |
||
648 | * |
||
649 | * @param \DateTime $dateTime |
||
650 | */ |
||
651 | public static function dateToFlexiDateTime($dateTime) |
||
655 | |||
656 | /** |
||
657 | * Set URL prefix |
||
658 | * |
||
659 | * @param string $prefix |
||
660 | */ |
||
661 | public function setPrefix($prefix) |
||
682 | |||
683 | /** |
||
684 | * Set communication format. |
||
685 | * One of html|xml|json|csv|dbf|xls|isdoc|isdocx|edi|pdf|pdf|vcf|ical |
||
686 | * |
||
687 | * @param string $format |
||
688 | * |
||
689 | * @return boolean format is availble |
||
690 | */ |
||
691 | public function setFormat($format) |
||
706 | |||
707 | /** |
||
708 | * Nastaví Evidenci pro Komunikaci. |
||
709 | * Set evidence for communication |
||
710 | * |
||
711 | * @param string $evidence evidence pathName to use |
||
712 | * |
||
713 | * @return boolean evidence switching status |
||
714 | */ |
||
715 | public function setEvidence($evidence) |
||
741 | |||
742 | /** |
||
743 | * Vrací právě používanou evidenci pro komunikaci |
||
744 | * Obtain current used evidence |
||
745 | * |
||
746 | * @return string |
||
747 | */ |
||
748 | public function getEvidence() |
||
752 | |||
753 | /** |
||
754 | * Set used company. |
||
755 | * Nastaví Firmu. |
||
756 | * |
||
757 | * @param string $company |
||
758 | */ |
||
759 | public function setCompany($company) |
||
763 | |||
764 | /** |
||
765 | * Obtain company now used |
||
766 | * Vrací právě používanou firmu |
||
767 | * |
||
768 | * @return string |
||
769 | */ |
||
770 | public function getCompany() |
||
774 | |||
775 | /** |
||
776 | * Vrací název evidence použité v odpovědích z FlexiBee |
||
777 | * |
||
778 | * @return string |
||
779 | */ |
||
780 | public function getResponseEvidence() |
||
795 | |||
796 | /** |
||
797 | * Převede rekurzivně Objekt na pole. |
||
798 | * |
||
799 | * @param object|array $object |
||
800 | * |
||
801 | * @return array |
||
802 | */ |
||
803 | public static function object2array($object) |
||
823 | |||
824 | /** |
||
825 | * Převede rekurzivně v poli všechny objekty na jejich identifikátory. |
||
826 | * |
||
827 | * @param object|array $object |
||
828 | * |
||
829 | * @return array |
||
830 | */ |
||
831 | public static function objectToID($object) |
||
849 | |||
850 | /** |
||
851 | * Return basic URL for used Evidence |
||
852 | * |
||
853 | * @link https://www.flexibee.eu/api/dokumentace/ref/urls/ Sestavování URL |
||
854 | * |
||
855 | * @return string Evidence URL |
||
856 | */ |
||
857 | public function getEvidenceURL() |
||
866 | |||
867 | /** |
||
868 | * Add suffix to Evidence URL |
||
869 | * |
||
870 | * @param string $urlSuffix |
||
871 | * |
||
872 | * @return string |
||
873 | */ |
||
874 | public function evidenceUrlWithSuffix($urlSuffix) |
||
886 | |||
887 | /** |
||
888 | * Update $this->apiURL |
||
889 | */ |
||
890 | public function updateApiURL() |
||
905 | /* |
||
906 | * Add Default Url params to given url if not overrided |
||
907 | * |
||
908 | * @param string $urlRaw |
||
909 | * |
||
910 | * @return string url with default params added |
||
911 | */ |
||
912 | |||
913 | public function addDefaultUrlParams($urlRaw) |
||
918 | |||
919 | /** |
||
920 | * Funkce, která provede I/O operaci a vyhodnotí výsledek. |
||
921 | * |
||
922 | * @param string $urlSuffix část URL za identifikátorem firmy. |
||
923 | * @param string $method HTTP/REST metoda |
||
924 | * @param string $format Requested format |
||
925 | * |
||
926 | * @return array|boolean Výsledek operace |
||
927 | */ |
||
928 | public function performRequest($urlSuffix = null, $method = 'GET', |
||
949 | |||
950 | /** |
||
951 | * Parse Raw FlexiBee response in several formats |
||
952 | * |
||
953 | * @param string $responseRaw raw response body |
||
954 | * @param string $format Raw Response format json|xml|etc |
||
955 | * |
||
956 | * @return array |
||
957 | */ |
||
958 | public function rawResponseToArray($responseRaw, $format) |
||
977 | |||
978 | /** |
||
979 | * Convert FlexiBee Response JSON to Array |
||
980 | * |
||
981 | * @param string $rawJson |
||
982 | * |
||
983 | * @return array |
||
984 | */ |
||
985 | public function rawJsonToArray($rawJson) |
||
1001 | |||
1002 | /** |
||
1003 | * Convert FlexiBee Response XML to Array |
||
1004 | * |
||
1005 | * @param string $rawXML |
||
1006 | * |
||
1007 | * @return array |
||
1008 | */ |
||
1009 | public function rawXmlToArray($rawXML) |
||
1013 | |||
1014 | /** |
||
1015 | * Parse Response array |
||
1016 | * |
||
1017 | * @param array $responseDecoded |
||
1018 | * @param int $responseCode Request Response Code |
||
1019 | * |
||
1020 | * @return array main data part of response |
||
1021 | */ |
||
1022 | public function parseResponse($responseDecoded, $responseCode) |
||
1087 | |||
1088 | /** |
||
1089 | * Parse error message response |
||
1090 | * |
||
1091 | * @param array $responseDecoded |
||
1092 | * |
||
1093 | * @return int number of errors processed |
||
1094 | */ |
||
1095 | public function parseError(array $responseDecoded) |
||
1113 | |||
1114 | /** |
||
1115 | * Vykonej HTTP požadavek |
||
1116 | * |
||
1117 | * @link https://www.flexibee.eu/api/dokumentace/ref/urls/ Sestavování URL |
||
1118 | * @param string $url URL požadavku |
||
1119 | * @param string $method HTTP Method GET|POST|PUT|OPTIONS|DELETE |
||
1120 | * @param string $format požadovaný formát komunikace |
||
1121 | * |
||
1122 | * @return int HTTP Response CODE |
||
1123 | */ |
||
1124 | public function doCurlRequest($url, $method, $format = null) |
||
1175 | |||
1176 | /** |
||
1177 | * Obtain json for application/json |
||
1178 | * |
||
1179 | * @param string $contentType |
||
1180 | * @param string $url |
||
1181 | * |
||
1182 | * @return string response format |
||
1183 | */ |
||
1184 | public function contentTypeToResponseFormat($contentType, $url = null) |
||
1212 | |||
1213 | /** |
||
1214 | * Nastaví druh prováděné akce. |
||
1215 | * |
||
1216 | * @link https://demo.flexibee.eu/devdoc/actions Provádění akcí |
||
1217 | * @param string $action |
||
1218 | * |
||
1219 | * @return boolean |
||
1220 | */ |
||
1221 | public function setAction($action) |
||
1232 | |||
1233 | /** |
||
1234 | * Convert XML to array. |
||
1235 | * |
||
1236 | * @param string $xml |
||
1237 | * |
||
1238 | * @return array |
||
1239 | */ |
||
1240 | public static function xml2array($xml) |
||
1260 | |||
1261 | /** |
||
1262 | * Odpojení od FlexiBee. |
||
1263 | */ |
||
1264 | public function disconnect() |
||
1271 | |||
1272 | /** |
||
1273 | * Disconnect CURL befere pass away |
||
1274 | */ |
||
1275 | public function __destruct() |
||
1279 | |||
1280 | /** |
||
1281 | * Načte řádek dat z FlexiBee. |
||
1282 | * |
||
1283 | * @param int $recordID id požadovaného záznamu |
||
1284 | * |
||
1285 | * @return array |
||
1286 | */ |
||
1287 | public function getFlexiRow($recordID) |
||
1297 | |||
1298 | /** |
||
1299 | * Oddělí z pole podmínek ty jenž patří za ? v URL požadavku |
||
1300 | * |
||
1301 | * @link https://www.flexibee.eu/api/dokumentace/ref/urls/ Sestavování URL |
||
1302 | * @param array $conditions pole podmínek - rendrují se do () |
||
1303 | * @param array $urlParams pole parametrů - rendrují za ? |
||
1304 | */ |
||
1305 | public function extractUrlParams(&$conditions, &$urlParams) |
||
1313 | |||
1314 | /** |
||
1315 | * convert unicode to entities for use with FlexiBee queries |
||
1316 | * |
||
1317 | * @param string $urlRaw |
||
1318 | * |
||
1319 | * @return string |
||
1320 | */ |
||
1321 | public static function urlEncode($urlRaw) |
||
1325 | |||
1326 | /** |
||
1327 | * Načte data z FlexiBee. |
||
1328 | * |
||
1329 | * @param string $suffix dotaz |
||
1330 | * @param string|array $conditions Custom filters or modifiers |
||
1331 | * |
||
1332 | * @return array Data obtained |
||
1333 | */ |
||
1334 | public function getFlexiData($suffix = null, $conditions = null) |
||
1401 | |||
1402 | /** |
||
1403 | * Načte záznam z FlexiBee a uloží v sobě jeho data |
||
1404 | * Read FlexiBee record and store it inside od object |
||
1405 | * |
||
1406 | * @param int|string $id ID or conditions |
||
1407 | * |
||
1408 | * @return int počet načtených položek |
||
1409 | */ |
||
1410 | public function loadFromFlexiBee($id = null) |
||
1425 | |||
1426 | /** |
||
1427 | * Reload current record from FlexiBee |
||
1428 | * |
||
1429 | * @return boolean |
||
1430 | */ |
||
1431 | public function reload() |
||
1438 | |||
1439 | /** |
||
1440 | * Set Filter code for requests |
||
1441 | * |
||
1442 | * @link https://www.flexibee.eu/api/dokumentace/ref/zamykani-odemykani/ |
||
1443 | * |
||
1444 | * @param array|string $filter filter formula or ['key'=>'value'] |
||
1445 | * |
||
1446 | * @return string Filter code |
||
1447 | */ |
||
1448 | public function setFilter($filter) |
||
1452 | |||
1453 | /** |
||
1454 | * Převede data do Json formátu pro FlexiBee. |
||
1455 | * Convert data to FlexiBee like Json format |
||
1456 | * |
||
1457 | * @url https://www.flexibee.eu/api/dokumentace/ref/actions/ |
||
1458 | * @url https://www.flexibee.eu/api/dokumentace/ref/zamykani-odemykani/ |
||
1459 | * |
||
1460 | * @param array $data object data |
||
1461 | * @param int $options json_encode options like JSON_PRETTY_PRINT etc |
||
1462 | * |
||
1463 | * @return string |
||
1464 | */ |
||
1465 | public function getJsonizedData($data = null, $options = 0) |
||
1478 | |||
1479 | /** |
||
1480 | * Get Data Fragment specific for current object |
||
1481 | * |
||
1482 | * @param array $data |
||
1483 | * |
||
1484 | * @return array |
||
1485 | */ |
||
1486 | public function getDataForJSON($data = null) |
||
1529 | |||
1530 | /** |
||
1531 | * Join another FlexiPeeHP Object |
||
1532 | * |
||
1533 | * @param FlexiBeeRO $object |
||
1534 | * |
||
1535 | * @return boolean adding to stack success |
||
1536 | */ |
||
1537 | public function join(&$object) |
||
1548 | |||
1549 | /** |
||
1550 | * Prepare record ID to use in URL |
||
1551 | * |
||
1552 | * @param mixed $id |
||
1553 | * |
||
1554 | * @return string id ready for use in URL |
||
1555 | */ |
||
1556 | public static function urlizeId($id) |
||
1567 | |||
1568 | /** |
||
1569 | * Test if given record ID exists in FlexiBee. |
||
1570 | * |
||
1571 | * @param mixed $identifer presence state |
||
1572 | * |
||
1573 | * @return boolean |
||
1574 | */ |
||
1575 | public function idExists($identifer = null) |
||
1590 | |||
1591 | /** |
||
1592 | * Test if given record exists in FlexiBee. |
||
1593 | * |
||
1594 | * @param array|string|int $data ext:id:23|code:ITEM|['id'=>23]|23 |
||
1595 | * |
||
1596 | * @return boolean Record presence status |
||
1597 | */ |
||
1598 | public function recordExists($data = []) |
||
1619 | |||
1620 | /** |
||
1621 | * Subitems - ex. items of invoice |
||
1622 | * |
||
1623 | * @return array of document items or null |
||
1624 | */ |
||
1625 | public function getSubItems() |
||
1631 | |||
1632 | /** |
||
1633 | * Vrací z FlexiBee sloupečky podle podmínek. |
||
1634 | * |
||
1635 | * @param array|int|string $conditions pole podmínek nebo ID záznamu |
||
1636 | * @param string $indexBy klice vysledku naplnit hodnotou ze |
||
1637 | * sloupečku |
||
1638 | * @return array |
||
1639 | */ |
||
1640 | public function getAllFromFlexibee($conditions = null, $indexBy = null) |
||
1654 | |||
1655 | /** |
||
1656 | * Vrací z FlexiBee sloupečky podle podmínek. |
||
1657 | * |
||
1658 | * @param string|string[] $columnsList seznam položek nebo úrověň detailu: id|summary|full |
||
1659 | * @param array $conditions pole podmínek nebo ID záznamu |
||
1660 | * @param string $indexBy Sloupeček podle kterého indexovat záznamy |
||
1661 | * |
||
1662 | * @return array |
||
1663 | */ |
||
1664 | public function getColumnsFromFlexibee($columnsList, $conditions = [], |
||
1703 | |||
1704 | /** |
||
1705 | * Vrací kód záznamu. |
||
1706 | * Obtain record CODE |
||
1707 | * |
||
1708 | * @param mixed $data |
||
1709 | * |
||
1710 | * @return string |
||
1711 | */ |
||
1712 | public function getKod($data = null, $unique = true) |
||
1766 | |||
1767 | /** |
||
1768 | * Write Operation Result. |
||
1769 | * |
||
1770 | * @param array $resultData |
||
1771 | * @param string $url URL |
||
1772 | * |
||
1773 | * @return boolean Log save success |
||
1774 | */ |
||
1775 | public function logResult($resultData = null, $url = null) |
||
1821 | |||
1822 | /** |
||
1823 | * Save RAW Curl Request & Response to files in Temp directory |
||
1824 | */ |
||
1825 | public function saveDebugFiles() |
||
1839 | |||
1840 | /** |
||
1841 | * Připraví data pro odeslání do FlexiBee |
||
1842 | * |
||
1843 | * @param string $data |
||
1844 | */ |
||
1845 | public function setPostFields($data) |
||
1849 | |||
1850 | /** |
||
1851 | * Get Content ready to be send as POST body |
||
1852 | * @return string |
||
1853 | */ |
||
1854 | public function getPostFields() |
||
1858 | |||
1859 | /** |
||
1860 | * Generuje fragment url pro filtrování. |
||
1861 | * |
||
1862 | * @see https://www.flexibee.eu/api/dokumentace/ref/filters |
||
1863 | * |
||
1864 | * @param array $data key=>values; value can bee class DatePeriod, DateTime or Array |
||
1865 | * @param string $joiner default and/or |
||
1866 | * @param string $defop default operator |
||
1867 | * |
||
1868 | * @return string |
||
1869 | */ |
||
1870 | public static function flexiUrl(array $data, $joiner = 'and', $defop = 'eq') |
||
1955 | |||
1956 | /** |
||
1957 | * Obtain record/object numeric identificator id: |
||
1958 | * Vrací číselný identifikátor objektu id: |
||
1959 | * |
||
1960 | * @link https://demo.flexibee.eu/devdoc/identifiers Identifikátory záznamů |
||
1961 | * |
||
1962 | * @return null|int indentifikátor záznamu reprezentovaného objektem |
||
1963 | */ |
||
1964 | public function getRecordID() |
||
1969 | |||
1970 | /** |
||
1971 | * Obtain record/object identificator code: |
||
1972 | * Vrací identifikátor objektu code: |
||
1973 | * |
||
1974 | * @link https://demo.flexibee.eu/devdoc/identifiers Identifikátory záznamů |
||
1975 | * |
||
1976 | * @return string record code identifier |
||
1977 | */ |
||
1978 | public function getRecordCode() |
||
1982 | |||
1983 | /** |
||
1984 | * Obtain record/object identificator extId: code: or id: |
||
1985 | * Vrací identifikátor objektu extId: code: nebo id: |
||
1986 | * |
||
1987 | * @link https://demo.flexibee.eu/devdoc/identifiers Identifikátory záznamů |
||
1988 | * |
||
1989 | * @return string|int|null record code identifier |
||
1990 | */ |
||
1991 | public function getRecordIdent() |
||
2002 | |||
2003 | /** |
||
2004 | * Obtain record/object identificator code: or id: |
||
2005 | * Vrací identifikátor objektu code: nebo id: |
||
2006 | * |
||
2007 | * @link https://demo.flexibee.eu/devdoc/identifiers Identifikátory záznamů |
||
2008 | * |
||
2009 | * @return string indentifikátor záznamu reprezentovaného objektem |
||
2010 | */ |
||
2011 | public function __toString() |
||
2015 | |||
2016 | /** |
||
2017 | * Gives you FlexiPeeHP class name for Given Evidence |
||
2018 | * |
||
2019 | * @param string $evidence |
||
2020 | * |
||
2021 | * @return string Class name |
||
2022 | */ |
||
2023 | public static function evidenceToClassName($evidence) |
||
2027 | |||
2028 | /** |
||
2029 | * Obtain ID of first record in evidence |
||
2030 | * |
||
2031 | * @return string|null id or null if no records |
||
2032 | */ |
||
2033 | public function getFirstRecordID() |
||
2044 | |||
2045 | /** |
||
2046 | * Get previous record ID |
||
2047 | * |
||
2048 | * @param array $conditions optional |
||
2049 | * |
||
2050 | * @return int|null |
||
2051 | */ |
||
2052 | public function getNextRecordID($conditions = []) |
||
2061 | |||
2062 | /** |
||
2063 | * Get next record ID |
||
2064 | * |
||
2065 | * @param array $conditions optional |
||
2066 | * |
||
2067 | * @return int|null |
||
2068 | */ |
||
2069 | public function getPrevRecordID($conditions = []) |
||
2078 | |||
2079 | /** |
||
2080 | * Vrací hodnotu daného externího ID |
||
2081 | * |
||
2082 | * @param string $want Namespace Selector. If empty,you obtain the first one. |
||
2083 | * |
||
2084 | * @return string|array one id or array if multiplete |
||
2085 | */ |
||
2086 | public function getExternalID($want = null) |
||
2114 | |||
2115 | /** |
||
2116 | * gives you currently loaded extermal IDs |
||
2117 | * |
||
2118 | * @return array |
||
2119 | */ |
||
2120 | public function getExternalIDs() |
||
2124 | |||
2125 | /** |
||
2126 | * Obtain actual GlobalVersion |
||
2127 | * Vrací aktuální globální verzi změn |
||
2128 | * |
||
2129 | * @link https://www.flexibee.eu/api/dokumentace/ref/changes-api#globalVersion Globální Verze |
||
2130 | * |
||
2131 | * @return int |
||
2132 | */ |
||
2133 | public function getGlobalVersion() |
||
2139 | |||
2140 | /** |
||
2141 | * Gives you current ApiURL with given format suffix |
||
2142 | * |
||
2143 | * @param string $format json|html|xml|... |
||
2144 | * |
||
2145 | * @return string API URL for current record or object/evidence |
||
2146 | */ |
||
2147 | public function getApiURL($format = null) |
||
2152 | |||
2153 | /** |
||
2154 | * Obtain content type of last response |
||
2155 | * |
||
2156 | * @return string |
||
2157 | */ |
||
2158 | public function getResponseFormat() |
||
2162 | |||
2163 | /** |
||
2164 | * Return the same response format for one and multiplete results |
||
2165 | * |
||
2166 | * @param array $responseBody |
||
2167 | * |
||
2168 | * @return array |
||
2169 | */ |
||
2170 | public function unifyResponseFormat($responseBody) |
||
2199 | |||
2200 | /** |
||
2201 | * Obtain structure for current (or given) evidence |
||
2202 | * |
||
2203 | * @param string $evidence |
||
2204 | * |
||
2205 | * @return array Evidence structure |
||
2206 | */ |
||
2207 | public function getOfflineColumnsInfo($evidence = null) |
||
2217 | |||
2218 | /** |
||
2219 | * Obtain Current evidence Live structure |
||
2220 | * |
||
2221 | * @param string $evidence |
||
2222 | * |
||
2223 | * @return array structure |
||
2224 | */ |
||
2225 | public function getOnlineColumnsInfo($evidence = null) |
||
2246 | |||
2247 | /** |
||
2248 | * Update evidence info from array or online from properties.json or offline |
||
2249 | * |
||
2250 | * @param array $columnsInfo |
||
2251 | * @param string $evidence |
||
2252 | */ |
||
2253 | public function updateColumnsInfo($columnsInfo = null, $evidence = null) |
||
2263 | |||
2264 | /** |
||
2265 | * Gives you evidence structure. You can obtain current online by pre-calling: |
||
2266 | * $this->updateColumnsInfo($evidence, $this->getOnlineColumnsInfo($evidence)); |
||
2267 | * |
||
2268 | * @param string $evidence |
||
2269 | * |
||
2270 | * @return array |
||
2271 | */ |
||
2272 | public function getColumnsInfo($evidence = null) |
||
2281 | |||
2282 | /** |
||
2283 | * Gives you properties for (current) evidence column |
||
2284 | * |
||
2285 | * @param string $column name of column |
||
2286 | * @param string $evidence evidence name if different |
||
2287 | * |
||
2288 | * @return array column properties or null if column not exits |
||
2289 | */ |
||
2290 | public function getColumnInfo($column, $evidence = null) |
||
2298 | |||
2299 | /** |
||
2300 | * Obtain actions for current (or given) evidence |
||
2301 | * |
||
2302 | * @param string $evidence |
||
2303 | * |
||
2304 | * @return array Evidence structure |
||
2305 | */ |
||
2306 | public function getActionsInfo($evidence = null) |
||
2318 | |||
2319 | /** |
||
2320 | * Obtain relations for current (or given) evidence |
||
2321 | * |
||
2322 | * @param string $evidence |
||
2323 | * |
||
2324 | * @return array Evidence structure |
||
2325 | */ |
||
2326 | public function getRelationsInfo($evidence = null) |
||
2338 | |||
2339 | /** |
||
2340 | * Obtain info for current (or given) evidence |
||
2341 | * |
||
2342 | * @param string $evidence |
||
2343 | * |
||
2344 | * @return array Evidence info |
||
2345 | */ |
||
2346 | public function getEvidenceInfo($evidence = null) |
||
2361 | |||
2362 | /** |
||
2363 | * Obtain name for current (or given) evidence path |
||
2364 | * |
||
2365 | * @param string $evidence Evidence Path |
||
2366 | * |
||
2367 | * @return array Evidence info |
||
2368 | */ |
||
2369 | public function getEvidenceName($evidence = null) |
||
2380 | |||
2381 | /** |
||
2382 | * Save current object to file |
||
2383 | * |
||
2384 | * @param string $destfile path to file |
||
2385 | */ |
||
2386 | public function saveResponseToFile($destfile) |
||
2393 | |||
2394 | /** |
||
2395 | * Obtain established relations listing |
||
2396 | * |
||
2397 | * @return array Null or Relations |
||
2398 | */ |
||
2399 | public function getVazby($id = null) |
||
2414 | |||
2415 | /** |
||
2416 | * Gives You URL for Current Record in FlexiBee web interface |
||
2417 | * |
||
2418 | * @return string url |
||
2419 | */ |
||
2420 | public function getFlexiBeeURL() |
||
2433 | |||
2434 | /** |
||
2435 | * Set Record Key |
||
2436 | * |
||
2437 | * @param int|string $myKeyValue |
||
2438 | * |
||
2439 | * @return boolean |
||
2440 | */ |
||
2441 | public function setMyKey($myKeyValue) |
||
2464 | |||
2465 | /** |
||
2466 | * Set or get ignore not found pages flag |
||
2467 | * |
||
2468 | * @param boolean $ignore set flag to |
||
2469 | * |
||
2470 | * @return boolean get flag state |
||
2471 | */ |
||
2472 | public function ignore404($ignore = null) |
||
2479 | |||
2480 | /** |
||
2481 | * Send Document by mail |
||
2482 | * |
||
2483 | * @url https://www.flexibee.eu/api/dokumentace/ref/odesilani-mailem/ |
||
2484 | * |
||
2485 | * @param string $to Email ecipient |
||
2486 | * @param string $subject Email Subject |
||
2487 | * @param string $body Email Text |
||
2488 | * |
||
2489 | * @return boolean mail sent status |
||
2490 | */ |
||
2491 | public function sendByMail($to, $subject, $body, $cc = null) |
||
2500 | |||
2501 | /** |
||
2502 | * Send all unsent Documents by eMail |
||
2503 | * |
||
2504 | * @url https://www.flexibee.eu/api/dokumentace/ref/odesilani-mailem/ |
||
2505 | * |
||
2506 | * @return int http response code |
||
2507 | */ |
||
2508 | public function sendUnsent() |
||
2513 | |||
2514 | /** |
||
2515 | * FlexiBee date to PHP DateTime conversion |
||
2516 | * |
||
2517 | * @param string $flexidate 2017-05-26 or 2017-05-26+02:00 |
||
2518 | * |
||
2519 | * @return \DateTime | false |
||
2520 | */ |
||
2521 | public static function flexiDateToDateTime($flexidate) |
||
2526 | |||
2527 | /** |
||
2528 | * FlexiBee dateTime to PHP DateTime conversion |
||
2529 | * |
||
2530 | * @param string $flexidatetime 2017-09-26T10:00:53.755+02:00 or older 2017-05-19T00:00:00+02:00 |
||
2531 | * |
||
2532 | * @return \DateTime | false |
||
2533 | */ |
||
2534 | public static function flexiDateTimeToDateTime($flexidatetime) |
||
2543 | |||
2544 | /** |
||
2545 | * Získá dokument v daném formátu |
||
2546 | * Obtain document in given format |
||
2547 | * |
||
2548 | * @link https://www.flexibee.eu/api/dokumentace/ref/pdf/ PDF Exports |
||
2549 | * |
||
2550 | * @param string $format pdf/csv/xml/json/ ... |
||
2551 | * @param string $reportName Template used to generate PDF |
||
2552 | * @param string $lang cs|sk|en|de Template language used to generate PDF |
||
2553 | * @param boolean $sign sign resulting PDF by certificate ? |
||
2554 | * |
||
2555 | * @return string|null filename downloaded or none |
||
2556 | */ |
||
2557 | public function getInFormat($format, $reportName = null, $lang = null, |
||
2597 | |||
2598 | /** |
||
2599 | * Uloží dokument v daném formátu do složky v systému souborů |
||
2600 | * Save document in given format to directory in filesystem |
||
2601 | * |
||
2602 | * @param string $format pdf/csv/xml/json/ ... |
||
2603 | * @param string $destDir where to put file (prefix) |
||
2604 | * @param string $reportName Template used to generate PDF |
||
2605 | * |
||
2606 | * @return string|null filename downloaded or none |
||
2607 | */ |
||
2608 | public function downloadInFormat($format, $destDir = './', |
||
2624 | |||
2625 | /** |
||
2626 | * Take data for object. separate external IDs |
||
2627 | * |
||
2628 | * @param array $data Data to keep |
||
2629 | * |
||
2630 | * @return int number of records taken |
||
2631 | */ |
||
2632 | public function takeData($data) |
||
2654 | |||
2655 | /** |
||
2656 | * Get Current Evidence reports listing |
||
2657 | * |
||
2658 | * @link https://www.flexibee.eu/api/dokumentace/casto-kladene-dotazy-pro-api/vyber-reportu-do-pdf/ Výběr reportu do PDF |
||
2659 | * |
||
2660 | * @return array |
||
2661 | */ |
||
2662 | public function getReportsInfo() |
||
2678 | |||
2679 | /** |
||
2680 | * Request authSessionId from current server |
||
2681 | * |
||
2682 | * @link https://www.flexibee.eu/api/dokumentace/ref/login/ description |
||
2683 | * |
||
2684 | * @param string $username |
||
2685 | * @param string $password |
||
2686 | * @param string $otp optional onetime password |
||
2687 | * |
||
2688 | * @return string authUserId or null in case of problems |
||
2689 | */ |
||
2690 | public function requestAuthSessionID($username, $password, $otp = null) |
||
2705 | |||
2706 | /** |
||
2707 | * Try to Sign in current user to FlexiBee and keep authSessionId |
||
2708 | * |
||
2709 | * @return boolean sign in success |
||
2710 | */ |
||
2711 | public function login() |
||
2717 | |||
2718 | /** |
||
2719 | * End (current's user) session |
||
2720 | * |
||
2721 | * |
||
2722 | * @link https://www.flexibee.eu/api/dokumentace/ref/logout Logout Reference |
||
2723 | * |
||
2724 | * @param string $username force username to sign off |
||
2725 | * |
||
2726 | * @return array server response |
||
2727 | */ |
||
2728 | public function logout($username = null) |
||
2733 | |||
2734 | /** |
||
2735 | * Compile and send Report about Error500 to FlexiBee developers |
||
2736 | * If FlexiBee is running on localost try also include java backtrace |
||
2737 | * |
||
2738 | * @param array $errorResponse result of parseError(); |
||
2739 | */ |
||
2740 | public function error500Reporter($errorResponse) |
||
2806 | |||
2807 | /** |
||
2808 | * Returns code:CODE |
||
2809 | * |
||
2810 | * @param string $code |
||
2811 | * |
||
2812 | * @return string |
||
2813 | */ |
||
2814 | public static function code($code) |
||
2818 | |||
2819 | /** |
||
2820 | * Returns CODE without code: prefix |
||
2821 | * |
||
2822 | * @param string $code |
||
2823 | * |
||
2824 | * @return string |
||
2825 | */ |
||
2826 | public static function uncode($code) |
||
2830 | |||
2831 | /** |
||
2832 | * Remove all @ items from array |
||
2833 | * |
||
2834 | * @param array $data original data |
||
2835 | * |
||
2836 | * @return array data without @ columns |
||
2837 | */ |
||
2838 | public static function arrayCleanUP($data) |
||
2846 | |||
2847 | /** |
||
2848 | * Add Info about used user, server and libraries |
||
2849 | * |
||
2850 | * @param string $prefix banner prefix text |
||
2851 | * @param string $suffix banner suffix text |
||
2852 | */ |
||
2853 | public function logBanner($prefix = null, $suffix = null) |
||
2861 | |||
2862 | /** |
||
2863 | * Get Last operation type |
||
2864 | * |
||
2865 | * @return string create|read|update|delete or update,insert for some inserted and updated in one transaction |
||
2866 | */ |
||
2867 | public function getLastOperationType() |
||
2871 | |||
2872 | /** |
||
2873 | * Last operation errors |
||
2874 | * |
||
2875 | * @return array FlexiBee error meassages |
||
2876 | */ |
||
2877 | public function getErrors() { |
||
2880 | |||
2881 | /** |
||
2882 | * Reconnect After unserialization |
||
2883 | */ |
||
2884 | public function __wakeup() |
||
2888 | } |
||
2889 |
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.
Let’s take a look at an example:
As you can see in this example, the array
$myArray
is initialized the first time when the foreach loop is entered. You can also see that the value of thebar
key is only written conditionally; thus, its value might result from a previous iteration.This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.