Skip to content

Commit 2d9550d

Browse files
committed
[REF] cleanup & reformat
1 parent f94710b commit 2d9550d

14 files changed

Lines changed: 172 additions & 145 deletions

src/Client/ManagedClient.php

Lines changed: 44 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@
44

55
namespace Gianfriaur\OpcuaSessionManager\Client;
66

7+
use DateTimeImmutable;
78
use Gianfriaur\OpcuaPhpClient\Exception\ConnectionException;
89
use Gianfriaur\OpcuaPhpClient\Exception\ServiceException;
910
use Gianfriaur\OpcuaPhpClient\OpcUaClientInterface;
1011
use Gianfriaur\OpcuaPhpClient\Security\SecurityMode;
1112
use Gianfriaur\OpcuaPhpClient\Security\SecurityPolicy;
1213
use Gianfriaur\OpcuaPhpClient\Types\BrowseDirection;
13-
use Gianfriaur\OpcuaPhpClient\Types\BrowseNode;
1414
use Gianfriaur\OpcuaPhpClient\Types\BuiltinType;
1515
use Gianfriaur\OpcuaPhpClient\Types\ConnectionState;
1616
use Gianfriaur\OpcuaPhpClient\Types\DataValue;
1717
use Gianfriaur\OpcuaPhpClient\Types\NodeId;
18-
use Gianfriaur\OpcuaPhpClient\Types\QualifiedName;
1918
use Gianfriaur\OpcuaPhpClient\Types\Variant;
2019
use Gianfriaur\OpcuaSessionManager\Exception\DaemonException;
2120
use Gianfriaur\OpcuaSessionManager\Serialization\TypeSerializer;
@@ -32,10 +31,11 @@ class ManagedClient implements OpcUaClientInterface
3231
private int $defaultBrowseMaxDepth = 10;
3332

3433
public function __construct(
35-
private readonly string $socketPath = '/tmp/opcua-session-manager.sock',
36-
private readonly float $timeout = 30.0,
34+
private readonly string $socketPath = '/tmp/opcua-session-manager.sock',
35+
private readonly float $timeout = 30.0,
3736
private readonly ?string $authToken = null,
38-
) {
37+
)
38+
{
3939
$this->serializer = new TypeSerializer();
4040
}
4141

@@ -184,7 +184,7 @@ public function isConnected(): bool
184184
return false;
185185
}
186186

187-
return (bool) $this->query('isConnected', []);
187+
return (bool)$this->query('isConnected', []);
188188
}
189189

