1
|
|
|
<?php |
|
|
|
|
2
|
|
|
|
3
|
|
|
namespace FlexiPeeHP; |
4
|
|
|
|
5
|
|
|
require_once '../testing/bootstrap.php'; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Obtain structure for given evidence |
9
|
|
|
* |
10
|
|
|
* @param string $evidence |
11
|
|
|
* @param FlexiBeeRO $syncer Class to read from FlexiBee |
12
|
|
|
* @return array Evidence structure |
13
|
|
|
*/ |
14
|
|
View Code Duplication |
function getPropertiesInfo($evidence, FlexiBeeRO $syncer) |
|
|
|
|
15
|
|
|
{ |
16
|
|
|
$properties = []; |
17
|
|
|
$flexinfo = $syncer->performRequest($evidence.'/properties.json'); |
18
|
|
|
if (count($flexinfo) && array_key_exists('properties', $flexinfo)) { |
19
|
|
|
foreach ($flexinfo['properties']['property'] as $evidenceProperty) { |
20
|
|
|
$key = $evidenceProperty['propertyName']; |
21
|
|
|
$properties[$key] = $evidenceProperty; |
22
|
|
|
$properties[$key]['name'] = $evidenceProperty['name']; |
23
|
|
|
$properties[$key]['type'] = $evidenceProperty['type']; |
24
|
|
|
} |
25
|
|
|
} |
26
|
|
|
return $properties; |
27
|
|
|
} |
28
|
|
|
echo '<?php |
29
|
|
|
/** |
30
|
|
|
* FlexiPeeHP - Struktura evidenci. |
31
|
|
|
* |
32
|
|
|
* @author Vítězslav Dvořák <[email protected]> |
33
|
|
|
* @copyright (C) 2015,2016 Spoje.Net |
34
|
|
|
*/ |
35
|
|
|
|
36
|
|
|
namespace FlexiPeeHP; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Struktura Evidencí |
40
|
|
|
* |
41
|
|
|
* @link https://demo.flexibee.eu/c/demo/evidence-list.json vlastnosti evidence |
42
|
|
|
*/ |
43
|
|
|
|
44
|
|
|
class Structure |
45
|
|
|
{ |
46
|
|
|
'; |
47
|
|
|
|
48
|
|
|
$syncer = new FlexiBeeRO(); |
49
|
|
|
|
50
|
|
|
$pos = 0; |
51
|
|
View Code Duplication |
foreach (EvidenceList::$name as $evidencePath => $evidenceName) { |
|
|
|
|
52
|
|
|
$pos++; |
53
|
|
|
$structure = getPropertiesInfo($evidencePath, $syncer); |
54
|
|
|
if (count($structure)) { |
55
|
|
|
echo ' /** |
56
|
|
|
* Evidence '.$evidencePath.' ('.$evidenceName.') structure. |
57
|
|
|
* |
58
|
|
|
* @var array |
59
|
|
|
*/ |
60
|
|
|
'; |
61
|
|
|
echo ' static public $'.lcfirst(FlexiBeeRO::evidenceToClassName($evidencePath)).' = '.str_replace('http://demo.flexibee.eu/c/demo/', |
62
|
|
|
'', var_export($structure, true)).'; |
63
|
|
|
'; |
64
|
|
|
|
65
|
|
|
$syncer->addStatusMessage($pos.' of '.count(EvidenceList::$name).' '.$evidencePath.': structure obtained', |
66
|
|
|
'success'); |
67
|
|
|
} else { |
68
|
|
|
$syncer->addStatusMessage($pos.' of '.count(EvidenceList::$name).' '.$evidencePath.': structure problem', |
69
|
|
|
'error'); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
echo '} |
74
|
|
|
'; |
75
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.