1
|
|
|
<?php |
|
|
|
|
2
|
|
|
|
3
|
|
|
namespace FlexiPeeHP; |
4
|
|
|
|
5
|
|
|
define('EASE_APPNAME', 'FlexiPeehUP'); |
6
|
|
|
define('EASE_LOGGER', 'console|syslog'); |
7
|
|
|
|
8
|
|
|
require_once '../testing/bootstrap.php'; |
9
|
|
|
|
10
|
|
|
$outFile = 'Properties.php'; |
11
|
|
|
$ok = 0; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Obtain structure for given evidence |
15
|
|
|
* |
16
|
|
|
* @param string $evidence |
17
|
|
|
* @param FlexiBeeRO $syncer Class to read from FlexiBee |
18
|
|
|
* @return array Evidence structure |
19
|
|
|
*/ |
20
|
|
|
function getPropertiesInfo($evidence, FlexiBeeRO $syncer) |
21
|
|
|
{ |
22
|
|
|
$properties = []; |
23
|
|
|
$flexinfo = $syncer->performRequest($evidence.'/properties.json'); |
24
|
|
|
if (count($flexinfo) && array_key_exists('properties', $flexinfo)) { |
25
|
|
|
foreach ($flexinfo['properties']['property'] as $evidenceProperty) { |
26
|
|
|
$key = $evidenceProperty['propertyName']; |
27
|
|
|
$properties[$key] = $evidenceProperty; |
28
|
|
|
$properties[$key]['name'] = $evidenceProperty['name']; |
29
|
|
|
$properties[$key]['type'] = $evidenceProperty['type']; |
30
|
|
|
} |
31
|
|
|
} |
32
|
|
|
return $properties; |
33
|
|
|
} |
34
|
|
|
$evidenceProps = '<?php |
35
|
|
|
/** |
36
|
|
|
* FlexiPeeHP - Evidence Properties. |
37
|
|
|
* |
38
|
|
|
* @author Vítězslav Dvořák <[email protected]> |
39
|
|
|
* @copyright (C) 2015-2017 Spoje.Net |
40
|
|
|
*/ |
41
|
|
|
|
42
|
|
|
namespace FlexiPeeHP; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Evidence Properties |
46
|
|
|
* |
47
|
|
|
* @link https://demo.flexibee.eu/c/demo/evidence-list.json vlastnosti evidence |
48
|
|
|
*/ |
49
|
|
|
|
50
|
|
|
class Properties |
51
|
|
|
{ |
52
|
|
|
'; |
53
|
|
|
|
54
|
|
|
$statuser = new Status(); |
55
|
|
|
|
56
|
|
|
|
57
|
|
|
$syncer = new FlexiBeeRO(); |
58
|
|
|
$syncer->setObjectName('FlexiBee Evidence Properties'); |
59
|
|
|
$syncer->addStatusMessage('Updating Evidences Properties'); |
60
|
|
|
|
61
|
|
|
$pos = 0; |
62
|
|
|
foreach (EvidenceList::$name as $evidencePath => $evidenceName) { |
63
|
|
|
$pos++; |
64
|
|
|
if ($evidencePath == 'nastaveni') { |
65
|
|
|
$info = json_decode(file_get_contents('nastaveni-properties.json'), |
66
|
|
|
true); |
67
|
|
|
$structure = $info['properties']['property']; |
68
|
|
|
} else { |
69
|
|
|
$structure = getPropertiesInfo($evidencePath, $syncer); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
if (count($structure)) { |
73
|
|
|
$syncer->addStatusMessage($pos.' of '.count(EvidenceList::$name).' '.$evidencePath.': structure obtained', |
74
|
|
|
'success'); |
75
|
|
|
$ok++; |
76
|
|
|
} else { |
77
|
|
|
$syncer->addStatusMessage($pos.' of '.count(EvidenceList::$name).' '.$evidencePath.': structure problem', |
78
|
|
|
'error'); |
79
|
|
|
} |
80
|
|
|
file_put_contents('Properties.'.$evidencePath.'.json', |
81
|
|
|
json_encode($structure)); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
$syncer->addStatusMessage('Updating of '.$ok.' Evidences Properties done', |
85
|
|
|
'success'); |
86
|
|
|
|
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.