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 |
||
17 | class FlexiBeeRO extends \Ease\Sand { |
||
18 | |||
19 | use \Ease\RecordKey; |
||
20 | |||
21 | /** |
||
22 | * Where to get JSON files with evidence stricture etc. |
||
23 | * @var string |
||
24 | */ |
||
25 | public static $infoDir = __DIR__ . '/../../static'; |
||
26 | |||
27 | /** |
||
28 | * Version of FlexiPeeHP library |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | public static $libVersion = '1.37'; |
||
33 | |||
34 | /** |
||
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 | * Data block in response field. |
||
49 | * |
||
50 | * @var string |
||
51 | */ |
||
52 | public $resultField = 'results'; |
||
53 | |||
54 | /** |
||
55 | * Communication protocol version used. |
||
56 | * |
||
57 | * @var string Verze použitého API |
||
58 | */ |
||
59 | public $protoVersion = '1.0'; |
||
60 | |||
61 | /** |
||
62 | * Evidence used by object |
||
63 | * |
||
64 | * @link https://demo.flexibee.eu/c/demo/evidence-list Přehled evidencí |
||
65 | * |
||
66 | * @var string |
||
67 | */ |
||
68 | public $evidence = null; |
||
69 | |||
70 | /** |
||
71 | * Detaily evidence užité objektem |
||
72 | * |
||
73 | * @var array |
||
74 | */ |
||
75 | public $evidenceInfo = []; |
||
76 | |||
77 | /** |
||
78 | * Default communication format. |
||
79 | * |
||
80 | * @link https://www.flexibee.eu/api/dokumentace/ref/format-types Přehled možných formátů |
||
81 | * |
||
82 | * @var string json|xml|... |
||
83 | */ |
||
84 | public $format = 'json'; |
||
85 | |||
86 | /** |
||
87 | * requested response format |
||
88 | * |
||
89 | * @link https://www.flexibee.eu/api/dokumentace/ref/format-types Přehled možných formátů |
||
90 | * |
||
91 | * @var string json|xml|... |
||
92 | */ |
||
93 | public $responseFormat = 'json'; |
||
94 | |||
95 | /** |
||
96 | * Curl Handle. |
||
97 | * |
||
98 | * @var resource |
||
99 | */ |
||
100 | public $curl = null; |
||
101 | |||
102 | /** |
||
103 | * @link https://demo.flexibee.eu/devdoc/company-identifier Identifikátor firmy |
||
104 | * @var string |
||
105 | */ |
||
106 | public $company = null; |
||
107 | |||
108 | /** |
||
109 | * [protocol://]Server[:port] |
||
110 | * @var string |
||
111 | */ |
||
112 | public $url = null; |
||
113 | |||
114 | /** |
||
115 | * REST API Username |
||
116 | * @var string |
||
117 | */ |
||
118 | public $user = null; |
||
119 | |||
120 | /** |
||
121 | * REST API Password |
||
122 | * @var string |
||
123 | */ |
||
124 | public $password = null; |
||
125 | |||
126 | /** |
||
127 | * @var array Pole HTTP hlaviček odesílaných s každým požadavkem |
||
128 | */ |
||
129 | public $defaultHttpHeaders = []; |
||
130 | |||
131 | /** |
||
132 | * Default additional request url parameters after question mark |
||
133 | * |
||
134 | * @link https://www.flexibee.eu/api/dokumentace/ref/urls Common params |
||
135 | * @link https://www.flexibee.eu/api/dokumentace/ref/paging Paging params |
||
136 | * @var array |
||
137 | */ |
||
138 | public $defaultUrlParams = []; |
||
139 | |||
140 | /** |
||
141 | * Identifikační řetězec. |
||
142 | * |
||
143 | * @var string |
||
144 | */ |
||
145 | public $init = null; |
||
146 | |||
147 | /** |
||
148 | * Sloupeček s názvem. |
||
149 | * |
||
150 | * @var string |
||
151 | */ |
||
152 | public $nameColumn = 'nazev'; |
||
153 | |||
154 | /** |
||
155 | * Sloupeček obsahující datum vložení záznamu do shopu. |
||
156 | * |
||
157 | * @var string |
||
158 | */ |
||
159 | public $myCreateColumn = 'false'; |
||
160 | |||
161 | /** |
||
162 | * Slopecek obsahujici datum poslení modifikace záznamu do shopu. |
||
163 | * |
||
164 | * @var string |
||
165 | */ |
||
166 | public $myLastModifiedColumn = 'lastUpdate'; |
||
167 | |||
168 | /** |
||
169 | * Klíčový idendifikátor záznamu. |
||
170 | * |
||
171 | * @var string |
||
172 | */ |
||
173 | public $fbKeyColumn = 'id'; |
||
174 | |||
175 | /** |
||
176 | * Informace o posledním HTTP requestu. |
||
177 | * |
||
178 | * @var * |
||
179 | */ |
||
180 | public $curlInfo; |
||
181 | |||
182 | /** |
||
183 | * Informace o poslední HTTP chybě. |
||
184 | * |
||
185 | * @var string |
||
186 | */ |
||
187 | public $lastCurlError = null; |
||
188 | |||
189 | /** |
||
190 | * Used codes storage. |
||
191 | * |
||
192 | * @var array |
||
193 | */ |
||
194 | public $codes = null; |
||
195 | |||
196 | /** |
||
197 | * Last Inserted ID. |
||
198 | * |
||
199 | * @var int |
||
200 | */ |
||
201 | public $lastInsertedID = null; |
||
202 | |||
203 | /** |
||
204 | * Default Line Prefix. |
||
205 | * |
||
206 | * @var string |
||
207 | */ |
||
208 | public $prefix = '/c/'; |
||
209 | |||
210 | /** |
||
211 | * Raw Content of last curl response |
||
212 | * |
||
213 | * @var string |
||
214 | */ |
||
215 | public $lastCurlResponse; |
||
216 | |||
217 | /** |
||
218 | * HTTP Response code of last request |
||
219 | * |
||
220 | * @var int |
||
221 | */ |
||
222 | public $lastResponseCode = null; |
||
223 | |||
224 | /** |
||
225 | * Body data for next curl POST operation |
||
226 | * |
||
227 | * @var string |
||
228 | */ |
||
229 | public $postFields = null; |
||
230 | |||
231 | /** |
||
232 | * Last operation result data or message(s) |
||
233 | * |
||
234 | * @var array |
||
235 | */ |
||
236 | public $lastResult = null; |
||
237 | |||
238 | /** |
||
239 | * Number from @rowCount in response |
||
240 | * @var int |
||
241 | */ |
||
242 | public $rowCount = null; |
||
243 | |||
244 | /** |
||
245 | * Number from @globalVersion |
||
246 | * @var int |
||
247 | */ |
||
248 | public $globalVersion = null; |
||
249 | |||
250 | /** |
||
251 | * @link https://www.flexibee.eu/api/dokumentace/ref/zamykani-odemykani/ |
||
252 | * @var string filter query |
||
253 | */ |
||
254 | public $filter; |
||
255 | |||
256 | /** |
||
257 | * @link https://demo.flexibee.eu/devdoc/actions Provádění akcí |
||
258 | * @var string |
||
259 | */ |
||
260 | protected $action; |
||
261 | |||
262 | /** |
||
263 | * Pole akcí které podporuje ta která evidence |
||
264 | * @link https://demo.flexibee.eu/c/demo/faktura-vydana/actions.json Např. Akce faktury |
||
265 | * @var array |
||
266 | */ |
||
267 | public $actionsAvailable = null; |
||
268 | |||
269 | /** |
||
270 | * Parmetry pro URL |
||
271 | * @link https://www.flexibee.eu/api/dokumentace/ref/urls/ Všechny podporované parametry |
||
272 | * @var array |
||
273 | */ |
||
274 | public $urlParams = [ |
||
275 | 'add-global-version' => ['type' => 'boolean', 'description' => 'The response will contain the global version number of the current export'], |
||
276 | 'add-row-count' => ['type' => 'boolean', 'description' => 'Adding Total Records to Output (Pagination)'], |
||
277 | 'as-gui' => ['type' => 'boolean', 'description' => 'Turns on functions that complement the GUI processing outputs'], |
||
278 | '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.'], |
||
279 | 'authSessionId' => ['type' => 'string', 'description' => 'Authentification Session ID'], |
||
280 | '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>'], |
||
281 | 'code-in-response' => ['type' => 'boolean', 'description' => 'The response will contain not only ID and URL for each object, but also code.'], |
||
282 | 'delimeter' => ['type' => 'string', 'description' => 'Specifies the input / output file separator in CSV format.', |
||
283 | 'example' => ';'], |
||
284 | 'detail' => ['type' => 'string', 'description' => 'Definition of the level of detail'], //See: https://www.flexibee.eu/api/dokumentace/ref/detail-levels |
||
285 | 'dir' => ['type' => 'string', 'description' => 'Sorting direction.', 'example' => 'desc'], |
||
286 | 'dry-run' => ['type' => 'boolean', 'description' => 'Test run (dry-run)'], // See: https://www.flexibee.eu/api/dokumentace/ref/dry-run/ |
||
287 | 'encoding' => ['type' => 'string', 'description' => 'Specifies the encoding of the input / output file in CSV format.'], |
||
288 | 'export-settings' => ['type' => 'boolean', 'description' => 'Export one extra entry with current settings at the beginning'], |
||
289 | 'fail-on-warning' => ['type' => 'boolean', 'description' => 'If a warning occurs, do not save a record (Data Validation)'], |
||
290 | 'filter' => ['type' => 'string', 'description' => 'filter results by this param'], |
||
291 | 'format' => ['type' => 'string', 'description' => 'One of the compiled XSL transforms will be applied to the output XML.'], |
||
292 | 'idUcetniObdobi' => ['type' => 'string', 'description' => ''], //See: https://www.flexibee.eu/api/dokumentace/ref/stavy-uctu/ |
||
293 | 'includes' => ['type' => 'string', 'description' => 'Include related detail level object ', |
||
294 | 'example' => 'faktura-vydana/stredisko'], |
||
295 | 'inDesktopApp' => ['type' => 'boolean', 'description' => 'Hide menu and navigation in html format'], // Note: Undocumented function (html only) |
||
296 | 'limit' => ['type' => 'integer', 'description' => 'number of requested results'], |
||
297 | 'mode' => ['type' => 'string', 'description' => 'Support for RubyOnRails', |
||
298 | 'example' => 'ruby'], |
||
299 | 'no-ext-ids' => ['type' => 'boolean', 'description' => 'The answer will not contain external identifiers (performance optimization)'], |
||
300 | 'no-http-errors' => ['type' => 'boolean', 'description' => 'If a 4xx error occurs while processing a request, the server sends 200 OK anyway'], |
||
301 | 'no-ids' => ['type' => 'boolean', 'description' => 'The response will not contain any primary identifiers (performance optimization). It only affects the main records.'], |
||
302 | '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.'], |
||
303 | 'order' => ['type' => 'string', 'description' => 'Sorting records', 'example' => 'nazev@A'], |
||
304 | 'relations' => ['type' => 'string', 'description' => 'Adding session data (see detail levels) A session overview can be obtained for each record (/ relations).'], |
||
305 | 'report-lang' => ['type' => 'string', 'description' => 'The language in which to print the output when exporting to PDF', |
||
306 | 'example' => 'en'], |
||
307 | 'report-name' => ['type' => 'string', 'description' => 'The name of the printout when exporting to PDF', |
||
308 | 'example' => 'invoice'], |
||
309 | 'report-sign' => ['type' => 'string', 'description' => 'Whether the PDF should be exported electronically signed'], |
||
310 | 'skupina-stitku' => ['type' => 'string', 'description' => 'Enables grouping of labels when exporting by group (multiple labels)'], |
||
311 | 'sort' => ['type' => 'string', 'description' => 'Sorting records for ExtJS'], |
||
312 | 'start' => ['type' => 'integer', 'description' => 'Pagination'], |
||
313 | 'stitky-as-ids' => ['type' => 'boolean', 'description' => 'Labels will be exported and imported not as a code list but as a list of numeric IDs'], |
||
314 | 'use-ext-id' => ['type' => 'boolean', 'description' => 'If the object contains an external ESHOP or MY ID, use it as a bind.'], |
||
315 | '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'], |
||
316 | 'xpath' => ['type' => 'string', 'description' => 'Apply XPATH to result', |
||
317 | 'example' => '//winstrom/adresar/email/text()'] // See: https://www.flexibee.eu/api/dokumentace/ref/xpath/ |
||
318 | ]; |
||
319 | |||
320 | /** |
||
321 | * Session ID |
||
322 | * @var string |
||
323 | */ |
||
324 | public $authSessionId = null; |
||
325 | |||
326 | /** |
||
327 | * Token obtained during login procedure |
||
328 | * @var string |
||
329 | */ |
||
330 | public $refreshToken = null; |
||
331 | |||
332 | /** |
||
333 | * Save 404 results to log ? |
||
334 | * @var boolean |
||
335 | */ |
||
336 | protected $ignoreNotFound = false; |
||
337 | |||
338 | /** |
||
339 | * Array of errors caused by last request |
||
340 | * @var array |
||
341 | */ |
||
342 | protected $errors = []; |
||
343 | |||
344 | /** |
||
345 | * List of Error500 reports sent |
||
346 | * @var array |
||
347 | */ |
||
348 | private $reports = []; |
||
349 | |||
350 | /** |
||
351 | * Send Error500 Report to |
||
352 | * @var string email address |
||
353 | */ |
||
354 | public $reportRecipient = '[email protected]'; |
||
355 | |||
356 | /** |
||
357 | * Formating string for \DateTime::format() for datetime columns |
||
358 | * @var string |
||
359 | */ |
||
360 | static public $DateTimeFormat = 'Y-m-d\TH:i:s.u+P'; |
||
361 | |||
362 | /** |
||
363 | * Formating string for \DateTime::format() for date columns |
||
364 | * @var string |
||
365 | */ |
||
366 | static public $DateFormat = 'Y-m-d'; |
||
367 | |||
368 | /** |
||
369 | * Last Request response stats |
||
370 | * @var array |
||
371 | */ |
||
372 | protected $responseStats = null; |
||
373 | |||
374 | /** |
||
375 | * Chained Objects |
||
376 | * @var array |
||
377 | */ |
||
378 | public $chained = []; |
||
379 | |||
380 | /** |
||
381 | * We Connect to server by default |
||
382 | * @var boolean |
||
383 | */ |
||
384 | public $offline = false; |
||
385 | |||
386 | /** |
||
387 | * Override cURL timeout |
||
388 | * @var int seconds |
||
389 | */ |
||
390 | public $timeout = null; |
||
391 | |||
392 | /** |
||
393 | * Columns Info for serveral evidencies |
||
394 | * @var array |
||
395 | */ |
||
396 | private $columnsInfo = []; |
||
397 | |||
398 | /** |
||
399 | * Throw Exception in case of FlexiBee error |
||
400 | * @var boolean |
||
401 | */ |
||
402 | public $throwException = false; |
||
403 | |||
404 | /** |
||
405 | * Class for read only interaction with FlexiBee. |
||
406 | * |
||
407 | * @param mixed $init default record id or initial data. See processInit() |
||
408 | * @param array $options Connection settings and other options override |
||
409 | */ |
||
410 | public function __construct($init = null, $options = []) { |
||
419 | |||
420 | /** |
||
421 | * Set internal Object name |
||
422 | * |
||
423 | * @param string $objectName |
||
424 | * |
||
425 | * @return string Jméno objektu |
||
426 | */ |
||
427 | public function setObjectName($objectName = null) { |
||
430 | |||
431 | /** |
||
432 | * SetUp Object to be ready for work |
||
433 | * |
||
434 | * @param array $options Object Options ( user,password,authSessionId |
||
435 | * company,url,evidence, |
||
436 | * prefix,defaultUrlParams,debug, |
||
437 | * detail,offline,filter,ignore404 |
||
438 | * timeout,companyUrl,ver,throwException |
||
439 | */ |
||
440 | public function setUp($options = []) { |
||
482 | |||
483 | /** |
||
484 | * Convert companyUrl provided by CustomButton to options array |
||
485 | * |
||
486 | * @param string $companyUrl |
||
487 | * |
||
488 | * @return array Options |
||
489 | */ |
||
490 | public static function companyUrlToOptions($companyUrl) { |
||
501 | |||
502 | /** |
||
503 | * Get Current connection options for use in another object |
||
504 | * |
||
505 | * @return array usable as second constructor parameter |
||
506 | */ |
||
507 | public function getConnectionOptions() { |
||
524 | |||
525 | /** |
||
526 | * Export current/given configutation into Environment |
||
527 | * @param array $opts |
||
528 | */ |
||
529 | public function configToEnv($opts = null) { |
||
547 | |||
548 | /** |
||
549 | * Inicializace CURL |
||
550 | * |
||
551 | * @return boolean Online Status |
||
552 | */ |
||
553 | public function curlInit() { |
||
574 | |||
575 | /** |
||
576 | * Initialise object with given data. Availble value types: |
||
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) { |
||
597 | |||
598 | /** |
||
599 | * Set Data Field value |
||
600 | * |
||
601 | * @param string $columnName field name |
||
602 | * @param mixed $value field data value |
||
603 | * |
||
604 | * @return bool Success |
||
605 | */ |
||
606 | public function setDataValue($columnName, $value) { |
||
632 | |||
633 | /** |
||
634 | * PHP Date object to FlexiBee date format |
||
635 | * |
||
636 | * @param \DateTime $date |
||
637 | */ |
||
638 | public static function dateToFlexiDate($date) { |
||
641 | |||
642 | /** |
||
643 | * PHP Date object to FlexiBee date format |
||
644 | * |
||
645 | * @param \DateTime $dateTime |
||
646 | */ |
||
647 | public static function dateToFlexiDateTime($dateTime) { |
||
650 | |||
651 | /** |
||
652 | * Set URL prefix |
||
653 | * |
||
654 | * @param string $prefix |
||
655 | */ |
||
656 | public function setPrefix($prefix) { |
||
676 | |||
677 | /** |
||
678 | * Set communication format. |
||
679 | * One of html|xml|json|csv|dbf|xls|isdoc|isdocx|edi|pdf|pdf|vcf|ical |
||
680 | * |
||
681 | * @param string $format |
||
682 | * |
||
683 | * @return boolean format is availble |
||
684 | */ |
||
685 | public function setFormat($format) { |
||
698 | |||
699 | /** |
||
700 | * Nastaví Evidenci pro Komunikaci. |
||
701 | * Set evidence for communication |
||
702 | * |
||
703 | * @param string $evidence evidence pathName to use |
||
704 | * |
||
705 | * @return boolean evidence switching status |
||
706 | */ |
||
707 | public function setEvidence($evidence) { |
||
732 | |||
733 | /** |
||
734 | * Vrací právě používanou evidenci pro komunikaci |
||
735 | * Obtain current used evidence |
||
736 | * |
||
737 | * @return string |
||
738 | */ |
||
739 | public function getEvidence() { |
||
742 | |||
743 | /** |
||
744 | * Set used company. |
||
745 | * Nastaví Firmu. |
||
746 | * |
||
747 | * @param string $company |
||
748 | */ |
||
749 | public function setCompany($company) { |
||
752 | |||
753 | /** |
||
754 | * Obtain company now used |
||
755 | * Vrací právě používanou firmu |
||
756 | * |
||
757 | * @return string |
||
758 | */ |
||
759 | public function getCompany() { |
||
762 | |||
763 | /** |
||
764 | * Vrací název evidence použité v odpovědích z FlexiBee |
||
765 | * |
||
766 | * @return string |
||
767 | */ |
||
768 | public function getResponseEvidence() { |
||
782 | |||
783 | /** |
||
784 | * Převede rekurzivně Objekt na pole. |
||
785 | * |
||
786 | * @param object|array $object |
||
787 | * |
||
788 | * @return array |
||
789 | */ |
||
790 | public static function object2array($object) { |
||
809 | |||
810 | /** |
||
811 | * Převede rekurzivně v poli všechny objekty na jejich identifikátory. |
||
812 | * |
||
813 | * @param object|array $object |
||
814 | * |
||
815 | * @return array |
||
816 | */ |
||
817 | public static function objectToID($object) { |
||
834 | |||
835 | /** |
||
836 | * Return basic URL for used Evidence |
||
837 | * |
||
838 | * @link https://www.flexibee.eu/api/dokumentace/ref/urls/ Sestavování URL |
||
839 | * |
||
840 | * @return string Evidence URL |
||
841 | */ |
||
842 | public function getEvidenceURL() { |
||
850 | |||
851 | /** |
||
852 | * Add suffix to Evidence URL |
||
853 | * |
||
854 | * @param string $urlSuffix |
||
855 | * |
||
856 | * @return string |
||
857 | */ |
||
858 | public function evidenceUrlWithSuffix($urlSuffix) { |
||
868 | |||
869 | /** |
||
870 | * Update $this->apiURL |
||
871 | */ |
||
872 | public function updateApiURL() { |
||
886 | |||
887 | /* |
||
888 | * Add Default Url params to given url if not overrided |
||
889 | * |
||
890 | * @param string $urlRaw |
||
891 | * |
||
892 | * @return string url with default params added |
||
893 | */ |
||
894 | |||
895 | public function addDefaultUrlParams($urlRaw) { |
||
899 | |||
900 | /** |
||
901 | * Funkce, která provede I/O operaci a vyhodnotí výsledek. |
||
902 | * |
||
903 | * @param string $urlSuffix část URL za identifikátorem firmy. |
||
904 | * @param string $method HTTP/REST metoda |
||
905 | * @param string $format Requested format |
||
906 | * |
||
907 | * @return array|boolean Výsledek operace |
||
908 | */ |
||
909 | public function performRequest($urlSuffix = null, $method = 'GET', |
||
929 | |||
930 | /** |
||
931 | * Parse Raw FlexiBee response in several formats |
||
932 | * |
||
933 | * @param string $responseRaw raw response body |
||
934 | * @param string $format Raw Response format json|xml|etc |
||
935 | * |
||
936 | * @return array |
||
937 | */ |
||
938 | public function rawResponseToArray($responseRaw, $format) { |
||
956 | |||
957 | /** |
||
958 | * Convert FlexiBee Response JSON to Array |
||
959 | * |
||
960 | * @param string $rawJson |
||
961 | * |
||
962 | * @return array |
||
963 | */ |
||
964 | public function rawJsonToArray($rawJson) { |
||
979 | |||
980 | /** |
||
981 | * Convert FlexiBee Response XML to Array |
||
982 | * |
||
983 | * @param string $rawXML |
||
984 | * |
||
985 | * @return array |
||
986 | */ |
||
987 | public function rawXmlToArray($rawXML) { |
||
990 | |||
991 | /** |
||
992 | * Parse Response array |
||
993 | * |
||
994 | * @param array $responseDecoded |
||
995 | * @param int $responseCode Request Response Code |
||
996 | * |
||
997 | * @return array main data part of response |
||
998 | */ |
||
999 | public function parseResponse($responseDecoded, $responseCode) { |
||
1067 | |||
1068 | /** |
||
1069 | * Parse error message response |
||
1070 | * |
||
1071 | * @param array $responseDecoded |
||
1072 | * |
||
1073 | * @return int number of errors processed |
||
1074 | */ |
||
1075 | public function parseError(array $responseDecoded) { |
||
1083 | |||
1084 | /** |
||
1085 | * Vykonej HTTP požadavek |
||
1086 | * |
||
1087 | * @link https://www.flexibee.eu/api/dokumentace/ref/urls/ Sestavování URL |
||
1088 | * @param string $url URL požadavku |
||
1089 | * @param string $method HTTP Method GET|POST|PUT|OPTIONS|DELETE |
||
1090 | * @param string $format požadovaný formát komunikace |
||
1091 | * |
||
1092 | * @return int HTTP Response CODE |
||
1093 | */ |
||
1094 | public function doCurlRequest($url, $method, $format = null) { |
||
1137 | |||
1138 | /** |
||
1139 | * Obtain json for application/json |
||
1140 | * |
||
1141 | * @param string $contentType |
||
1142 | * @param string $url |
||
1143 | * |
||
1144 | * @return string response format |
||
1145 | */ |
||
1146 | public function contentTypeToResponseFormat($contentType, $url = null) { |
||
1173 | |||
1174 | /** |
||
1175 | * Nastaví druh prováděné akce. |
||
1176 | * |
||
1177 | * @link https://demo.flexibee.eu/devdoc/actions Provádění akcí |
||
1178 | * @param string $action |
||
1179 | * |
||
1180 | * @return boolean |
||
1181 | */ |
||
1182 | public function setAction($action) { |
||
1192 | |||
1193 | /** |
||
1194 | * Convert XML to array. |
||
1195 | * |
||
1196 | * @param string $xml |
||
1197 | * |
||
1198 | * @return array |
||
1199 | */ |
||
1200 | public static function xml2array($xml) { |
||
1219 | |||
1220 | /** |
||
1221 | * Odpojení od FlexiBee. |
||
1222 | */ |
||
1223 | public function disconnect() { |
||
1229 | |||
1230 | /** |
||
1231 | * Disconnect CURL befere pass away |
||
1232 | */ |
||
1233 | public function __destruct() { |
||
1236 | |||
1237 | /** |
||
1238 | * Načte řádek dat z FlexiBee. |
||
1239 | * |
||
1240 | * @param int $recordID id požadovaného záznamu |
||
1241 | * |
||
1242 | * @return array |
||
1243 | */ |
||
1244 | public function getFlexiRow($recordID) { |
||
1253 | |||
1254 | /** |
||
1255 | * Oddělí z pole podmínek ty jenž patří za ? v URL požadavku |
||
1256 | * |
||
1257 | * @link https://www.flexibee.eu/api/dokumentace/ref/urls/ Sestavování URL |
||
1258 | * @param array $conditions pole podmínek - rendrují se do () |
||
1259 | * @param array $urlParams pole parametrů - rendrují za ? |
||
1260 | */ |
||
1261 | public function extractUrlParams(&$conditions, &$urlParams) { |
||
1268 | |||
1269 | /** |
||
1270 | * convert unicode to entities for use with FlexiBee queries |
||
1271 | * |
||
1272 | * @param string $urlRaw |
||
1273 | * |
||
1274 | * @return string |
||
1275 | */ |
||
1276 | public static function urlEncode($urlRaw) { |
||
1279 | |||
1280 | /** |
||
1281 | * Načte data z FlexiBee. |
||
1282 | * |
||
1283 | * @param string $suffix dotaz |
||
1284 | * @param string|array $conditions Custom filters or modifiers |
||
1285 | * |
||
1286 | * @return array Data obtained |
||
1287 | */ |
||
1288 | public function getFlexiData($suffix = null, $conditions = null) { |
||
1354 | |||
1355 | /** |
||
1356 | * Načte záznam z FlexiBee a uloží v sobě jeho data |
||
1357 | * Read FlexiBee record and store it inside od object |
||
1358 | * |
||
1359 | * @param int|string $id ID or conditions |
||
1360 | * |
||
1361 | * @return int počet načtených položek |
||
1362 | */ |
||
1363 | public function loadFromFlexiBee($id = null) { |
||
1377 | |||
1378 | /** |
||
1379 | * Reload current record from FlexiBee |
||
1380 | * |
||
1381 | * @return boolean |
||
1382 | */ |
||
1383 | public function reload() { |
||
1389 | |||
1390 | /** |
||
1391 | * Set Filter code for requests |
||
1392 | * |
||
1393 | * @link https://www.flexibee.eu/api/dokumentace/ref/zamykani-odemykani/ |
||
1394 | * |
||
1395 | * @param array|string $filter filter formula or ['key'=>'value'] |
||
1396 | * |
||
1397 | * @return string Filter code |
||
1398 | */ |
||
1399 | public function setFilter($filter) { |
||
1402 | |||
1403 | /** |
||
1404 | * Převede data do Json formátu pro FlexiBee. |
||
1405 | * Convert data to FlexiBee like Json format |
||
1406 | * |
||
1407 | * @url https://www.flexibee.eu/api/dokumentace/ref/actions/ |
||
1408 | * @url https://www.flexibee.eu/api/dokumentace/ref/zamykani-odemykani/ |
||
1409 | * |
||
1410 | * @param array $data object data |
||
1411 | * @param int $options json_encode options like JSON_PRETTY_PRINT etc |
||
1412 | * |
||
1413 | * @return string |
||
1414 | */ |
||
1415 | public function getJsonizedData($data = null, $options = 0) { |
||
1427 | |||
1428 | /** |
||
1429 | * Get Data Fragment specific for current object |
||
1430 | * |
||
1431 | * @param array $data |
||
1432 | * |
||
1433 | * @return array |
||
1434 | */ |
||
1435 | public function getDataForJSON($data = null) { |
||
1477 | |||
1478 | /** |
||
1479 | * Join another FlexiPeeHP Object |
||
1480 | * |
||
1481 | * @param FlexiBeeRO $object |
||
1482 | * |
||
1483 | * @return boolean adding to stack success |
||
1484 | */ |
||
1485 | public function join(&$object) { |
||
1495 | |||
1496 | /** |
||
1497 | * Prepare record ID to use in URL |
||
1498 | * |
||
1499 | * @param mixed $id |
||
1500 | * |
||
1501 | * @return string id ready for use in URL |
||
1502 | */ |
||
1503 | public static function urlizeId($id) { |
||
1513 | |||
1514 | /** |
||
1515 | * Test if given record ID exists in FlexiBee. |
||
1516 | * |
||
1517 | * @param mixed $identifer presence state |
||
1518 | * |
||
1519 | * @return boolean |
||
1520 | */ |
||
1521 | public function idExists($identifer = null) { |
||
1535 | |||
1536 | /** |
||
1537 | * Test if given record exists in FlexiBee. |
||
1538 | * |
||
1539 | * @param array|string|int $data ext:id:23|code:ITEM|['id'=>23]|23 |
||
1540 | * |
||
1541 | * @return boolean Record presence status |
||
1542 | */ |
||
1543 | public function recordExists($data = []) { |
||
1562 | |||
1563 | /** |
||
1564 | * Vrací z FlexiBee sloupečky podle podmínek. |
||
1565 | * |
||
1566 | * @param array|int|string $conditions pole podmínek nebo ID záznamu |
||
1567 | * @param string $indexBy klice vysledku naplnit hodnotou ze |
||
1568 | * sloupečku |
||
1569 | * @return array |
||
1570 | */ |
||
1571 | public function getAllFromFlexibee($conditions = null, $indexBy = null) { |
||
1584 | |||
1585 | /** |
||
1586 | * Vrací z FlexiBee sloupečky podle podmínek. |
||
1587 | * |
||
1588 | * @param string|string[] $columnsList seznam položek nebo úrověň detailu: id|summary|full |
||
1589 | * @param array $conditions pole podmínek nebo ID záznamu |
||
1590 | * @param string $indexBy Sloupeček podle kterého indexovat záznamy |
||
1591 | * |
||
1592 | * @return array |
||
1593 | */ |
||
1594 | public function getColumnsFromFlexibee($columnsList, $conditions = [], |
||
1632 | |||
1633 | /** |
||
1634 | * Vrací kód záznamu. |
||
1635 | * Obtain record CODE |
||
1636 | * |
||
1637 | * @param mixed $data |
||
1638 | * |
||
1639 | * @return string |
||
1640 | */ |
||
1641 | public function getKod($data = null, $unique = true) { |
||
1694 | |||
1695 | /** |
||
1696 | * Write Operation Result. |
||
1697 | * |
||
1698 | * @param array $resultData |
||
1699 | * @param string $url URL |
||
1700 | * |
||
1701 | * @return boolean Log save success |
||
1702 | */ |
||
1703 | public function logResult($resultData = null, $url = null) { |
||
1748 | |||
1749 | /** |
||
1750 | * Save RAW Curl Request & Response to files in Temp directory |
||
1751 | */ |
||
1752 | public function saveDebugFiles() { |
||
1765 | |||
1766 | /** |
||
1767 | * Připraví data pro odeslání do FlexiBee |
||
1768 | * |
||
1769 | * @param string $data |
||
1770 | */ |
||
1771 | public function setPostFields($data) { |
||
1774 | |||
1775 | /** |
||
1776 | * Get Content ready to be send as POST body |
||
1777 | * @return string |
||
1778 | */ |
||
1779 | public function getPostFields() { |
||
1782 | |||
1783 | /** |
||
1784 | * Generuje fragment url pro filtrování. |
||
1785 | * |
||
1786 | * @see https://www.flexibee.eu/api/dokumentace/ref/filters |
||
1787 | * |
||
1788 | * @param array $data key=>values; value can bee class DatePeriod, DateTime or Array |
||
1789 | * @param string $joiner default and/or |
||
1790 | * @param string $defop default operator |
||
1791 | * |
||
1792 | * @return string |
||
1793 | */ |
||
1794 | public static function flexiUrl(array $data, $joiner = 'and', $defop = 'eq') { |
||
1877 | |||
1878 | /** |
||
1879 | * Obtain record/object numeric identificator id: |
||
1880 | * Vrací číselný identifikátor objektu id: |
||
1881 | * |
||
1882 | * @link https://demo.flexibee.eu/devdoc/identifiers Identifikátory záznamů |
||
1883 | * |
||
1884 | * @return null|int indentifikátor záznamu reprezentovaného objektem |
||
1885 | */ |
||
1886 | public function getRecordID() { |
||
1890 | |||
1891 | /** |
||
1892 | * Obtain record/object identificator code: |
||
1893 | * Vrací identifikátor objektu code: |
||
1894 | * |
||
1895 | * @link https://demo.flexibee.eu/devdoc/identifiers Identifikátory záznamů |
||
1896 | * |
||
1897 | * @return string record code identifier |
||
1898 | */ |
||
1899 | public function getRecordCode() { |
||
1902 | |||
1903 | /** |
||
1904 | * Obtain record/object identificator extId: code: or id: |
||
1905 | * Vrací identifikátor objektu extId: code: nebo id: |
||
1906 | * |
||
1907 | * @link https://demo.flexibee.eu/devdoc/identifiers Identifikátory záznamů |
||
1908 | * |
||
1909 | * @return string|int|null record code identifier |
||
1910 | */ |
||
1911 | public function getRecordIdent() { |
||
1921 | |||
1922 | /** |
||
1923 | * Obtain record/object identificator code: or id: |
||
1924 | * Vrací identifikátor objektu code: nebo id: |
||
1925 | * |
||
1926 | * @link https://demo.flexibee.eu/devdoc/identifiers Identifikátory záznamů |
||
1927 | * |
||
1928 | * @return string indentifikátor záznamu reprezentovaného objektem |
||
1929 | */ |
||
1930 | public function __toString() { |
||
1933 | |||
1934 | /** |
||
1935 | * Gives you FlexiPeeHP class name for Given Evidence |
||
1936 | * |
||
1937 | * @param string $evidence |
||
1938 | * |
||
1939 | * @return string Class name |
||
1940 | */ |
||
1941 | public static function evidenceToClassName($evidence) { |
||
1944 | |||
1945 | /** |
||
1946 | * Obtain ID of first record in evidence |
||
1947 | * |
||
1948 | * @return string|null id or null if no records |
||
1949 | */ |
||
1950 | public function getFirstRecordID() { |
||
1960 | |||
1961 | /** |
||
1962 | * Get previous record ID |
||
1963 | * |
||
1964 | * @param array $conditions optional |
||
1965 | * |
||
1966 | * @return int|null |
||
1967 | */ |
||
1968 | public function getNextRecordID($conditions = []) { |
||
1976 | |||
1977 | /** |
||
1978 | * Get next record ID |
||
1979 | * |
||
1980 | * @param array $conditions optional |
||
1981 | * |
||
1982 | * @return int|null |
||
1983 | */ |
||
1984 | public function getPrevRecordID($conditions = []) { |
||
1992 | |||
1993 | /** |
||
1994 | * Vrací hodnotu daného externího ID |
||
1995 | * |
||
1996 | * @param string $want Namespace Selector. If empty,you obtain the first one. |
||
1997 | * |
||
1998 | * @return string|array one id or array if multiplete |
||
1999 | */ |
||
2000 | public function getExternalID($want = null) { |
||
2027 | |||
2028 | /** |
||
2029 | * gives you currently loaded extermal IDs |
||
2030 | * |
||
2031 | * @return array |
||
2032 | */ |
||
2033 | public function getExternalIDs() { |
||
2036 | |||
2037 | /** |
||
2038 | * Obtain actual GlobalVersion |
||
2039 | * Vrací aktuální globální verzi změn |
||
2040 | * |
||
2041 | * @link https://www.flexibee.eu/api/dokumentace/ref/changes-api#globalVersion Globální Verze |
||
2042 | * |
||
2043 | * @return int |
||
2044 | */ |
||
2045 | public function getGlobalVersion() { |
||
2050 | |||
2051 | /** |
||
2052 | * Gives you current ApiURL with given format suffix |
||
2053 | * |
||
2054 | * @param string $format json|html|xml|... |
||
2055 | * |
||
2056 | * @return string API URL for current record or object/evidence |
||
2057 | */ |
||
2058 | public function getApiURL($format = null) { |
||
2062 | |||
2063 | /** |
||
2064 | * Obtain content type of last response |
||
2065 | * |
||
2066 | * @return string |
||
2067 | */ |
||
2068 | public function getResponseFormat() { |
||
2071 | |||
2072 | /** |
||
2073 | * Return the same response format for one and multiplete results |
||
2074 | * |
||
2075 | * @param array $responseBody |
||
2076 | * |
||
2077 | * @return array |
||
2078 | */ |
||
2079 | public function unifyResponseFormat($responseBody) { |
||
2107 | |||
2108 | /** |
||
2109 | * Obtain structure for current (or given) evidence |
||
2110 | * |
||
2111 | * @param string $evidence |
||
2112 | * |
||
2113 | * @return array Evidence structure |
||
2114 | */ |
||
2115 | public function getOfflineColumnsInfo($evidence = null) { |
||
2123 | |||
2124 | /** |
||
2125 | * Obtain Current evidence Live structure |
||
2126 | * |
||
2127 | * @param string $evidence |
||
2128 | * |
||
2129 | * @return array structure |
||
2130 | */ |
||
2131 | public function getOnlineColumnsInfo($evidence = null) { |
||
2151 | |||
2152 | /** |
||
2153 | * Update evidence info from array or online from properties.json or offline |
||
2154 | * |
||
2155 | * @param array $columnsInfo |
||
2156 | * @param string $evidence |
||
2157 | */ |
||
2158 | public function updateColumnsInfo($columnsInfo = null, $evidence = null) { |
||
2166 | |||
2167 | /** |
||
2168 | * Gives you evidence structure. You can obtain current online by pre-calling: |
||
2169 | * $this->updateColumnsInfo($evidence, $this->getOnlineColumnsInfo($evidence)); |
||
2170 | * |
||
2171 | * @param string $evidence |
||
2172 | * |
||
2173 | * @return array |
||
2174 | */ |
||
2175 | public function getColumnsInfo($evidence = null) { |
||
2183 | |||
2184 | /** |
||
2185 | * Gives you properties for (current) evidence column |
||
2186 | * |
||
2187 | * @param string $column name of column |
||
2188 | * @param string $evidence evidence name if different |
||
2189 | * |
||
2190 | * @return array column properties or null if column not exits |
||
2191 | */ |
||
2192 | public function getColumnInfo($column, $evidence = null) { |
||
2196 | |||
2197 | /** |
||
2198 | * Obtain actions for current (or given) evidence |
||
2199 | * |
||
2200 | * @param string $evidence |
||
2201 | * |
||
2202 | * @return array Evidence structure |
||
2203 | */ |
||
2204 | public function getActionsInfo($evidence = null) { |
||
2215 | |||
2216 | /** |
||
2217 | * Obtain relations for current (or given) evidence |
||
2218 | * |
||
2219 | * @param string $evidence |
||
2220 | * |
||
2221 | * @return array Evidence structure |
||
2222 | */ |
||
2223 | public function getRelationsInfo($evidence = null) { |
||
2234 | |||
2235 | /** |
||
2236 | * Obtain info for current (or given) evidence |
||
2237 | * |
||
2238 | * @param string $evidence |
||
2239 | * |
||
2240 | * @return array Evidence info |
||
2241 | */ |
||
2242 | public function getEvidenceInfo($evidence = null) { |
||
2256 | |||
2257 | /** |
||
2258 | * Obtain name for current (or given) evidence path |
||
2259 | * |
||
2260 | * @param string $evidence Evidence Path |
||
2261 | * |
||
2262 | * @return array Evidence info |
||
2263 | */ |
||
2264 | public function getEvidenceName($evidence = null) { |
||
2274 | |||
2275 | /** |
||
2276 | * Save current object to file |
||
2277 | * |
||
2278 | * @param string $destfile path to file |
||
2279 | */ |
||
2280 | public function saveResponseToFile($destfile) { |
||
2286 | |||
2287 | /** |
||
2288 | * Obtain established relations listing |
||
2289 | * |
||
2290 | * @return array Null or Relations |
||
2291 | */ |
||
2292 | public function getVazby($id = null) { |
||
2305 | |||
2306 | /** |
||
2307 | * Gives You URL for Current Record in FlexiBee web interface |
||
2308 | * |
||
2309 | * @return string url |
||
2310 | */ |
||
2311 | public function getFlexiBeeURL() { |
||
2322 | |||
2323 | /** |
||
2324 | * Set Record Key |
||
2325 | * |
||
2326 | * @param int|string $myKeyValue |
||
2327 | * |
||
2328 | * @return boolean |
||
2329 | */ |
||
2330 | public function setMyKey($myKeyValue) { |
||
2352 | |||
2353 | /** |
||
2354 | * Set or get ignore not found pages flag |
||
2355 | * |
||
2356 | * @param boolean $ignore set flag to |
||
2357 | * |
||
2358 | * @return boolean get flag state |
||
2359 | */ |
||
2360 | public function ignore404($ignore = null) { |
||
2366 | |||
2367 | /** |
||
2368 | * Send Document by mail |
||
2369 | * |
||
2370 | * @url https://www.flexibee.eu/api/dokumentace/ref/odesilani-mailem/ |
||
2371 | * |
||
2372 | * @param string $to Email ecipient |
||
2373 | * @param string $subject Email Subject |
||
2374 | * @param string $body Email Text |
||
2375 | * |
||
2376 | * @return boolean mail sent status |
||
2377 | */ |
||
2378 | public function sendByMail($to, $subject, $body, $cc = null) { |
||
2386 | |||
2387 | /** |
||
2388 | * FlexiBee date to PHP DateTime conversion |
||
2389 | * |
||
2390 | * @param string $flexidate 2017-05-26 or 2017-05-26+02:00 |
||
2391 | * |
||
2392 | * @return \DateTime | false |
||
2393 | */ |
||
2394 | public static function flexiDateToDateTime($flexidate) { |
||
2397 | |||
2398 | /** |
||
2399 | * FlexiBee dateTime to PHP DateTime conversion |
||
2400 | * |
||
2401 | * @param string $flexidatetime 2017-09-26T10:00:53.755+02:00 or older 2017-05-19T00:00:00+02:00 |
||
2402 | * |
||
2403 | * @return \DateTime | false |
||
2404 | */ |
||
2405 | public static function flexiDateTimeToDateTime($flexidatetime) { |
||
2413 | |||
2414 | /** |
||
2415 | * Získá dokument v daném formátu |
||
2416 | * Obtain document in given format |
||
2417 | * |
||
2418 | * @link https://www.flexibee.eu/api/dokumentace/ref/pdf/ PDF Exports |
||
2419 | * |
||
2420 | * @param string $format pdf/csv/xml/json/ ... |
||
2421 | * @param string $reportName Template used to generate PDF |
||
2422 | * @param string $lang cs|sk|en|de Template language used to generate PDF |
||
2423 | * @param boolean $sign sign resulting PDF by certificate ? |
||
2424 | * |
||
2425 | * @return string|null filename downloaded or none |
||
2426 | */ |
||
2427 | public function getInFormat($format, $reportName = null, $lang = null, |
||
2466 | |||
2467 | /** |
||
2468 | * Uloží dokument v daném formátu do složky v systému souborů |
||
2469 | * Save document in given format to directory in filesystem |
||
2470 | * |
||
2471 | * @param string $format pdf/csv/xml/json/ ... |
||
2472 | * @param string $destDir where to put file (prefix) |
||
2473 | * @param string $reportName Template used to generate PDF |
||
2474 | * |
||
2475 | * @return string|null filename downloaded or none |
||
2476 | */ |
||
2477 | public function downloadInFormat($format, $destDir = './', |
||
2492 | |||
2493 | /** |
||
2494 | * Take data for object. separate external IDs |
||
2495 | * |
||
2496 | * @param array $data Data to keep |
||
2497 | * |
||
2498 | * @return int number of records taken |
||
2499 | */ |
||
2500 | public function takeData($data) { |
||
2521 | |||
2522 | /** |
||
2523 | * Get Current Evidence reports listing |
||
2524 | * |
||
2525 | * @link https://www.flexibee.eu/api/dokumentace/casto-kladene-dotazy-pro-api/vyber-reportu-do-pdf/ Výběr reportu do PDF |
||
2526 | * |
||
2527 | * @return array |
||
2528 | */ |
||
2529 | public function getReportsInfo() { |
||
2543 | |||
2544 | /** |
||
2545 | * Request authSessionId from current server |
||
2546 | * |
||
2547 | * @link https://www.flexibee.eu/api/dokumentace/ref/login/ description |
||
2548 | * |
||
2549 | * @param string $username |
||
2550 | * @param string $password |
||
2551 | * @param string $otp optional onetime password |
||
2552 | * |
||
2553 | * @return string authUserId or null in case of problems |
||
2554 | */ |
||
2555 | public function requestAuthSessionID($username, $password, $otp = null) { |
||
2568 | |||
2569 | /** |
||
2570 | * Try to Sign in current user to FlexiBee and keep authSessionId |
||
2571 | * |
||
2572 | * @return boolean sign in success |
||
2573 | */ |
||
2574 | public function login() { |
||
2579 | |||
2580 | /** |
||
2581 | * End (current's user) session |
||
2582 | * |
||
2583 | * |
||
2584 | * @link https://www.flexibee.eu/api/dokumentace/ref/logout Logout Reference |
||
2585 | * |
||
2586 | * @param string $username force username to sign off |
||
2587 | * |
||
2588 | * @return array server response |
||
2589 | */ |
||
2590 | public function logout($username = null) { |
||
2593 | |||
2594 | /** |
||
2595 | * Compile and send Report about Error500 to FlexiBee developers |
||
2596 | * If FlexiBee is running on localost try also include java backtrace |
||
2597 | * |
||
2598 | * @param array $errorResponse result of parseError(); |
||
2599 | */ |
||
2600 | public function error500Reporter($errorResponse) { |
||
2664 | |||
2665 | /** |
||
2666 | * Returns code:CODE |
||
2667 | * |
||
2668 | * @param string $code |
||
2669 | * |
||
2670 | * @return string |
||
2671 | */ |
||
2672 | public static function code($code) { |
||
2675 | |||
2676 | /** |
||
2677 | * Returns CODE without code: prefix |
||
2678 | * |
||
2679 | * @param string $code |
||
2680 | * |
||
2681 | * @return string |
||
2682 | */ |
||
2683 | public static function uncode($code) { |
||
2686 | |||
2687 | /** |
||
2688 | * Remove all @ items from array |
||
2689 | * |
||
2690 | * @param array $data original data |
||
2691 | * |
||
2692 | * @return array data without @ columns |
||
2693 | */ |
||
2694 | public static function arrayCleanUP($data) { |
||
2701 | |||
2702 | /** |
||
2703 | * Add Info about used user, server and libraries |
||
2704 | * |
||
2705 | * @param string $prefix banner prefix text |
||
2706 | * @param string $suffix banner suffix text |
||
2707 | */ |
||
2708 | public function logBanner($prefix = null, $suffix = null) { |
||
2715 | |||
2716 | /** |
||
2717 | * Get Last operation type |
||
2718 | * |
||
2719 | * @return string create|read|update|delete or update,insert for some inserted and updated in one transaction |
||
2720 | */ |
||
2721 | public function getLastOperationType() { |
||
2724 | |||
2725 | /** |
||
2726 | * Last operation errors |
||
2727 | * |
||
2728 | * @return array FlexiBee error meassages |
||
2729 | */ |
||
2730 | public function getErrors() { |
||
2733 | |||
2734 | /** |
||
2735 | * Reconnect After unserialization |
||
2736 | */ |
||
2737 | public function __wakeup() { |
||
2740 | |||
2741 | } |
||
2742 |
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.