1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* |
5
|
|
|
* The MIT License (MIT) |
6
|
|
|
* |
7
|
|
|
* Copyright (c) 2024 Daniel Popiniuc |
8
|
|
|
* |
9
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
10
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
11
|
|
|
* in the Software without restriction, including without limitation the rights |
12
|
|
|
* to use, copy, modify, merge, publish, distribute, sub-license, and/or sell |
13
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
14
|
|
|
* furnished to do so, subject to the following conditions: |
15
|
|
|
* |
16
|
|
|
* The above copyright notice and this permission notice shall be included in all |
17
|
|
|
* copies or substantial portions of the Software. |
18
|
|
|
* |
19
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
20
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
21
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
22
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
23
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
24
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
25
|
|
|
* SOFTWARE. |
26
|
|
|
* |
27
|
|
|
*/ |
28
|
|
|
|
29
|
|
|
namespace danielgp\efactura; |
30
|
|
|
|
31
|
|
|
class ElectronicInvoiceComments |
32
|
|
|
{ |
33
|
|
|
|
34
|
|
|
use TraitVersions; |
|
|
|
|
35
|
|
|
|
36
|
|
|
public function getCommentsIntoArrayForTable() |
37
|
|
|
{ |
38
|
|
|
$arrayCommentsRaw = $this->getCommentsFromFileAsArray(); |
39
|
|
|
$arrayCommentsForTable = []; |
40
|
|
|
$arrayMapping = [ |
41
|
|
|
'BG-' => 'Group', |
42
|
|
|
'BT-' => 'Field', |
43
|
|
|
]; |
44
|
|
|
foreach ($arrayCommentsRaw as $key => $value) { |
45
|
|
|
$strKeyPrefix = substr($key, 0, 3); |
46
|
|
|
$strIdType = (in_array($strKeyPrefix, array_keys($arrayMapping)) ? $arrayMapping[$strKeyPrefix] : '?'); |
47
|
|
|
$arrayTemp = [ |
48
|
|
|
'ID' => $key, |
49
|
|
|
'IT_Type' => $strIdType, |
50
|
|
|
'Level' => $value['Level'], |
51
|
|
|
'Cardinality' => $value['Cardinality'], |
52
|
|
|
'OperationalTerm_EN' => $this->getKeyFromArrayOrAlternative('en_US', $value['OperationalTerm'], '-'), |
53
|
|
|
'OperationalTerm_RO' => $this->getKeyFromArrayOrAlternative('ro_RO', $value['OperationalTerm'], '-'), |
54
|
|
|
'Description_EN' => $this->getKeyFromArrayOrAlternative('en_US', $value['Description'], '-'), |
55
|
|
|
'Description_RO' => $this->getKeyFromArrayOrAlternative('ro_RO', $value['Description'], '-'), |
56
|
|
|
'UsageNote_EN' => $this->getKeyFromArrayOrAlternative('en_US', $value['UsageNote'], $value, '-'), |
|
|
|
|
57
|
|
|
'UsageNote_RO' => $this->getKeyFromArrayOrAlternative('ro_RO', $value['UsageNote'], $value, '-'), |
58
|
|
|
'RequirementID' => $value['RequirementID'], |
59
|
|
|
'SemanticDataType' => $this->getKeyFromArrayOrAlternative('SemanticDataType', $value, '-'), |
60
|
|
|
]; |
61
|
|
|
if (is_array($value['HierarchycalTagName'])) { |
62
|
|
|
foreach ($value['HierarchycalTagName'] as $value2) { |
63
|
|
|
$arrayCommentsForTable[] = array_merge(['Tag' => $value2], $arrayTemp); |
64
|
|
|
} |
65
|
|
|
} else { |
66
|
|
|
$arrayCommentsForTable[] = array_merge(['Tag' => $value['HierarchycalTagName']], $arrayTemp); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
return $arrayCommentsForTable; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function getCommentsIntoArrayForVerifications() |
73
|
|
|
{ |
74
|
|
|
$arrayCommentsRaw = $this->getCommentsFromFileAsArray(); |
75
|
|
|
$arrayCommentsForTable = []; |
76
|
|
|
foreach ($arrayCommentsRaw as $key => $value) { |
77
|
|
|
if (array_key_exists('SemanticDataType', $value)) { |
78
|
|
|
$arrayCommentsForTable[$value['SemanticDataType']] = [ |
79
|
|
|
'ID' => $key, |
80
|
|
|
]; |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
return $arrayCommentsForTable; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function getKeyFromArrayOrAlternative(string $strKey, array $arrayIn, string $strAlternative): string |
87
|
|
|
{ |
88
|
|
|
$strToReturn = $strAlternative; |
89
|
|
|
if (array_key_exists($strKey, $arrayIn)) { |
90
|
|
|
$strToReturn = $arrayIn[$strKey]; |
91
|
|
|
} |
92
|
|
|
return $strToReturn; |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|