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
|
|
|
function evidenceToClass($evidence) |
11
|
|
|
{ |
12
|
|
|
return str_replace(' ', '', ucwords(str_replace('-', ' ', $evidence))); |
13
|
|
|
} |
14
|
|
|
$outFile = 'Properties.php'; |
15
|
|
|
$ok = 0; |
16
|
|
|
|
17
|
|
|
$evidenceProps = '<?php |
18
|
|
|
/** |
19
|
|
|
* FlexiPeeHP - Evidence Properties. |
20
|
|
|
* |
21
|
|
|
* @author Vítězslav Dvořák <[email protected]> |
22
|
|
|
* @copyright (C) 2015-'.date('Y').' Spoje.Net |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
namespace FlexiPeeHP; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Evidence Properties |
29
|
|
|
* |
30
|
|
|
* @link https://demo.flexibee.eu/c/demo/evidence-list.json vlastnosti evidence |
31
|
|
|
*/ |
32
|
|
|
|
33
|
|
|
class Properties |
34
|
|
|
{ |
35
|
|
|
'; |
36
|
|
|
|
37
|
|
|
$statuser = new Status(); |
38
|
|
|
|
39
|
|
|
|
40
|
|
|
$syncer = new FlexiBeeRO(); |
41
|
|
|
$syncer->setObjectName('FlexiBee Evidence Properties'); |
42
|
|
|
$syncer->addStatusMessage('Updating Evidences Properties'); |
43
|
|
|
|
44
|
|
|
$pos = 0; |
45
|
|
|
foreach (EvidenceList::$name as $evidencePath => $evidenceName) { |
46
|
|
|
$pos++; |
47
|
|
|
if ($evidencePath == 'nastaveni') { |
48
|
|
|
$info = json_decode(file_get_contents('nastaveni-properties.json'), |
49
|
|
|
true); |
50
|
|
|
$structure = $info['properties']['property']; |
51
|
|
|
} else { |
52
|
|
|
$structure = $syncer->getOnlineColumnsInfo($evidencePath); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
if (count($structure)) { |
56
|
|
|
$syncer->addStatusMessage($pos.' of '.count(EvidenceList::$name).' '.$evidencePath.': structure obtained', |
57
|
|
|
'success'); |
58
|
|
|
$ok++; |
59
|
|
|
} else { |
60
|
|
|
$syncer->addStatusMessage($pos.' of '.count(EvidenceList::$name).' '.$evidencePath.': structure problem', |
61
|
|
|
'error'); |
62
|
|
|
} |
63
|
|
|
file_put_contents('Properties.'.$evidencePath.'.json', |
64
|
|
|
json_encode($structure)); |
65
|
|
|
|
66
|
|
|
$evidenceClass = evidenceToClass($evidencePath); |
67
|
|
|
$evidenceClassFile = '../src/FlexiPeeHP/'.$evidenceClass.'.php'; |
68
|
|
|
if (file_exists($evidenceClassFile)) { |
69
|
|
|
$evidenceClassBody = file_get_contents($evidenceClassFile); |
70
|
|
|
|
71
|
|
|
if (array_key_exists('firma', $structure)) { |
72
|
|
|
if (!strstr($evidenceClassBody, 'use Firma;')) { |
73
|
|
|
$syncer->addStatusMessage(sprintf('use Firma; not found in %s ', |
74
|
|
|
$evidenceClassFile), 'warning'); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
if (array_key_exists('stitky', $structure)) { |
79
|
|
|
if (!strstr($evidenceClassBody, 'use Stitky;')) { |
80
|
|
|
$syncer->addStatusMessage(sprintf('use Stitky; not found in %s ', |
81
|
|
|
$evidenceClassFile), 'warning'); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
$syncer->addStatusMessage('Updating of '.$ok.' Evidences Properties done', |
88
|
|
|
'success'); |
89
|
|
|
|
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.