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.32'; |
||
33 | |||
34 | /** |
||
35 | * Základní namespace pro komunikaci s FlexiBee. |
||
36 | * Basic namespace for communication with FlexiBee |
||
37 | * |
||
38 | * @var string Jmený prostor datového bloku odpovědi |
||
39 | */ |
||
40 | public $nameSpace = 'winstrom'; |
||
41 | |||
42 | /** |
||
43 | * URL of object data in FlexiBee |
||
44 | * @var string url |
||
45 | */ |
||
46 | public $apiURL = null; |
||
47 | |||
48 | /** |
||
49 | * Datový blok v poli odpovědi. |
||
50 | * Data block in response field. |
||
51 | * |
||
52 | * @var string |
||
53 | */ |
||
54 | public $resultField = 'results'; |
||
55 | |||
56 | /** |
||
57 | * Verze protokolu použitého pro komunikaci. |
||
58 | * Communication protocol version used. |
||
59 | * |
||
60 | * @var string Verze použitého API |
||
61 | */ |
||
62 | public $protoVersion = '1.0'; |
||
63 | |||
64 | /** |
||
65 | * Evidence užitá objektem. |
||
66 | * Evidence used by object |
||
67 | * |
||
68 | * @link https://demo.flexibee.eu/c/demo/evidence-list Přehled evidencí |
||
69 | * @var string |
||
70 | */ |
||
71 | public $evidence = null; |
||
72 | |||
73 | /** |
||
74 | * Detaily evidence užité objektem |
||
75 | * |
||
76 | * @var array |
||
77 | */ |
||
78 | public $evidenceInfo = []; |
||
79 | |||
80 | /** |
||
81 | * Výchozí formát pro komunikaci. |
||
82 | * Default communication format. |
||
83 | * |
||
84 | * @link https://www.flexibee.eu/api/dokumentace/ref/format-types Přehled možných formátů |
||
85 | * |
||
86 | * @var string json|xml|... |
||
87 | */ |
||
88 | public $format = 'json'; |
||
89 | |||
90 | /** |
||
91 | * formát příchozí odpovědi |
||
92 | * response format |
||
93 | * |
||
94 | * @link https://www.flexibee.eu/api/dokumentace/ref/format-types Přehled možných formátů |
||
95 | * |
||
96 | * @var string json|xml|... |
||
97 | */ |
||
98 | public $responseFormat = 'json'; |
||
99 | |||
100 | /** |
||
101 | * Curl Handle. |
||
102 | * |
||
103 | * @var resource |
||
104 | */ |
||
105 | public $curl = null; |
||
106 | |||
107 | /** |
||
108 | * @link https://demo.flexibee.eu/devdoc/company-identifier Identifikátor firmy |
||
109 | * @var string |
||
110 | */ |
||
111 | public $company = null; |
||
112 | |||
113 | /** |
||
114 | * [protocol://]Server[:port] |
||
115 | * @var string |
||
116 | */ |
||
117 | public $url = null; |
||
118 | |||
119 | /** |
||
120 | * REST API Username |
||
121 | * @var string |
||
122 | */ |
||
123 | public $user = null; |
||
124 | |||
125 | /** |
||
126 | * REST API Password |
||
127 | * @var string |
||
128 | */ |
||
129 | public $password = null; |
||
130 | |||
131 | /** |
||
132 | * @var array Pole HTTP hlaviček odesílaných s každým požadavkem |
||
133 | */ |
||
134 | public $defaultHttpHeaders = ['User-Agent' => 'FlexiPeeHP']; |
||
135 | |||
136 | /** |
||
137 | * Default additional request url parameters after question mark |
||
138 | * |
||
139 | * @link https://www.flexibee.eu/api/dokumentace/ref/urls Common params |
||
140 | * @link https://www.flexibee.eu/api/dokumentace/ref/paging Paging params |
||
141 | * @var array |
||
142 | */ |
||
143 | public $defaultUrlParams = []; |
||
144 | |||
145 | /** |
||
146 | * Identifikační řetězec. |
||
147 | * |
||
148 | * @var string |
||
149 | */ |
||
150 | public $init = null; |
||
151 | |||
152 | /** |
||
153 | * Sloupeček s názvem. |
||
154 | * |
||
155 | * @var string |
||
156 | */ |
||
157 | public $nameColumn = 'nazev'; |
||
158 | |||
159 | /** |
||
160 | * Sloupeček obsahující datum vložení záznamu do shopu. |
||
161 | * |
||
162 | * @var string |
||
163 | */ |
||
164 | public $myCreateColumn = 'false'; |
||
165 | |||
166 | /** |
||
167 | * Slopecek obsahujici datum poslení modifikace záznamu do shopu. |
||
168 | * |
||
169 | * @var string |
||
170 | */ |
||
171 | public $myLastModifiedColumn = 'lastUpdate'; |
||
172 | |||
173 | /** |
||
174 | * Klíčový idendifikátor záznamu. |
||
175 | * |
||
176 | * @var string |
||
177 | */ |
||
178 | public $fbKeyColumn = 'id'; |
||
179 | |||
180 | /** |
||
181 | * Informace o posledním HTTP requestu. |
||
182 | * |
||
183 | * @var * |
||
184 | */ |
||
185 | public $curlInfo; |
||
186 | |||
187 | /** |
||
188 | * Informace o poslední HTTP chybě. |
||
189 | * |
||
190 | * @var string |
||
191 | */ |
||
192 | public $lastCurlError = null; |
||
193 | |||
194 | /** |
||
195 | * Used codes storage. |
||
196 | * |
||
197 | * @var array |
||
198 | */ |
||
199 | public $codes = null; |
||
200 | |||
201 | /** |
||
202 | * Last Inserted ID. |
||
203 | * |
||
204 | * @var int |
||
205 | */ |
||
206 | public $lastInsertedID = null; |
||
207 | |||
208 | /** |
||
209 | * Default Line Prefix. |
||
210 | * |
||
211 | * @var string |
||
212 | */ |
||
213 | public $prefix = '/c/'; |
||
214 | |||
215 | /** |
||
216 | * Raw Content of last curl response |
||
217 | * |
||
218 | * @var string |
||
219 | */ |
||
220 | public $lastCurlResponse; |
||
221 | |||
222 | /** |
||
223 | * HTTP Response code of last request |
||
224 | * |
||
225 | * @var int |
||
226 | */ |
||
227 | public $lastResponseCode = null; |
||
228 | |||
229 | /** |
||
230 | * Body data for next curl POST operation |
||
231 | * |
||
232 | * @var string |
||
233 | */ |
||
234 | protected $postFields = null; |
||
235 | |||
236 | /** |
||
237 | * Last operation result data or message(s) |
||
238 | * |
||
239 | * @var array |
||
240 | */ |
||
241 | public $lastResult = null; |
||
242 | |||
243 | /** |
||
244 | * Number from @rowCount in response |
||
245 | * @var int |
||
246 | */ |
||
247 | public $rowCount = null; |
||
248 | |||
249 | /** |
||
250 | * Number from @globalVersion |
||
251 | * @var int |
||
252 | */ |
||
253 | public $globalVersion = null; |
||
254 | |||
255 | /** |
||
256 | * @link https://www.flexibee.eu/api/dokumentace/ref/zamykani-odemykani/ |
||
257 | * @var string filter query |
||
258 | */ |
||
259 | public $filter; |
||
260 | |||
261 | /** |
||
262 | * @link https://demo.flexibee.eu/devdoc/actions Provádění akcí |
||
263 | * @var string |
||
264 | */ |
||
265 | protected $action; |
||
266 | |||
267 | /** |
||
268 | * Pole akcí které podporuje ta která evidence |
||
269 | * @link https://demo.flexibee.eu/c/demo/faktura-vydana/actions.json Např. Akce faktury |
||
270 | * @var array |
||
271 | */ |
||
272 | public $actionsAvailable = null; |
||
273 | |||
274 | /** |
||
275 | * Parmetry pro URL |
||
276 | * @link https://www.flexibee.eu/api/dokumentace/ref/urls/ Všechny podporované parametry |
||
277 | * @var array |
||
278 | */ |
||
279 | public $urlParams = [ |
||
280 | 'add-global-version' => ['type' => 'boolean', 'description' => 'The response will contain the global version number of the current export'], |
||
281 | 'add-row-count' => ['type' => 'boolean', 'description' => 'Adding Total Records to Output (Pagination)'], |
||
282 | 'as-gui' => ['type' => 'boolean', 'description' => 'Turns on functions that complement the GUI processing outputs'], |
||
283 | '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.'], |
||
284 | 'authSessionId' => ['type' => 'string', 'description' => 'Authentification Session ID'], |
||
285 | '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>'], |
||
286 | 'code-in-response' => ['type' => 'boolean', 'description' => 'The response will contain not only ID and URL for each object, but also code.'], |
||
287 | 'delimeter' => ['type' => 'string', 'description' => 'Specifies the input / output file separator in CSV format.', |
||
288 | 'example' => ';'], |
||
289 | 'detail' => ['type' => 'string', 'description' => 'Definition of the level of detail'], //See: https://www.flexibee.eu/api/dokumentace/ref/detail-levels |
||
290 | 'dir' => ['type' => 'string', 'description' => 'Sorting direction.', 'example' => 'desc'], |
||
291 | 'dry-run' => ['type' => 'boolean', 'description' => 'Test run (dry-run)'], // See: https://www.flexibee.eu/api/dokumentace/ref/dry-run/ |
||
292 | 'encoding' => ['type' => 'string', 'description' => 'Specifies the encoding of the input / output file in CSV format.'], |
||
293 | 'export-settings' => ['type' => 'boolean', 'description' => 'Export one extra entry with current settings at the beginning'], |
||
294 | 'fail-on-warning' => ['type' => 'boolean', 'description' => 'If a warning occurs, do not save a record (Data Validation)'], |
||
295 | 'filter' => ['type' => 'string', 'description' => 'filter results by this param'], |
||
296 | 'format' => ['type' => 'string', 'description' => 'One of the compiled XSL transforms will be applied to the output XML.'], |
||
297 | 'idUcetniObdobi' => ['type' => 'string', 'description' => ''], //See: https://www.flexibee.eu/api/dokumentace/ref/stavy-uctu/ |
||
298 | 'includes' => ['type' => 'string', 'description' => 'Include related detail level object ', |
||
299 | 'example' => 'faktura-vydana/stredisko'], |
||
300 | 'inDesktopApp' => ['type' => 'boolean', 'description' => 'Hide menu and navigation in html format'], // Note: Undocumented function (html only) |
||
301 | 'limit' => ['type' => 'integer', 'description' => 'number of requested results'], |
||
302 | 'mode' => ['type' => 'string', 'description' => 'Support for RubyOnRails', |
||
303 | 'example' => 'ruby'], |
||
304 | 'no-ext-ids' => ['type' => 'boolean', 'description' => 'The answer will not contain external identifiers (performance optimization)'], |
||
305 | 'no-http-errors' => ['type' => 'boolean', 'description' => 'If a 4xx error occurs while processing a request, the server sends 200 OK anyway'], |
||
306 | 'no-ids' => ['type' => 'boolean', 'description' => 'The response will not contain any primary identifiers (performance optimization). It only affects the main records.'], |
||
307 | '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.'], |
||
308 | 'order' => ['type' => 'string', 'description' => 'Sorting records', 'example' => 'nazev@A'], |
||
309 | 'relations' => ['type' => 'string', 'description' => 'Adding session data (see detail levels) A session overview can be obtained for each record (/ relations).'], |
||
310 | 'report-lang' => ['type' => 'string', 'description' => 'The language in which to print the output when exporting to PDF', |
||
311 | 'example' => 'en'], |
||
312 | 'report-name' => ['type' => 'string', 'description' => 'The name of the printout when exporting to PDF', |
||
313 | 'example' => 'invoice'], |
||
314 | 'report-sign' => ['type' => 'string', 'description' => 'Whether the PDF should be exported electronically signed'], |
||
315 | 'skupina-stitku' => ['type' => 'string', 'description' => 'Enables grouping of labels when exporting by group (multiple labels)'], |
||
316 | 'sort' => ['type' => 'string', 'description' => 'Sorting records for ExtJS'], |
||
317 | 'start' => ['type' => 'integer', 'description' => 'Pagination'], |
||
318 | 'stitky-as-ids' => ['type' => 'boolean', 'description' => 'Labels will be exported and imported not as a code list but as a list of numeric IDs'], |
||
319 | 'use-ext-id' => ['type' => 'boolean', 'description' => 'If the object contains an external ESHOP or MY ID, use it as a bind.'], |
||
320 | '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'], |
||
321 | 'xpath' => ['type' => 'string', 'description' => 'Apply XPATH to result', |
||
322 | 'example' => '//winstrom/adresar/email/text()'] // See: https://www.flexibee.eu/api/dokumentace/ref/xpath/ |
||
323 | ]; |
||
324 | |||
325 | /** |
||
326 | * Session ID |
||
327 | * @var string |
||
328 | */ |
||
329 | public $authSessionId = null; |
||
330 | |||
331 | /** |
||
332 | * Token obtained during login procedure |
||
333 | * @var string |
||
334 | */ |
||
335 | public $refreshToken = null; |
||
336 | |||
337 | /** |
||
338 | * Save 404 results to log ? |
||
339 | * @var boolean |
||
340 | */ |
||
341 | protected $ignoreNotFound = false; |
||
342 | |||
343 | /** |
||
344 | * Array of errors caused by last request |
||
345 | * @var array |
||
346 | */ |
||
347 | private $errors = []; |
||
348 | |||
349 | /** |
||
350 | * List of Error500 reports sent |
||
351 | * @var array |
||
352 | */ |
||
353 | private $reports = []; |
||
354 | |||
355 | /** |
||
356 | * Send Error500 Report to |
||
357 | * @var string email address |
||
358 | */ |
||
359 | public $reportRecipient = '[email protected]'; |
||
360 | |||
361 | /** |
||
362 | * Formating string for \DateTime::format() for datetime columns |
||
363 | * @var string |
||
364 | */ |
||
365 | static public $DateTimeFormat = 'Y-m-d\TH:i:s.u+P'; |
||
366 | |||
367 | /** |
||
368 | * Formating string for \DateTime::format() for date columns |
||
369 | * @var string |
||
370 | */ |
||
371 | static public $DateFormat = 'Y-m-d'; |
||
372 | |||
373 | /** |
||
374 | * Last Request response stats |
||
375 | * @var array |
||
376 | */ |
||
377 | protected $responseStats = null; |
||
378 | |||
379 | /** |
||
380 | * Chained Objects |
||
381 | * @var array |
||
382 | */ |
||
383 | public $chained = []; |
||
384 | |||
385 | /** |
||
386 | * We Connect to server by default |
||
387 | * @var boolean |
||
388 | */ |
||
389 | public $offline = false; |
||
390 | |||
391 | /** |
||
392 | * Override cURL timeout |
||
393 | * @var int seconds |
||
394 | */ |
||
395 | public $timeout = null; |
||
396 | |||
397 | /** |
||
398 | * Columns Info for serveral evidencies |
||
399 | * @var array |
||
400 | */ |
||
401 | private $columnsInfo = []; |
||
402 | |||
403 | /** |
||
404 | * Throw Exception in case of FlexiBee error |
||
405 | * @var boolean |
||
406 | */ |
||
407 | public $throwException = false; |
||
408 | |||
409 | /** |
||
410 | * Class for read only interaction with FlexiBee. |
||
411 | * |
||
412 | * @param mixed $init default record id or initial data. See processInit() |
||
413 | * @param array $options Connection settings and other options override |
||
414 | */ |
||
415 | public function __construct($init = null, $options = []) { |
||
424 | |||
425 | /** |
||
426 | * Set internal Object name |
||
427 | * |
||
428 | * @param string $objectName |
||
429 | * |
||
430 | * @return string Jméno objektu |
||
431 | */ |
||
432 | public function setObjectName($objectName = null) { |
||
435 | |||
436 | /** |
||
437 | * SetUp Object to be ready for work |
||
438 | * |
||
439 | * @param array $options Object Options ( user,password,authSessionId |
||
440 | * company,url,evidence, |
||
441 | * prefix,defaultUrlParams,debug, |
||
442 | * detail,offline,filter,ignore404 |
||
443 | * timeout,companyUrl,ver,throwException |
||
444 | */ |
||
445 | public function setUp($options = []) { |
||
487 | |||
488 | /** |
||
489 | * Set up one of properties |
||
490 | * |
||
491 | * @param array $options array of given properties |
||
492 | * @param string $name name of property to process |
||
493 | * @param string $constant load default property value from constant |
||
494 | */ |
||
495 | public function setupProperty($options, $name, $constant = null) { |
||
506 | |||
507 | /** |
||
508 | * Convert companyUrl provided by CustomButton to options array |
||
509 | * |
||
510 | * @param string $companyUrl |
||
511 | * |
||
512 | * @return array Options |
||
513 | */ |
||
514 | public static function companyUrlToOptions($companyUrl) { |
||
525 | |||
526 | /** |
||
527 | * Get Current connection options for use in another object |
||
528 | * |
||
529 | * @return array usable as second constructor parameter |
||
530 | */ |
||
531 | public function getConnectionOptions() { |
||
548 | |||
549 | /** |
||
550 | * Inicializace CURL |
||
551 | * |
||
552 | * @return boolean Online Status |
||
553 | */ |
||
554 | public function curlInit() { |
||
573 | |||
574 | /** |
||
575 | * Zinicializuje objekt dle daných dat. Možné hodnoty: |
||
576 | * |
||
577 | * * 234 - interní číslo záznamu k načtení |
||
578 | * * code:LOPATA - kód záznamu |
||
579 | * * BAGR - kód záznamu k načtení |
||
580 | * * ['id'=>24,'nazev'=>'hoblík'] - pole hodnot k předvyplnění |
||
581 | * * 743.json?relations=adresa,vazby - část url s parametry k načtení |
||
582 | * |
||
583 | * @param mixed $init číslo/"(code:)kód"/(část)URI záznamu k načtení | pole hodnot k předvyplnění |
||
584 | */ |
||
585 | public function processInit($init) { |
||
596 | |||
597 | /** |
||
598 | * Set Data Field value |
||
599 | * |
||
600 | * @param string $columnName field name |
||
601 | * @param mixed $value field data value |
||
602 | * |
||
603 | * @return bool Success |
||
604 | */ |
||
605 | public function setDataValue($columnName, $value) { |
||
631 | |||
632 | /** |
||
633 | * PHP Date object to FlexiBee date format |
||
634 | * |
||
635 | * @param \DateTime $date |
||
636 | */ |
||
637 | public static function dateToFlexiDate($date) { |
||
640 | |||
641 | /** |
||
642 | * PHP Date object to FlexiBee date format |
||
643 | * |
||
644 | * @param \DateTime $dateTime |
||
645 | */ |
||
646 | public static function dateToFlexiDateTime($dateTime) { |
||
649 | |||
650 | /** |
||
651 | * Set URL prefix |
||
652 | * |
||
653 | * @param string $prefix |
||
654 | */ |
||
655 | public function setPrefix($prefix) { |
||
675 | |||
676 | /** |
||
677 | * Set communication format. |
||
678 | * One of html|xml|json|csv|dbf|xls|isdoc|isdocx|edi|pdf|pdf|vcf|ical |
||
679 | * |
||
680 | * @param string $format |
||
681 | * |
||
682 | * @return boolean format is availble |
||
683 | */ |
||
684 | public function setFormat($format) { |
||
697 | |||
698 | /** |
||
699 | * Nastaví Evidenci pro Komunikaci. |
||
700 | * Set evidence for communication |
||
701 | * |
||
702 | * @param string $evidence evidence pathName to use |
||
703 | * |
||
704 | * @return boolean evidence switching status |
||
705 | */ |
||
706 | public function setEvidence($evidence) { |
||
731 | |||
732 | /** |
||
733 | * Vrací právě používanou evidenci pro komunikaci |
||
734 | * Obtain current used evidence |
||
735 | * |
||
736 | * @return string |
||
737 | */ |
||
738 | public function getEvidence() { |
||
741 | |||
742 | /** |
||
743 | * Set used company. |
||
744 | * Nastaví Firmu. |
||
745 | * |
||
746 | * @param string $company |
||
747 | */ |
||
748 | public function setCompany($company) { |
||
751 | |||
752 | /** |
||
753 | * Obtain company now used |
||
754 | * Vrací právě používanou firmu |
||
755 | * |
||
756 | * @return string |
||
757 | */ |
||
758 | public function getCompany() { |
||
761 | |||
762 | /** |
||
763 | * Vrací název evidence použité v odpovědích z FlexiBee |
||
764 | * |
||
765 | * @return string |
||
766 | */ |
||
767 | public function getResponseEvidence() { |
||
781 | |||
782 | /** |
||
783 | * Převede rekurzivně Objekt na pole. |
||
784 | * |
||
785 | * @param object|array $object |
||
786 | * |
||
787 | * @return array |
||
788 | */ |
||
789 | public static function object2array($object) { |
||
808 | |||
809 | /** |
||
810 | * Převede rekurzivně v poli všechny objekty na jejich identifikátory. |
||
811 | * |
||
812 | * @param object|array $object |
||
813 | * |
||
814 | * @return array |
||
815 | */ |
||
816 | public static function objectToID($object) { |
||
833 | |||
834 | /** |
||
835 | * Return basic URL for used Evidence |
||
836 | * |
||
837 | * @link https://www.flexibee.eu/api/dokumentace/ref/urls/ Sestavování URL |
||
838 | * |
||
839 | * @return string Evidence URL |
||
840 | */ |
||
841 | public function getEvidenceURL() { |
||
849 | |||
850 | /** |
||
851 | * Add suffix to Evidence URL |
||
852 | * |
||
853 | * @param string $urlSuffix |
||
854 | * |
||
855 | * @return string |
||
856 | */ |
||
857 | public function evidenceUrlWithSuffix($urlSuffix) { |
||
867 | |||
868 | /** |
||
869 | * Update $this->apiURL |
||
870 | */ |
||
871 | public function updateApiURL() { |
||
885 | |||
886 | /* |
||
887 | * Add Default Url params to given url if not overrided |
||
888 | * |
||
889 | * @param string $urlRaw |
||
890 | * |
||
891 | * @return string url with default params added |
||
892 | */ |
||
893 | |||
894 | public function addDefaultUrlParams($urlRaw) { |
||
898 | |||
899 | /** |
||
900 | * Funkce, která provede I/O operaci a vyhodnotí výsledek. |
||
901 | * |
||
902 | * @param string $urlSuffix část URL za identifikátorem firmy. |
||
903 | * @param string $method HTTP/REST metoda |
||
904 | * @param string $format Requested format |
||
905 | * |
||
906 | * @return array|boolean Výsledek operace |
||
907 | */ |
||
908 | public function performRequest($urlSuffix = null, $method = 'GET', |
||
928 | |||
929 | /** |
||
930 | * Parse Raw FlexiBee response in several formats |
||
931 | * |
||
932 | * @param string $responseRaw raw response body |
||
933 | * @param string $format Raw Response format json|xml|etc |
||
934 | * |
||
935 | * @return array |
||
936 | */ |
||
937 | public function rawResponseToArray($responseRaw, $format) { |
||
955 | |||
956 | /** |
||
957 | * Convert FlexiBee Response JSON to Array |
||
958 | * |
||
959 | * @param string $rawJson |
||
960 | * |
||
961 | * @return array |
||
962 | */ |
||
963 | public function rawJsonToArray($rawJson) { |
||
978 | |||
979 | /** |
||
980 | * Convert FlexiBee Response XML to Array |
||
981 | * |
||
982 | * @param string $rawXML |
||
983 | * |
||
984 | * @return array |
||
985 | */ |
||
986 | public function rawXmlToArray($rawXML) { |
||
989 | |||
990 | /** |
||
991 | * Parse Response array |
||
992 | * |
||
993 | * @param array $responseDecoded |
||
994 | * @param int $responseCode Request Response Code |
||
995 | * |
||
996 | * @return array main data part of response |
||
997 | */ |
||
998 | public function parseResponse($responseDecoded, $responseCode) { |
||
1066 | |||
1067 | /** |
||
1068 | * Parse error message response |
||
1069 | * |
||
1070 | * @param array $responseDecoded |
||
1071 | * |
||
1072 | * @return int number of errors processed |
||
1073 | */ |
||
1074 | public function parseError(array $responseDecoded) { |
||
1091 | |||
1092 | /** |
||
1093 | * Vykonej HTTP požadavek |
||
1094 | * |
||
1095 | * @link https://www.flexibee.eu/api/dokumentace/ref/urls/ Sestavování URL |
||
1096 | * @param string $url URL požadavku |
||
1097 | * @param string $method HTTP Method GET|POST|PUT|OPTIONS|DELETE |
||
1098 | * @param string $format požadovaný formát komunikace |
||
1099 | * |
||
1100 | * @return int HTTP Response CODE |
||
1101 | */ |
||
1102 | public function doCurlRequest($url, $method, $format = null) { |
||
1152 | |||
1153 | /** |
||
1154 | * Obtain json for application/json |
||
1155 | * |
||
1156 | * @param string $contentType |
||
1157 | * @param string $url |
||
1158 | * |
||
1159 | * @return string response format |
||
1160 | */ |
||
1161 | public function contentTypeToResponseFormat($contentType, $url = null) { |
||
1188 | |||
1189 | /** |
||
1190 | * Nastaví druh prováděné akce. |
||
1191 | * |
||
1192 | * @link https://demo.flexibee.eu/devdoc/actions Provádění akcí |
||
1193 | * @param string $action |
||
1194 | * |
||
1195 | * @return boolean |
||
1196 | */ |
||
1197 | public function setAction($action) { |
||
1207 | |||
1208 | /** |
||
1209 | * Convert XML to array. |
||
1210 | * |
||
1211 | * @param string $xml |
||
1212 | * |
||
1213 | * @return array |
||
1214 | */ |
||
1215 | public static function xml2array($xml) { |
||
1234 | |||
1235 | /** |
||
1236 | * Odpojení od FlexiBee. |
||
1237 | */ |
||
1238 | public function disconnect() { |
||
1244 | |||
1245 | /** |
||
1246 | * Disconnect CURL befere pass away |
||
1247 | */ |
||
1248 | public function __destruct() { |
||
1251 | |||
1252 | /** |
||
1253 | * Načte řádek dat z FlexiBee. |
||
1254 | * |
||
1255 | * @param int $recordID id požadovaného záznamu |
||
1256 | * |
||
1257 | * @return array |
||
1258 | */ |
||
1259 | public function getFlexiRow($recordID) { |
||
1268 | |||
1269 | /** |
||
1270 | * Oddělí z pole podmínek ty jenž patří za ? v URL požadavku |
||
1271 | * |
||
1272 | * @link https://www.flexibee.eu/api/dokumentace/ref/urls/ Sestavování URL |
||
1273 | * @param array $conditions pole podmínek - rendrují se do () |
||
1274 | * @param array $urlParams pole parametrů - rendrují za ? |
||
1275 | */ |
||
1276 | public function extractUrlParams(&$conditions, &$urlParams) { |
||
1283 | |||
1284 | /** |
||
1285 | * convert unicode to entities for use with FlexiBee queries |
||
1286 | * |
||
1287 | * @param string $urlRaw |
||
1288 | * |
||
1289 | * @return string |
||
1290 | */ |
||
1291 | public static function urlEncode($urlRaw) { |
||
1294 | |||
1295 | /** |
||
1296 | * Načte data z FlexiBee. |
||
1297 | * |
||
1298 | * @param string $suffix dotaz |
||
1299 | * @param string|array $conditions Custom filters or modifiers |
||
1300 | * |
||
1301 | * @return array Data obtained |
||
1302 | */ |
||
1303 | public function getFlexiData($suffix = null, $conditions = null) { |
||
1369 | |||
1370 | /** |
||
1371 | * Načte záznam z FlexiBee a uloží v sobě jeho data |
||
1372 | * Read FlexiBee record and store it inside od object |
||
1373 | * |
||
1374 | * @param int|string $id ID or conditions |
||
1375 | * |
||
1376 | * @return int počet načtených položek |
||
1377 | */ |
||
1378 | public function loadFromFlexiBee($id = null) { |
||
1392 | |||
1393 | /** |
||
1394 | * Reload current record from FlexiBee |
||
1395 | * |
||
1396 | * @return boolean |
||
1397 | */ |
||
1398 | public function reload() { |
||
1404 | |||
1405 | /** |
||
1406 | * Set Filter code for requests |
||
1407 | * |
||
1408 | * @link https://www.flexibee.eu/api/dokumentace/ref/zamykani-odemykani/ |
||
1409 | * |
||
1410 | * @param array|string $filter filter formula or ['key'=>'value'] |
||
1411 | * |
||
1412 | * @return string Filter code |
||
1413 | */ |
||
1414 | public function setFilter($filter) { |
||
1417 | |||
1418 | /** |
||
1419 | * Převede data do Json formátu pro FlexiBee. |
||
1420 | * Convert data to FlexiBee like Json format |
||
1421 | * |
||
1422 | * @url https://www.flexibee.eu/api/dokumentace/ref/actions/ |
||
1423 | * @url https://www.flexibee.eu/api/dokumentace/ref/zamykani-odemykani/ |
||
1424 | * |
||
1425 | * @param array $data object data |
||
1426 | * @param int $options json_encode options like JSON_PRETTY_PRINT etc |
||
1427 | * |
||
1428 | * @return string |
||
1429 | */ |
||
1430 | public function getJsonizedData($data = null, $options = 0) { |
||
1442 | |||
1443 | /** |
||
1444 | * Get Data Fragment specific for current object |
||
1445 | * |
||
1446 | * @param array $data |
||
1447 | * |
||
1448 | * @return array |
||
1449 | */ |
||
1450 | public function getDataForJSON($data = null) { |
||
1492 | |||
1493 | /** |
||
1494 | * Join another FlexiPeeHP Object |
||
1495 | * |
||
1496 | * @param FlexiBeeRO $object |
||
1497 | * |
||
1498 | * @return boolean adding to stack success |
||
1499 | */ |
||
1500 | public function join(&$object) { |
||
1510 | |||
1511 | /** |
||
1512 | * Prepare record ID to use in URL |
||
1513 | * |
||
1514 | * @param mixed $id |
||
1515 | * |
||
1516 | * @return string id ready for use in URL |
||
1517 | */ |
||
1518 | public static function urlizeId($id) { |
||
1528 | |||
1529 | /** |
||
1530 | * Test if given record ID exists in FlexiBee. |
||
1531 | * |
||
1532 | * @param mixed $identifer presence state |
||
1533 | * |
||
1534 | * @return boolean |
||
1535 | */ |
||
1536 | public function idExists($identifer = null) { |
||
1550 | |||
1551 | /** |
||
1552 | * Test if given record exists in FlexiBee. |
||
1553 | * |
||
1554 | * @param array|string|int $data ext:id:23|code:ITEM|['id'=>23]|23 |
||
1555 | * |
||
1556 | * @return boolean Record presence status |
||
1557 | */ |
||
1558 | public function recordExists($data = []) { |
||
1577 | |||
1578 | /** |
||
1579 | * Subitems - ex. items of invoice |
||
1580 | * |
||
1581 | * @return array of document items or null |
||
1582 | */ |
||
1583 | public function getSubItems() { |
||
1586 | |||
1587 | /** |
||
1588 | * Vrací z FlexiBee sloupečky podle podmínek. |
||
1589 | * |
||
1590 | * @param array|int|string $conditions pole podmínek nebo ID záznamu |
||
1591 | * @param string $indexBy klice vysledku naplnit hodnotou ze |
||
1592 | * sloupečku |
||
1593 | * @return array |
||
1594 | */ |
||
1595 | public function getAllFromFlexibee($conditions = null, $indexBy = null) { |
||
1608 | |||
1609 | /** |
||
1610 | * Vrací z FlexiBee sloupečky podle podmínek. |
||
1611 | * |
||
1612 | * @param string|string[] $columnsList seznam položek nebo úrověň detailu: id|summary|full |
||
1613 | * @param array $conditions pole podmínek nebo ID záznamu |
||
1614 | * @param string $indexBy Sloupeček podle kterého indexovat záznamy |
||
1615 | * |
||
1616 | * @return array |
||
1617 | */ |
||
1618 | public function getColumnsFromFlexibee($columnsList, $conditions = [], |
||
1656 | |||
1657 | /** |
||
1658 | * Vrací kód záznamu. |
||
1659 | * Obtain record CODE |
||
1660 | * |
||
1661 | * @param mixed $data |
||
1662 | * |
||
1663 | * @return string |
||
1664 | */ |
||
1665 | public function getKod($data = null, $unique = true) { |
||
1718 | |||
1719 | /** |
||
1720 | * Write Operation Result. |
||
1721 | * |
||
1722 | * @param array $resultData |
||
1723 | * @param string $url URL |
||
1724 | * |
||
1725 | * @return boolean Log save success |
||
1726 | */ |
||
1727 | public function logResult($resultData = null, $url = null) { |
||
1772 | |||
1773 | /** |
||
1774 | * Save RAW Curl Request & Response to files in Temp directory |
||
1775 | */ |
||
1776 | public function saveDebugFiles() { |
||
1789 | |||
1790 | /** |
||
1791 | * Připraví data pro odeslání do FlexiBee |
||
1792 | * |
||
1793 | * @param string $data |
||
1794 | */ |
||
1795 | public function setPostFields($data) { |
||
1798 | |||
1799 | /** |
||
1800 | * Get Content ready to be send as POST body |
||
1801 | * @return string |
||
1802 | */ |
||
1803 | public function getPostFields() { |
||
1806 | |||
1807 | /** |
||
1808 | * Generuje fragment url pro filtrování. |
||
1809 | * |
||
1810 | * @see https://www.flexibee.eu/api/dokumentace/ref/filters |
||
1811 | * |
||
1812 | * @param array $data key=>values; value can bee class DatePeriod, DateTime or Array |
||
1813 | * @param string $joiner default and/or |
||
1814 | * @param string $defop default operator |
||
1815 | * |
||
1816 | * @return string |
||
1817 | */ |
||
1818 | public static function flexiUrl(array $data, $joiner = 'and', $defop = 'eq') { |
||
1901 | |||
1902 | /** |
||
1903 | * Obtain record/object numeric identificator id: |
||
1904 | * Vrací číselný identifikátor objektu id: |
||
1905 | * |
||
1906 | * @link https://demo.flexibee.eu/devdoc/identifiers Identifikátory záznamů |
||
1907 | * |
||
1908 | * @return null|int indentifikátor záznamu reprezentovaného objektem |
||
1909 | */ |
||
1910 | public function getRecordID() { |
||
1914 | |||
1915 | /** |
||
1916 | * Obtain record/object identificator code: |
||
1917 | * Vrací identifikátor objektu code: |
||
1918 | * |
||
1919 | * @link https://demo.flexibee.eu/devdoc/identifiers Identifikátory záznamů |
||
1920 | * |
||
1921 | * @return string record code identifier |
||
1922 | */ |
||
1923 | public function getRecordCode() { |
||
1926 | |||
1927 | /** |
||
1928 | * Obtain record/object identificator extId: code: or id: |
||
1929 | * Vrací identifikátor objektu extId: code: nebo id: |
||
1930 | * |
||
1931 | * @link https://demo.flexibee.eu/devdoc/identifiers Identifikátory záznamů |
||
1932 | * |
||
1933 | * @return string|int|null record code identifier |
||
1934 | */ |
||
1935 | public function getRecordIdent() { |
||
1945 | |||
1946 | /** |
||
1947 | * Obtain record/object identificator code: or id: |
||
1948 | * Vrací identifikátor objektu code: nebo id: |
||
1949 | * |
||
1950 | * @link https://demo.flexibee.eu/devdoc/identifiers Identifikátory záznamů |
||
1951 | * |
||
1952 | * @return string indentifikátor záznamu reprezentovaného objektem |
||
1953 | */ |
||
1954 | public function __toString() { |
||
1957 | |||
1958 | /** |
||
1959 | * Gives you FlexiPeeHP class name for Given Evidence |
||
1960 | * |
||
1961 | * @param string $evidence |
||
1962 | * |
||
1963 | * @return string Class name |
||
1964 | */ |
||
1965 | public static function evidenceToClassName($evidence) { |
||
1968 | |||
1969 | /** |
||
1970 | * Obtain ID of first record in evidence |
||
1971 | * |
||
1972 | * @return string|null id or null if no records |
||
1973 | */ |
||
1974 | public function getFirstRecordID() { |
||
1984 | |||
1985 | /** |
||
1986 | * Get previous record ID |
||
1987 | * |
||
1988 | * @param array $conditions optional |
||
1989 | * |
||
1990 | * @return int|null |
||
1991 | */ |
||
1992 | public function getNextRecordID($conditions = []) { |
||
2000 | |||
2001 | /** |
||
2002 | * Get next record ID |
||
2003 | * |
||
2004 | * @param array $conditions optional |
||
2005 | * |
||
2006 | * @return int|null |
||
2007 | */ |
||
2008 | public function getPrevRecordID($conditions = []) { |
||
2016 | |||
2017 | /** |
||
2018 | * Vrací hodnotu daného externího ID |
||
2019 | * |
||
2020 | * @param string $want Namespace Selector. If empty,you obtain the first one. |
||
2021 | * |
||
2022 | * @return string|array one id or array if multiplete |
||
2023 | */ |
||
2024 | public function getExternalID($want = null) { |
||
2051 | |||
2052 | /** |
||
2053 | * gives you currently loaded extermal IDs |
||
2054 | * |
||
2055 | * @return array |
||
2056 | */ |
||
2057 | public function getExternalIDs() { |
||
2060 | |||
2061 | /** |
||
2062 | * Obtain actual GlobalVersion |
||
2063 | * Vrací aktuální globální verzi změn |
||
2064 | * |
||
2065 | * @link https://www.flexibee.eu/api/dokumentace/ref/changes-api#globalVersion Globální Verze |
||
2066 | * |
||
2067 | * @return int |
||
2068 | */ |
||
2069 | public function getGlobalVersion() { |
||
2074 | |||
2075 | /** |
||
2076 | * Gives you current ApiURL with given format suffix |
||
2077 | * |
||
2078 | * @param string $format json|html|xml|... |
||
2079 | * |
||
2080 | * @return string API URL for current record or object/evidence |
||
2081 | */ |
||
2082 | public function getApiURL($format = null) { |
||
2086 | |||
2087 | /** |
||
2088 | * Obtain content type of last response |
||
2089 | * |
||
2090 | * @return string |
||
2091 | */ |
||
2092 | public function getResponseFormat() { |
||
2095 | |||
2096 | /** |
||
2097 | * Return the same response format for one and multiplete results |
||
2098 | * |
||
2099 | * @param array $responseBody |
||
2100 | * |
||
2101 | * @return array |
||
2102 | */ |
||
2103 | public function unifyResponseFormat($responseBody) { |
||
2131 | |||
2132 | /** |
||
2133 | * Obtain structure for current (or given) evidence |
||
2134 | * |
||
2135 | * @param string $evidence |
||
2136 | * |
||
2137 | * @return array Evidence structure |
||
2138 | */ |
||
2139 | public function getOfflineColumnsInfo($evidence = null) { |
||
2147 | |||
2148 | /** |
||
2149 | * Obtain Current evidence Live structure |
||
2150 | * |
||
2151 | * @param string $evidence |
||
2152 | * |
||
2153 | * @return array structure |
||
2154 | */ |
||
2155 | public function getOnlineColumnsInfo($evidence = null) { |
||
2175 | |||
2176 | /** |
||
2177 | * Update evidence info from array or online from properties.json or offline |
||
2178 | * |
||
2179 | * @param array $columnsInfo |
||
2180 | * @param string $evidence |
||
2181 | */ |
||
2182 | public function updateColumnsInfo($columnsInfo = null, $evidence = null) { |
||
2190 | |||
2191 | /** |
||
2192 | * Gives you evidence structure. You can obtain current online by pre-calling: |
||
2193 | * $this->updateColumnsInfo($evidence, $this->getOnlineColumnsInfo($evidence)); |
||
2194 | * |
||
2195 | * @param string $evidence |
||
2196 | * |
||
2197 | * @return array |
||
2198 | */ |
||
2199 | public function getColumnsInfo($evidence = null) { |
||
2207 | |||
2208 | /** |
||
2209 | * Gives you properties for (current) evidence column |
||
2210 | * |
||
2211 | * @param string $column name of column |
||
2212 | * @param string $evidence evidence name if different |
||
2213 | * |
||
2214 | * @return array column properties or null if column not exits |
||
2215 | */ |
||
2216 | public function getColumnInfo($column, $evidence = null) { |
||
2220 | |||
2221 | /** |
||
2222 | * Obtain actions for current (or given) evidence |
||
2223 | * |
||
2224 | * @param string $evidence |
||
2225 | * |
||
2226 | * @return array Evidence structure |
||
2227 | */ |
||
2228 | public function getActionsInfo($evidence = null) { |
||
2239 | |||
2240 | /** |
||
2241 | * Obtain relations for current (or given) evidence |
||
2242 | * |
||
2243 | * @param string $evidence |
||
2244 | * |
||
2245 | * @return array Evidence structure |
||
2246 | */ |
||
2247 | public function getRelationsInfo($evidence = null) { |
||
2258 | |||
2259 | /** |
||
2260 | * Obtain info for current (or given) evidence |
||
2261 | * |
||
2262 | * @param string $evidence |
||
2263 | * |
||
2264 | * @return array Evidence info |
||
2265 | */ |
||
2266 | public function getEvidenceInfo($evidence = null) { |
||
2280 | |||
2281 | /** |
||
2282 | * Obtain name for current (or given) evidence path |
||
2283 | * |
||
2284 | * @param string $evidence Evidence Path |
||
2285 | * |
||
2286 | * @return array Evidence info |
||
2287 | */ |
||
2288 | public function getEvidenceName($evidence = null) { |
||
2298 | |||
2299 | /** |
||
2300 | * Save current object to file |
||
2301 | * |
||
2302 | * @param string $destfile path to file |
||
2303 | */ |
||
2304 | public function saveResponseToFile($destfile) { |
||
2310 | |||
2311 | /** |
||
2312 | * Obtain established relations listing |
||
2313 | * |
||
2314 | * @return array Null or Relations |
||
2315 | */ |
||
2316 | public function getVazby($id = null) { |
||
2329 | |||
2330 | /** |
||
2331 | * Gives You URL for Current Record in FlexiBee web interface |
||
2332 | * |
||
2333 | * @return string url |
||
2334 | */ |
||
2335 | public function getFlexiBeeURL() { |
||
2346 | |||
2347 | /** |
||
2348 | * Set Record Key |
||
2349 | * |
||
2350 | * @param int|string $myKeyValue |
||
2351 | * |
||
2352 | * @return boolean |
||
2353 | */ |
||
2354 | public function setMyKey($myKeyValue) { |
||
2376 | |||
2377 | /** |
||
2378 | * Set or get ignore not found pages flag |
||
2379 | * |
||
2380 | * @param boolean $ignore set flag to |
||
2381 | * |
||
2382 | * @return boolean get flag state |
||
2383 | */ |
||
2384 | public function ignore404($ignore = null) { |
||
2390 | |||
2391 | /** |
||
2392 | * Send Document by mail |
||
2393 | * |
||
2394 | * @url https://www.flexibee.eu/api/dokumentace/ref/odesilani-mailem/ |
||
2395 | * |
||
2396 | * @param string $to Email ecipient |
||
2397 | * @param string $subject Email Subject |
||
2398 | * @param string $body Email Text |
||
2399 | * |
||
2400 | * @return boolean mail sent status |
||
2401 | */ |
||
2402 | public function sendByMail($to, $subject, $body, $cc = null) { |
||
2410 | |||
2411 | /** |
||
2412 | * Send all unsent Documents by eMail |
||
2413 | * |
||
2414 | * @url https://www.flexibee.eu/api/dokumentace/ref/odesilani-mailem/ |
||
2415 | * |
||
2416 | * @return int http response code |
||
2417 | */ |
||
2418 | public function sendUnsent() { |
||
2422 | |||
2423 | /** |
||
2424 | * FlexiBee date to PHP DateTime conversion |
||
2425 | * |
||
2426 | * @param string $flexidate 2017-05-26 or 2017-05-26+02:00 |
||
2427 | * |
||
2428 | * @return \DateTime | false |
||
2429 | */ |
||
2430 | public static function flexiDateToDateTime($flexidate) { |
||
2433 | |||
2434 | /** |
||
2435 | * FlexiBee dateTime to PHP DateTime conversion |
||
2436 | * |
||
2437 | * @param string $flexidatetime 2017-09-26T10:00:53.755+02:00 or older 2017-05-19T00:00:00+02:00 |
||
2438 | * |
||
2439 | * @return \DateTime | false |
||
2440 | */ |
||
2441 | public static function flexiDateTimeToDateTime($flexidatetime) { |
||
2449 | |||
2450 | /** |
||
2451 | * Získá dokument v daném formátu |
||
2452 | * Obtain document in given format |
||
2453 | * |
||
2454 | * @link https://www.flexibee.eu/api/dokumentace/ref/pdf/ PDF Exports |
||
2455 | * |
||
2456 | * @param string $format pdf/csv/xml/json/ ... |
||
2457 | * @param string $reportName Template used to generate PDF |
||
2458 | * @param string $lang cs|sk|en|de Template language used to generate PDF |
||
2459 | * @param boolean $sign sign resulting PDF by certificate ? |
||
2460 | * |
||
2461 | * @return string|null filename downloaded or none |
||
2462 | */ |
||
2463 | public function getInFormat($format, $reportName = null, $lang = null, |
||
2502 | |||
2503 | /** |
||
2504 | * Uloží dokument v daném formátu do složky v systému souborů |
||
2505 | * Save document in given format to directory in filesystem |
||
2506 | * |
||
2507 | * @param string $format pdf/csv/xml/json/ ... |
||
2508 | * @param string $destDir where to put file (prefix) |
||
2509 | * @param string $reportName Template used to generate PDF |
||
2510 | * |
||
2511 | * @return string|null filename downloaded or none |
||
2512 | */ |
||
2513 | public function downloadInFormat($format, $destDir = './', |
||
2528 | |||
2529 | /** |
||
2530 | * Take data for object. separate external IDs |
||
2531 | * |
||
2532 | * @param array $data Data to keep |
||
2533 | * |
||
2534 | * @return int number of records taken |
||
2535 | */ |
||
2536 | public function takeData($data) { |
||
2557 | |||
2558 | /** |
||
2559 | * Get Current Evidence reports listing |
||
2560 | * |
||
2561 | * @link https://www.flexibee.eu/api/dokumentace/casto-kladene-dotazy-pro-api/vyber-reportu-do-pdf/ Výběr reportu do PDF |
||
2562 | * |
||
2563 | * @return array |
||
2564 | */ |
||
2565 | public function getReportsInfo() { |
||
2579 | |||
2580 | /** |
||
2581 | * Request authSessionId from current server |
||
2582 | * |
||
2583 | * @link https://www.flexibee.eu/api/dokumentace/ref/login/ description |
||
2584 | * |
||
2585 | * @param string $username |
||
2586 | * @param string $password |
||
2587 | * @param string $otp optional onetime password |
||
2588 | * |
||
2589 | * @return string authUserId or null in case of problems |
||
2590 | */ |
||
2591 | public function requestAuthSessionID($username, $password, $otp = null) { |
||
2604 | |||
2605 | /** |
||
2606 | * Try to Sign in current user to FlexiBee and keep authSessionId |
||
2607 | * |
||
2608 | * @return boolean sign in success |
||
2609 | */ |
||
2610 | public function login() { |
||
2615 | |||
2616 | /** |
||
2617 | * End (current's user) session |
||
2618 | * |
||
2619 | * |
||
2620 | * @link https://www.flexibee.eu/api/dokumentace/ref/logout Logout Reference |
||
2621 | * |
||
2622 | * @param string $username force username to sign off |
||
2623 | * |
||
2624 | * @return array server response |
||
2625 | */ |
||
2626 | public function logout($username = null) { |
||
2629 | |||
2630 | /** |
||
2631 | * Compile and send Report about Error500 to FlexiBee developers |
||
2632 | * If FlexiBee is running on localost try also include java backtrace |
||
2633 | * |
||
2634 | * @param array $errorResponse result of parseError(); |
||
2635 | */ |
||
2636 | public function error500Reporter($errorResponse) { |
||
2700 | |||
2701 | /** |
||
2702 | * Returns code:CODE |
||
2703 | * |
||
2704 | * @param string $code |
||
2705 | * |
||
2706 | * @return string |
||
2707 | */ |
||
2708 | public static function code($code) { |
||
2711 | |||
2712 | /** |
||
2713 | * Returns CODE without code: prefix |
||
2714 | * |
||
2715 | * @param string $code |
||
2716 | * |
||
2717 | * @return string |
||
2718 | */ |
||
2719 | public static function uncode($code) { |
||
2722 | |||
2723 | /** |
||
2724 | * Remove all @ items from array |
||
2725 | * |
||
2726 | * @param array $data original data |
||
2727 | * |
||
2728 | * @return array data without @ columns |
||
2729 | */ |
||
2730 | public static function arrayCleanUP($data) { |
||
2737 | |||
2738 | /** |
||
2739 | * Add Info about used user, server and libraries |
||
2740 | * |
||
2741 | * @param string $prefix banner prefix text |
||
2742 | * @param string $suffix banner suffix text |
||
2743 | */ |
||
2744 | public function logBanner($prefix = null, $suffix = null) { |
||
2751 | |||
2752 | /** |
||
2753 | * Get Last operation type |
||
2754 | * |
||
2755 | * @return string create|read|update|delete or update,insert for some inserted and updated in one transaction |
||
2756 | */ |
||
2757 | public function getLastOperationType() { |
||
2760 | |||
2761 | /** |
||
2762 | * Last operation errors |
||
2763 | * |
||
2764 | * @return array FlexiBee error meassages |
||
2765 | */ |
||
2766 | public function getErrors() { |
||
2769 | |||
2770 | /** |
||
2771 | * Reconnect After unserialization |
||
2772 | */ |
||
2773 | public function __wakeup() { |
||
2776 | |||
2777 | } |
||
2778 |
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.