1 | <?php |
||
42 | trait MessageBuilderTrait |
||
43 | { |
||
44 | /** |
||
45 | * @param string $messagePrefix |
||
46 | * @param EveApiReadWriteInterface $data |
||
47 | * |
||
48 | * @return string |
||
49 | * @throws \LogicException |
||
50 | */ |
||
51 | 39 | protected function createEveApiMessage(string $messagePrefix, EveApiReadWriteInterface $data): string |
|
52 | { |
||
53 | 39 | $mess = $messagePrefix . ' Eve API %1$s/%2$s'; |
|
54 | 39 | $subs = [lcfirst($data->getEveApiSectionName()), $data->getEveApiName()]; |
|
55 | 39 | if ($data->hasEveApiArgument('keyID')) { |
|
56 | $mess .= ' for keyID = %3$s'; |
||
57 | $subs[] = $data->getEveApiArgument('keyID'); |
||
58 | if ($data->hasEveApiArgument('characterID')) { |
||
59 | $mess .= ' and characterID = %4$s'; |
||
60 | $subs[] = $data->getEveApiArgument('characterID'); |
||
61 | } elseif ($data->hasEveApiArgument('corporationID')) { |
||
62 | $mess .= ' and corporationID = %4$s'; |
||
63 | $subs[] = $data->getEveApiArgument('corporationID'); |
||
64 | } |
||
65 | } |
||
66 | 39 | return vsprintf($mess, $subs); |
|
67 | } |
||
68 | /** |
||
69 | * @param string $messagePrefix |
||
70 | * @param EveApiReadWriteInterface $data |
||
71 | * @param string $eventName |
||
72 | * |
||
73 | * @return string |
||
74 | * @throws \LogicException |
||
75 | */ |
||
76 | 39 | protected function createEventMessage( |
|
77 | string $messagePrefix, |
||
78 | EveApiReadWriteInterface $data, |
||
79 | string $eventName |
||
80 | ): string { |
||
81 | 39 | $messagePrefix .= sprintf(' the %s event while processing', $eventName); |
|
82 | 39 | return $this->createEveApiMessage($messagePrefix, $data); |
|
83 | } |
||
84 | /** |
||
85 | * @param EveApiReadWriteInterface $data |
||
86 | * @param string $eventName |
||
87 | * |
||
88 | * @return string |
||
89 | * @throws \LogicException |
||
90 | */ |
||
91 | 4 | protected function getEmittingEventMessage(EveApiReadWriteInterface $data, string $eventName): string |
|
92 | { |
||
93 | 4 | $messagePrefix = 'Emitting'; |
|
94 | 4 | return $this->createEventMessage($messagePrefix, $data, $eventName); |
|
95 | } |
||
96 | /** |
||
97 | * @param EveApiReadWriteInterface $data |
||
98 | * @param string $eventName |
||
99 | * |
||
100 | * @return string |
||
101 | * @throws \LogicException |
||
102 | */ |
||
103 | protected function getEmptyXmlDataMessage(EveApiReadWriteInterface $data, string $eventName): string |
||
108 | /** |
||
109 | * @param EveApiReadWriteInterface $data |
||
110 | * @param string $fileName |
||
111 | * |
||
112 | * @return string |
||
113 | * @throws \LogicException |
||
114 | */ |
||
115 | protected function getFailedToWriteFileMessage( |
||
122 | /** |
||
123 | * @param EveApiReadWriteInterface $data |
||
124 | * @param string $eventName |
||
125 | * |
||
126 | * @return string |
||
127 | * @throws \LogicException |
||
128 | */ |
||
129 | protected function getFinishedEventMessage(EveApiReadWriteInterface $data, string $eventName): string |
||
134 | /** |
||
135 | * @param EveApiReadWriteInterface $data |
||
136 | * @param string $eventName |
||
137 | * |
||
138 | * @return string |
||
139 | * @throws \LogicException |
||
140 | */ |
||
141 | 4 | protected function getNonHandledEventMessage(EveApiReadWriteInterface $data, string $eventName): string |
|
146 | /** |
||
147 | * @param EveApiReadWriteInterface $data |
||
148 | * @param string $eventName |
||
149 | * @param string $location |
||
150 | * |
||
151 | * @return string |
||
152 | * @throws \LogicException |
||
153 | */ |
||
154 | 39 | protected function getReceivedEventMessage( |
|
162 | /** |
||
163 | * @param EveApiReadWriteInterface $data |
||
164 | * @param string $eventName |
||
165 | * |
||
166 | * @return string |
||
167 | * @throws \LogicException |
||
168 | */ |
||
169 | protected function getSufficientlyHandledEventMessage(EveApiReadWriteInterface $data, string $eventName): string |
||
174 | /** |
||
175 | * @param EveApiReadWriteInterface $data |
||
176 | * @param string $eventName |
||
177 | * |
||
178 | * @return string |
||
179 | * @throws \LogicException |
||
180 | */ |
||
181 | protected function getWasHandledEventMessage(EveApiReadWriteInterface $data, string $eventName): string |
||
186 | } |
||
187 |