1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the skidata-library package. |
5
|
|
|
* |
6
|
|
|
* (c) 2017 WEBEWEB |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace WBW\Library\SkiData\Parser; |
13
|
|
|
|
14
|
|
|
use WBW\Library\Core\Helper\Argument\BooleanHelper; |
15
|
|
|
use WBW\Library\SkiData\Entity\SkiDataCard; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* SkiData card parser. |
19
|
|
|
* |
20
|
|
|
* @author webeweb <https://github.com/webeweb/> |
21
|
|
|
* @package WBW\Library\SkiData\Parser |
22
|
|
|
*/ |
23
|
|
|
class SkiDataCardParser extends AbstractSkiDataParser { |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Constructor. |
27
|
|
|
*/ |
28
|
|
|
public function __construct() { |
29
|
|
|
parent::__construct(); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Parse a SkiData card entity. |
34
|
|
|
* |
35
|
|
|
* @param SkiDataCard $entity The SkiData card entity. |
36
|
|
|
* @return string Returns the parsed SkiData card entity. |
37
|
|
|
*/ |
38
|
|
|
public function parseEntity(SkiDataCard $entity) { |
39
|
|
|
|
40
|
|
|
// Initialise the output. |
41
|
|
|
$output = []; |
42
|
|
|
|
43
|
|
|
$output[] = $this->encodeString($entity->getTicketNumber(), 23); |
44
|
|
|
$output[] = $this->encodeInteger($entity->getUserNumber(), 9); |
45
|
|
|
$output[] = $this->encodeInteger($entity->getArticleNumber(), 3); |
46
|
|
|
$output[] = $this->encodeDate($entity->getValidFrom()); |
47
|
|
|
$output[] = $this->encodeDate($entity->getExpires()); |
48
|
|
|
$output[] = $this->encodeBoolean($entity->getBlocked()); |
49
|
|
|
$output[] = $this->encodeDate($entity->getBlockedDate()); |
50
|
|
|
$output[] = $this->encodeInteger($entity->getProductionState(), 1); |
51
|
|
|
$output[] = $this->encodeInteger($entity->getReasonProduction(), 1); |
52
|
|
|
$output[] = $this->encodeInteger($entity->getProductionCounter(), 4); |
53
|
|
|
$output[] = $this->encodeBoolean($entity->getNeutral()); |
54
|
|
|
$output[] = $this->encodeBoolean($entity->getRetainTicketEntry()); |
55
|
|
|
$output[] = $this->encodeBoolean($entity->getEntryBarrierClosed()); |
56
|
|
|
$output[] = $this->encodeBoolean($entity->getExitBarrierClosed()); |
57
|
|
|
$output[] = $this->encodeBoolean($entity->getRetainTicketExit()); |
58
|
|
|
$output[] = $this->encodeBoolean($entity->getDisplayText()); |
59
|
|
|
$output[] = $this->encodeString($entity->getDisplayText1(), 16); |
60
|
|
|
$output[] = $this->encodeString($entity->getDisplayText2(), 16); |
61
|
|
|
$output[] = $this->encodeInteger($entity->getPersonnalNo(), 4); |
62
|
|
|
$output[] = $this->encodeInteger($entity->getResidualValue(), 12); |
63
|
|
|
$output[] = $this->encodeString($entity->getSerialNumberKeyCardSwatch(), 20); |
64
|
|
|
$output[] = $this->encodeString($entity->getCurrencyResidualValue(), 3); |
65
|
|
|
$output[] = $this->encodeInteger($entity->getTicketType(), 1); |
66
|
|
|
$output[] = $this->encodeString($entity->getTicketSubType(), 5); |
67
|
|
|
$output[] = $this->encodeString($entity->getSerialNo(), 30); |
68
|
|
|
$output[] = $this->encodeDate($entity->getSuspendPeriodFrom()); |
69
|
|
|
$output[] = $this->encodeDate($entity->getSuspendPeriodUntil()); |
70
|
|
|
$output[] = $this->encodeBoolean($entity->getUseValidCarParks()); |
71
|
|
|
$output[] = $this->encodeInteger($entity->getProductionFacilityNumber(), 7); |
72
|
|
|
|
73
|
|
|
// Return the output. |
74
|
|
|
return implode(";", $output); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Parse a line. |
79
|
|
|
* |
80
|
|
|
* @param string $line The line. |
81
|
|
|
* @return SkiDataCard Returns a SkiData card entity. |
82
|
|
|
*/ |
83
|
|
|
public function parseLine($line) { |
84
|
|
|
|
85
|
|
|
// Split the line. |
86
|
|
|
$data = explode(";", $line); |
87
|
|
|
$i = 0; |
88
|
|
|
|
89
|
|
|
// Initialize the entity. |
90
|
|
|
$entity = new SkiDataCard(); |
91
|
|
|
|
92
|
|
|
$entity->setTicketNumber($this->decodeString($data[$i++])); |
93
|
|
|
$entity->setUserNumber($this->decodeInteger($data[$i++])); |
94
|
|
|
$entity->setArticleNumber($this->decodeInteger($data[$i++])); |
95
|
|
|
$entity->setValidFrom($this->decodeDate($data[$i++])); |
96
|
|
|
$entity->setExpires($this->decodeDate($data[$i++])); |
97
|
|
|
$entity->setBlocked(BooleanHelper::parseString($data[$i++])); |
98
|
|
|
$entity->setBlockedDate($this->decodeDate($data[$i++])); |
99
|
|
|
$entity->setProductionState($this->decodeInteger($data[$i++])); |
100
|
|
|
$entity->setReasonProduction($this->decodeInteger($data[$i++])); |
101
|
|
|
$entity->setProductionCounter($this->decodeInteger($data[$i++])); |
102
|
|
|
$entity->setNeutral(BooleanHelper::parseString($data[$i++])); |
103
|
|
|
$entity->setRetainTicketEntry(BooleanHelper::parseString($data[$i++])); |
104
|
|
|
$entity->setEntryBarrierClosed(BooleanHelper::parseString($data[$i++])); |
105
|
|
|
$entity->setExitBarrierClosed(BooleanHelper::parseString($data[$i++])); |
106
|
|
|
$entity->setRetainTicketExit(BooleanHelper::parseString($data[$i++])); |
107
|
|
|
$entity->setDisplayText(BooleanHelper::parseString($data[$i++])); |
108
|
|
|
$entity->setDisplayText1($this->decodeString($data[$i++])); |
109
|
|
|
$entity->setDisplayText2($this->decodeString($data[$i++])); |
110
|
|
|
$entity->setPersonnalNo($this->decodeInteger($data[$i++])); |
111
|
|
|
$entity->setResidualValue($this->decodeInteger($data[$i++])); |
112
|
|
|
$entity->setSerialNumberKeyCardSwatch($this->decodeString($data[$i++])); |
113
|
|
|
$entity->setCurrencyResidualValue($this->decodeString($data[$i++])); |
114
|
|
|
$entity->setTicketType($this->decodeInteger($data[$i++])); |
115
|
|
|
$entity->setTicketSubType($this->decodeString($data[$i++])); |
116
|
|
|
$entity->setSerialNo($this->decodeString($data[$i++])); |
117
|
|
|
$entity->setSuspendPeriodFrom($this->decodeDate($data[$i++])); |
118
|
|
|
$entity->setSuspendPeriodUntil($this->decodeDate($data[$i++])); |
119
|
|
|
$entity->setUseValidCarParks(BooleanHelper::parseString($data[$i++])); |
120
|
|
|
$entity->setProductionFacilityNumber($this->decodeInteger($data[$i++])); |
121
|
|
|
|
122
|
|
|
// Return the entity. |
123
|
|
|
return $entity; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
} |
127
|
|
|
|