190190
public function getConnectionState(): ConnectionState
@@ -211,7 +211,8 @@ public function browse(
211211
?NodeId $referenceTypeId = null,
212212
bool $includeSubtypes = true,
213213
int $nodeClassMask = 0,
214-
): array {
214+
): array
215+
{
215216
$result = $this->query('browse', [
216217
$this->serializer->serializeNodeId($nodeId),
217218
$direction->value,
@@ -232,7 +233,8 @@ public function browseWithContinuation(
232233
?NodeId $referenceTypeId = null,
233234
bool $includeSubtypes = true,
234235
int $nodeClassMask = 0,
235-
): array {
236+
): array
237+
{
236238
$result = $this->query('browseWithContinuation', [
237239
$this->serializer->serializeNodeId($nodeId),
238240
$direction->value,
@@ -269,7 +271,8 @@ public function browseAll(
269271
?NodeId $referenceTypeId = null,
270272
bool $includeSubtypes = true,
271273
int $nodeClassMask = 0,
272-
): array {
274+
): array
275+
{
273276
$result = $this->query('browseAll', [
274277
$this->serializer->serializeNodeId($nodeId),
275278
$direction->value,
@@ -291,7 +294,8 @@ public function browseRecursive(
291294
?NodeId $referenceTypeId = null,
292295
bool $includeSubtypes = true,
293296
int $nodeClassMask = 0,
294-
): array {
297+
): array
298+
{
295299
$result = $this->query('browseRecursive', [
296300
$this->serializer->serializeNodeId($nodeId),
297301
$direction->value,
@@ -404,12 +408,13 @@ public function call(NodeId $objectId, NodeId $methodId, array $inputArguments =
404408

405409
public function createSubscription(
406410
float $publishingInterval = 500.0,
407-
int $lifetimeCount = 2400,
408-
int $maxKeepAliveCount = 10,
409-
int $maxNotificationsPerPublish = 0,
410-
bool $publishingEnabled = true,
411-
int $priority = 0,
412-
): array {
411+
int $lifetimeCount = 2400,
412+
int $maxKeepAliveCount = 10,
413+
int $maxNotificationsPerPublish = 0,
414+
bool $publishingEnabled = true,
415+
int $priority = 0,
416+
): array
417+
{
413418
return $this->query('createSubscription', [
414419
$publishingInterval,
415420
$lifetimeCount,
@@ -435,11 +440,12 @@ public function createMonitoredItems(int $subscriptionId, array $items): array
435440
}
436441

437442
public function createEventMonitoredItem(
438-
int $subscriptionId,
443+
int $subscriptionId,
439444
NodeId $nodeId,
440-
array $selectFields = ['EventId', 'EventType', 'SourceName', 'Time', 'Message', 'Severity'],
441-
int $clientHandle = 1,
442-
): array {
445+
array $selectFields = ['EventId', 'EventType', 'SourceName', 'Time', 'Message', 'Severity'],
446+
int $clientHandle = 1,
447+
): array
448+
{
443449
return $this->query('createEventMonitoredItem', [
444450
$subscriptionId,
445451
$this->serializer->serializeNodeId($nodeId),
@@ -464,12 +470,13 @@ public function publish(array $acknowledgements = []): array
464470
}
465471

466472
public function historyReadRaw(
467-
NodeId $nodeId,
468-
?\DateTimeImmutable $startTime = null,
469-
?\DateTimeImmutable $endTime = null,
470-
int $numValuesPerNode = 0,
471-
bool $returnBounds = false,
472-
): array {
473+
NodeId $nodeId,
474+
?DateTimeImmutable $startTime = null,
475+
?DateTimeImmutable $endTime = null,
476+
int $numValuesPerNode = 0,
477+
bool $returnBounds = false,
478+
): array
479+
{
473480
$result = $this->query('historyReadRaw', [
474481
$this->serializer->serializeNodeId($nodeId),
475482
$startTime?->format('c'),
@@ -485,12 +492,13 @@ public function historyReadRaw(
485492
}
486493

487494
public function historyReadProcessed(
488-
NodeId $nodeId,
489-
\DateTimeImmutable $startTime,
490-
\DateTimeImmutable $endTime,
491-
float $processingInterval,
492-
NodeId $aggregateType,
493-
): array {
495+
NodeId $nodeId,
496+
DateTimeImmutable $startTime,
497+
DateTimeImmutable $endTime,
498+
float $processingInterval,
499+
NodeId $aggregateType,
500+
): array
501+
{
494502
$result = $this->query('historyReadProcessed', [
495503
$this->serializer->serializeNodeId($nodeId),
496504
$startTime->format('c'),
@@ -507,11 +515,12 @@ public function historyReadProcessed(
507515

508516
public function historyReadAtTime(
509517
NodeId $nodeId,
510-
array $timestamps,
511-
): array {
518+
array $timestamps,
519+
): array
520+
{
512521
$result = $this->query('historyReadAtTime', [
513522
$this->serializer->serializeNodeId($nodeId),
514-
array_map(fn(\DateTimeImmutable $ts) => $ts->format('c'), $timestamps),
523+
array_map(fn(DateTimeImmutable $ts) => $ts->format('c'), $timestamps),
515524
]);
516525

517526
return array_map(

src/Client/SocketConnection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static function send(string $socketPath, array $payload, float $timeout =
2525
throw new DaemonException("Cannot connect to daemon: [{$errorCode}] {$errorMessage}");
2626
}
2727

28-
stream_set_timeout($socket, (int) $timeout, (int) (($timeout - (int) $timeout) * 1_000_000));
28+
stream_set_timeout($socket, (int)$timeout, (int)(($timeout - (int)$timeout) * 1_000_000));
2929

3030
$json = json_encode($payload, JSON_THROW_ON_ERROR);
3131
$written = fwrite($socket, $json . "\n");

0 commit comments

Comments
 (0)