-
-
Notifications
You must be signed in to change notification settings - Fork 3
Fix: Correct updateInPohoda behavior and add test #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
e977cee
ee4f620
f3d011d
595020a
734a309
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -81,120 +81,70 @@ public function __construct(Client $caller) | |||||||||||||||||||||||||||||||||||||||||||||||
| public function useCaller(Client $caller): void | ||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||
| $this->caller = $caller; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| if ($caller->lastCurlResponse) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| $parsed = $this->parse($this->caller->lastCurlResponse, []); | ||||||||||||||||||||||||||||||||||||||||||||||||
| $this->processResponsePack($parsed['responsePack']); | ||||||||||||||||||||||||||||||||||||||||||||||||
| $this->rawXML = $this->caller->lastCurlResponse; | ||||||||||||||||||||||||||||||||||||||||||||||||
| $this->rawXML = $caller->lastCurlResponse; | ||||||||||||||||||||||||||||||||||||||||||||||||
| $xml = simplexml_load_string($this->rawXML); | ||||||||||||||||||||||||||||||||||||||||||||||||
| if ($xml) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| $this->state = (string) $xml->attributes('rsp', true)->state; | ||||||||||||||||||||||||||||||||||||||||||||||||
| $this->note = (string) $xml->attributes('rsp', true)->note; | ||||||||||||||||||||||||||||||||||||||||||||||||
| foreach ($xml->children('rsp', true) as $responsePackItem) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| $this->processResponsePackItem($responsePackItem); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
Vitexus marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| $this->state = 'error'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| $this->note = $caller->lastCurlError; | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| public function processResponsePack($responsePackData): void | ||||||||||||||||||||||||||||||||||||||||||||||||
| public function processResponsePack(\SimpleXMLElement $responsePackData): void | ||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||
| if (\array_key_exists('rsp:responsePackItem', $responsePackData)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| $this->processResponsePackItem($responsePackData['rsp:responsePackItem']); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| $this->state = isset($responsePackData['@state']) ? (string) $responsePackData['@state'] : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
| $this->note = $responsePackData['@note'] ?? ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| // This method is no longer used | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
| public function processResponsePack(\SimpleXMLElement $responsePackData): void | |
| { | |
| if (\array_key_exists('rsp:responsePackItem', $responsePackData)) { | |
| $this->processResponsePackItem($responsePackData['rsp:responsePackItem']); | |
| } else { | |
| $this->state = isset($responsePackData['@state']) ? (string) $responsePackData['@state'] : ''; | |
| $this->note = $responsePackData['@note'] ?? ''; | |
| } | |
| // This method is no longer used | |
| } | |
| public function processResponsePack(\SimpleXMLElement $responsePackData): void | |
| { | |
| $attrs = $responsePackData->attributes(); | |
| if (isset($attrs['state'])) { | |
| $this->state = (string) $attrs['state']; | |
| } | |
| if (isset($attrs['note'])) { | |
| $this->note = (string) $attrs['note']; | |
| } | |
| foreach ($responsePackData->children() as $item) { | |
| $this->processResponsePackItem($item); | |
| } | |
| } |
🧰 Tools
🪛 PHPMD (2.15.0)
100-100: Avoid unused parameters such as '$responsePackData'. (undefined)
(UnusedFormalParameter)
🤖 Prompt for AI Agents
In src/mServer/Response.php around lines 100–104, implement processResponsePack
to read the 'state' and 'note' attributes from the passed SimpleXMLElement and
assign them to $this->state and $this->note (cast to string to avoid unused
param warning), then iterate the child item elements (foreach
($responsePackData->item as $item)) and delegate each to the existing
item-processing method (e.g. $this->processResponse($item) or the appropriate
processResponseItem method used elsewhere) so the pack updates state/note and
processes all items.
Uh oh!
There was an error while loading. Please reload this page.