refactor: move buspro XML protocol into XmlChannel
This commit is contained in:
1 parent
3c81c79819
commit
0a55544ca8
6 files changed
+348
-281
No files matched your search
@@ -37,7 +37,7 @@ class XmlDumpReader
|
||||
return [];
|
||||
}
|
||||
|
||||
$pattern = '/^'.preg_quote($requestId, '/').'(_\d+)?_(request|response)\.xml$/';
|
||||
$pattern = '/^'.preg_quote($requestId, '/').'(_\d+)?_('.XmlDumpWriter::REQUEST.'|'.XmlDumpWriter::RESPONSE.')\.xml$/';
|
||||
$matches = [];
|
||||
|
||||
foreach ($this->xmlDump->listContents('.') as $item) {
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use League\Flysystem\FilesystemException;
|
||||
use League\Flysystem\FilesystemOperator;
|
||||
|
||||
/**
|
||||
* Writes the XML dumps of BusProNet API communication that XmlDumpReader finds and reads.
|
||||
*/
|
||||
class XmlDumpWriter
|
||||
{
|
||||
public const REQUEST = 'request';
|
||||
public const RESPONSE = 'response';
|
||||
|
||||
public function __construct(
|
||||
private readonly FilesystemOperator $xmlDump,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* A dump is a diagnostic aid, so failing to write one never fails the request it records.
|
||||
*
|
||||
* @param self::REQUEST|self::RESPONSE $direction
|
||||
*/
|
||||
public function write(string $requestId, string $direction, string $body): void
|
||||
{
|
||||
try {
|
||||
$this->xmlDump->write($requestId.'_'.$direction.'.xml', $body);
|
||||
} catch (FilesystemException) {
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user