diff --git a/src/Control.php b/src/Control.php index 657de6a..73ea311 100644 --- a/src/Control.php +++ b/src/Control.php @@ -12,20 +12,20 @@ final class Control { - private Users $users; - private VHosts $vhosts; - private Permissions $permissions; - - private function __construct(Server $server) - { - $this->users = Users::of($server); - $this->vhosts = VHosts::of($server); - $this->permissions = Permissions::of($server); + private function __construct( + private Users $users, + private VHosts $vhosts, + private Permissions $permissions, + ) { } public static function of(Server $server): self { - return new self($server); + return new self( + Users::of($server), + VHosts::of($server), + Permissions::of($server), + ); } public function users(): Users diff --git a/src/Control/Permissions.php b/src/Control/Permissions.php index 1557db4..6cc7081 100644 --- a/src/Control/Permissions.php +++ b/src/Control/Permissions.php @@ -14,18 +14,15 @@ final class Permissions { - private Server $server; - private Command $command; - - private function __construct(Server $server) - { - $this->server = $server; - $this->command = Command::foreground('rabbitmqadmin'); + private function __construct( + private Server $server, + private Command $command, + ) { } public static function of(Server $server): self { - return new self($server); + return new self($server, Command::foreground('rabbitmqadmin')); } /** diff --git a/src/Control/Users.php b/src/Control/Users.php index dc7da88..20cc6c4 100644 --- a/src/Control/Users.php +++ b/src/Control/Users.php @@ -14,18 +14,15 @@ final class Users { - private Server $server; - private Command $command; - - private function __construct(Server $server) - { - $this->server = $server; - $this->command = Command::foreground('rabbitmqadmin'); + private function __construct( + private Server $server, + private Command $command, + ) { } public static function of(Server $server): self { - return new self($server); + return new self($server, Command::foreground('rabbitmqadmin')); } /** diff --git a/src/Control/VHosts.php b/src/Control/VHosts.php index d7e8612..2720c07 100644 --- a/src/Control/VHosts.php +++ b/src/Control/VHosts.php @@ -14,18 +14,15 @@ final class VHosts { - private Server $server; - private Command $command; - - private function __construct(Server $server) - { - $this->server = $server; - $this->command = Command::foreground('rabbitmqadmin'); + private function __construct( + private Server $server, + private Command $command, + ) { } public static function of(Server $server): self { - return new self($server); + return new self($server, Command::foreground('rabbitmqadmin')); } /** diff --git a/src/Model/Channel.php b/src/Model/Channel.php index 6460f5b..12f84e1 100644 --- a/src/Model/Channel.php +++ b/src/Model/Channel.php @@ -15,46 +15,22 @@ */ final class Channel { - private Name $name; - private VHost\Name $vhost; - private User\Name $user; - private int $number; - private Node\Name $node; - private State $state; - private Messages $messages; - private Count $consumers; - private bool $confirm; - private bool $transactional; - /** @var Maybe */ - private Maybe $idleSince; - /** * @param Maybe $idleSince */ private function __construct( - Name $name, - VHost\Name $vhost, - User\Name $user, - int $number, - Node\Name $node, - State $state, - Messages $messages, - Count $consumers, - bool $confirm, - bool $transactional, - Maybe $idleSince, + private Name $name, + private VHost\Name $vhost, + private User\Name $user, + private int $number, + private Node\Name $node, + private State $state, + private Messages $messages, + private Count $consumers, + private bool $confirm, + private bool $transactional, + private Maybe $idleSince, ) { - $this->name = $name; - $this->vhost = $vhost; - $this->user = $user; - $this->number = $number; - $this->node = $node; - $this->state = $state; - $this->messages = $messages; - $this->consumers = $consumers; - $this->confirm = $confirm; - $this->transactional = $transactional; - $this->idleSince = $idleSince; } /** diff --git a/src/Model/Channel/Messages.php b/src/Model/Channel/Messages.php index f1ebe8e..5f16acd 100644 --- a/src/Model/Channel/Messages.php +++ b/src/Model/Channel/Messages.php @@ -10,18 +10,11 @@ */ final class Messages { - private Count $uncommitted; - private Count $unconfirmed; - private Count $unacknowledged; - private function __construct( - Count $uncommitted, - Count $unconfirmed, - Count $unacknowledged, + private Count $uncommitted, + private Count $unconfirmed, + private Count $unacknowledged, ) { - $this->uncommitted = $uncommitted; - $this->unconfirmed = $unconfirmed; - $this->unacknowledged = $unacknowledged; } /** diff --git a/src/Model/Channel/Name.php b/src/Model/Channel/Name.php index 83a88ab..01b35c1 100644 --- a/src/Model/Channel/Name.php +++ b/src/Model/Channel/Name.php @@ -8,11 +8,8 @@ */ final class Name { - private string $value; - - private function __construct(string $value) + private function __construct(private string $value) { - $this->value = $value; } /** diff --git a/src/Model/Connection.php b/src/Model/Connection.php index 4080b89..6461eeb 100644 --- a/src/Model/Connection.php +++ b/src/Model/Connection.php @@ -22,51 +22,22 @@ */ final class Connection { - private Name $name; - private PointInTime $connectedAt; - private Timeout $timeout; - private VHost\Name $vhost; - private User\Name $user; - private Protocol $protocol; - private AuthenticationMechanism $authenticationMechanism; - private bool $ssl; - private Peer $peer; - private Host $host; - private Port $port; - private Node\Name $node; - private Type $type; - private State $state; - private function __construct( - Name $name, - PointInTime $connectedAt, - Timeout $timeout, - VHost\Name $vhost, - User\Name $user, - Protocol $protocol, - AuthenticationMechanism $authenticationMechanism, - bool $ssl, - Peer $peer, - Host $host, - Port $port, - Node\Name $node, - Type $type, - State $state, + private Name $name, + private PointInTime $connectedAt, + private Timeout $timeout, + private VHost\Name $vhost, + private User\Name $user, + private Protocol $protocol, + private AuthenticationMechanism $authenticationMechanism, + private bool $ssl, + private Peer $peer, + private Host $host, + private Port $port, + private Node\Name $node, + private Type $type, + private State $state, ) { - $this->connectedAt = $connectedAt; - $this->timeout = $timeout; - $this->vhost = $vhost; - $this->user = $user; - $this->protocol = $protocol; - $this->authenticationMechanism = $authenticationMechanism; - $this->ssl = $ssl; - $this->peer = $peer; - $this->host = $host; - $this->port = $port; - $this->name = $name; - $this->node = $node; - $this->type = $type; - $this->state = $state; } /** diff --git a/src/Model/Connection/Name.php b/src/Model/Connection/Name.php index cbe9c3b..2cdf547 100644 --- a/src/Model/Connection/Name.php +++ b/src/Model/Connection/Name.php @@ -8,11 +8,8 @@ */ final class Name { - private string $value; - - private function __construct(string $value) + private function __construct(private string $value) { - $this->value = $value; } /** diff --git a/src/Model/Connection/Peer.php b/src/Model/Connection/Peer.php index 4f2fcde..a888f40 100644 --- a/src/Model/Connection/Peer.php +++ b/src/Model/Connection/Peer.php @@ -13,13 +13,10 @@ */ final class Peer { - private Host $host; - private Port $port; - - private function __construct(Host $host, Port $port) - { - $this->host = $host; - $this->port = $port; + private function __construct( + private Host $host, + private Port $port, + ) { } /** diff --git a/src/Model/Connection/Timeout.php b/src/Model/Connection/Timeout.php index aac559f..e392311 100644 --- a/src/Model/Connection/Timeout.php +++ b/src/Model/Connection/Timeout.php @@ -8,21 +8,17 @@ */ final class Timeout { - /** @var 0|positive-int */ - private int $value; - /** - * @param 0|positive-int $value + * @param int<0, max> $value */ - private function __construct(int $value) + private function __construct(private int $value) { - $this->value = $value; } /** * @psalm-pure * - * @param 0|positive-int $value + * @param int<0, max> $value */ public static function of(int $value): self { @@ -30,7 +26,7 @@ public static function of(int $value): self } /** - * @return 0|positive-int + * @return int<0, max> */ public function toInt(): int { diff --git a/src/Model/Consumer.php b/src/Model/Consumer.php index ed715fd..de27138 100644 --- a/src/Model/Consumer.php +++ b/src/Model/Consumer.php @@ -14,27 +14,14 @@ */ final class Consumer { - private Tag $tag; - private Name $channel; - private Identity $queue; - private Connection\Name $connection; - private bool $ackRequired; - private bool $exclusive; - private function __construct( - Tag $tag, - Name $channel, - Identity $queue, - Connection\Name $connection, - bool $ackRequired, - bool $exclusive, + private Tag $tag, + private Name $channel, + private Identity $queue, + private Connection\Name $connection, + private bool $ackRequired, + private bool $exclusive, ) { - $this->tag = $tag; - $this->channel = $channel; - $this->queue = $queue; - $this->connection = $connection; - $this->ackRequired = $ackRequired; - $this->exclusive = $exclusive; } /** diff --git a/src/Model/Consumer/Tag.php b/src/Model/Consumer/Tag.php index 57f2b99..0c1b9f8 100644 --- a/src/Model/Consumer/Tag.php +++ b/src/Model/Consumer/Tag.php @@ -8,11 +8,8 @@ */ final class Tag { - private string $value; - - private function __construct(string $value) + private function __construct(private string $value) { - $this->value = $value; } /** diff --git a/src/Model/Count.php b/src/Model/Count.php index f58b752..25e9be2 100644 --- a/src/Model/Count.php +++ b/src/Model/Count.php @@ -8,19 +8,15 @@ */ final class Count { - /** @var 0|positive-int */ - private int $value; - /** - * @param 0|positive-int $value + * @param int<0, max> $value */ - private function __construct(int $value) + private function __construct(private int $value) { - $this->value = $value; } /** - * @param 0|positive-int $value + * @param int<0, max> $value */ public static function of(int $value): self { @@ -28,7 +24,7 @@ public static function of(int $value): self } /** - * @return 0|positive-int + * @return int<0, max> */ public function toInt(): int { diff --git a/src/Model/Exchange.php b/src/Model/Exchange.php index b26019f..b887716 100644 --- a/src/Model/Exchange.php +++ b/src/Model/Exchange.php @@ -13,27 +13,14 @@ */ final class Exchange { - private Name $name; - private VHost\Name $vhost; - private Type $type; - private bool $durable; - private bool $autoDelete; - private bool $internal; - private function __construct( - Name $name, - VHost\Name $vhost, - Type $type, - bool $durable, - bool $autoDelete, - bool $internal, + private Name $name, + private VHost\Name $vhost, + private Type $type, + private bool $durable, + private bool $autoDelete, + private bool $internal, ) { - $this->name = $name; - $this->vhost = $vhost; - $this->type = $type; - $this->durable = $durable; - $this->autoDelete = $autoDelete; - $this->internal = $internal; } /** diff --git a/src/Model/Exchange/Name.php b/src/Model/Exchange/Name.php index 6ef982f..ae9accf 100644 --- a/src/Model/Exchange/Name.php +++ b/src/Model/Exchange/Name.php @@ -8,11 +8,8 @@ */ final class Name { - private string $value; - - private function __construct(string $value) + private function __construct(private string $value) { - $this->value = $value; } /** diff --git a/src/Model/Node.php b/src/Model/Node.php index 9c96819..1a9d1f3 100644 --- a/src/Model/Node.php +++ b/src/Model/Node.php @@ -13,15 +13,11 @@ */ final class Node { - private Name $name; - private Type $type; - private bool $running; - - private function __construct(Name $name, Type $type, bool $running) - { - $this->name = $name; - $this->type = $type; - $this->running = $running; + private function __construct( + private Name $name, + private Type $type, + private bool $running, + ) { } /** diff --git a/src/Model/Node/Name.php b/src/Model/Node/Name.php index 585aded..c34ba8e 100644 --- a/src/Model/Node/Name.php +++ b/src/Model/Node/Name.php @@ -15,13 +15,10 @@ */ final class Name { - private string $value; - private Host $host; - - private function __construct(string $value, Host $host) - { - $this->value = $value; - $this->host = $host; + private function __construct( + private string $value, + private Host $host, + ) { } /** diff --git a/src/Model/Permission.php b/src/Model/Permission.php index bca077b..46ed168 100644 --- a/src/Model/Permission.php +++ b/src/Model/Permission.php @@ -8,24 +8,13 @@ */ final class Permission { - private User\Name $user; - private VHost\Name $vhost; - private string $configure; - private string $write; - private string $read; - private function __construct( - User\Name $user, - VHost\Name $vhost, - string $configure, - string $write, - string $read, + private User\Name $user, + private VHost\Name $vhost, + private string $configure, + private string $write, + private string $read, ) { - $this->user = $user; - $this->vhost = $vhost; - $this->configure = $configure; - $this->write = $write; - $this->read = $read; } /** diff --git a/src/Model/Queue.php b/src/Model/Queue.php index 7bbbbfb..42d54c7 100644 --- a/src/Model/Queue.php +++ b/src/Model/Queue.php @@ -15,40 +15,20 @@ */ final class Queue { - private Identity $identity; - private Messages $messages; - /** @var Maybe */ - private Maybe $idleSince; - private Count $consumers; - private State $state; - private Node\Name $node; - private bool $exclusive; - private bool $autoDelete; - private bool $durable; - /** * @param Maybe $idleSince */ private function __construct( - Identity $identity, - Messages $messages, - Maybe $idleSince, - Count $consumers, - State $state, - Node\Name $node, - bool $exclusive, - bool $autoDelete, - bool $durable, + private Identity $identity, + private Messages $messages, + private Maybe $idleSince, + private Count $consumers, + private State $state, + private Node\Name $node, + private bool $exclusive, + private bool $autoDelete, + private bool $durable, ) { - $this->identity = $identity; - $this->messages = $messages; - $this->idleSince = $idleSince; - $this->consumers = $consumers; - $this->state = $state; - $this->node = $node; - $this->exclusive = $exclusive; - $this->autoDelete = $autoDelete; - $this->durable = $durable; } /** diff --git a/src/Model/Queue/Identity.php b/src/Model/Queue/Identity.php index d14a062..546fcf1 100644 --- a/src/Model/Queue/Identity.php +++ b/src/Model/Queue/Identity.php @@ -10,13 +10,10 @@ */ final class Identity { - private string $name; - private Name $vhost; - - private function __construct(string $name, Name $vhost) - { - $this->name = $name; - $this->vhost = $vhost; + private function __construct( + private string $name, + private Name $vhost, + ) { } /** diff --git a/src/Model/Queue/Messages.php b/src/Model/Queue/Messages.php index 9cce247..8a281d2 100644 --- a/src/Model/Queue/Messages.php +++ b/src/Model/Queue/Messages.php @@ -10,18 +10,11 @@ */ final class Messages { - private Count $total; - private Count $ready; - private Count $unacknowledged; - private function __construct( - Count $total, - Count $ready, - Count $unacknowledged, + private Count $total, + private Count $ready, + private Count $unacknowledged, ) { - $this->total = $total; - $this->ready = $ready; - $this->unacknowledged = $unacknowledged; } /** diff --git a/src/Model/User.php b/src/Model/User.php index 4a30983..d031104 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -14,22 +14,14 @@ */ final class User { - private Name $name; - private Password $password; - /** @var Set */ - private Set $tags; - /** * @param Set $tags */ private function __construct( - Name $name, - Password $password, - Set $tags, + private Name $name, + private Password $password, + private Set $tags, ) { - $this->name = $name; - $this->password = $password; - $this->tags = $tags; } /** diff --git a/src/Model/User/Name.php b/src/Model/User/Name.php index 42dbc32..45ca23d 100644 --- a/src/Model/User/Name.php +++ b/src/Model/User/Name.php @@ -8,11 +8,8 @@ */ final class Name { - private string $value; - - private function __construct(string $value) + private function __construct(private string $value) { - $this->value = $value; } /** diff --git a/src/Model/User/Password.php b/src/Model/User/Password.php index 5db37af..e57e3be 100644 --- a/src/Model/User/Password.php +++ b/src/Model/User/Password.php @@ -8,13 +8,10 @@ */ final class Password { - private string $hash; - private string $algorithm; - - private function __construct(string $hash, string $algorithm) - { - $this->hash = $hash; - $this->algorithm = $algorithm; + private function __construct( + private string $hash, + private string $algorithm, + ) { } /** diff --git a/src/Model/VHost.php b/src/Model/VHost.php index 6a3e495..8b40d5a 100644 --- a/src/Model/VHost.php +++ b/src/Model/VHost.php @@ -13,15 +13,11 @@ */ final class VHost { - private Name $name; - private Messages $messages; - private bool $tracing; - - private function __construct(Name $name, Messages $messages, bool $tracing) - { - $this->name = $name; - $this->messages = $messages; - $this->tracing = $tracing; + private function __construct( + private Name $name, + private Messages $messages, + private bool $tracing, + ) { } /** diff --git a/src/Model/VHost/Messages.php b/src/Model/VHost/Messages.php index 7f0e451..08089a6 100644 --- a/src/Model/VHost/Messages.php +++ b/src/Model/VHost/Messages.php @@ -10,18 +10,11 @@ */ final class Messages { - private Count $total; - private Count $ready; - private Count $unacknowledged; - private function __construct( - Count $total, - Count $ready, - Count $unacknowledged, + private Count $total, + private Count $ready, + private Count $unacknowledged, ) { - $this->total = $total; - $this->ready = $ready; - $this->unacknowledged = $unacknowledged; } /** diff --git a/src/Model/VHost/Name.php b/src/Model/VHost/Name.php index 2b768a9..4a45aac 100644 --- a/src/Model/VHost/Name.php +++ b/src/Model/VHost/Name.php @@ -8,11 +8,8 @@ */ final class Name { - private string $value; - - private function __construct(string $value) + private function __construct(private string $value) { - $this->value = $value; } /** diff --git a/src/Status.php b/src/Status.php index 0f68295..c5fb722 100644 --- a/src/Status.php +++ b/src/Status.php @@ -44,22 +44,12 @@ final class Status { - private Server $server; - private Clock $clock; - private Environment $environment; - private Command $command; - private function __construct( - Server $server, - Clock $clock, - ?Environment $environment = null, + private Server $server, + private Clock $clock, + private Environment $environment, + private Command $command, ) { - $this->server = $server; - $this->clock = $clock; - $this->environment = $environment ?? Environment\Local::of(); - $this->command = Command::foreground('rabbitmqadmin') - ->withShortOption('f', 'raw_json') - ->withArgument('list'); } public static function of( @@ -67,7 +57,14 @@ public static function of( Clock $clock, ?Environment $environment = null, ): self { - return new self($server, $clock, $environment); + return new self( + $server, + $clock, + $environment ?? Environment\Local::of(), + Command::foreground('rabbitmqadmin') + ->withShortOption('f', 'raw_json') + ->withArgument('list'), + ); } /** diff --git a/src/Status/Environment/Local.php b/src/Status/Environment/Local.php index 4089d6e..3d68eb5 100644 --- a/src/Status/Environment/Local.php +++ b/src/Status/Environment/Local.php @@ -9,11 +9,8 @@ final class Local implements Environment { - private ?Path $vhost; - - private function __construct(?Path $vhost) + private function __construct(private ?Path $vhost) { - $this->vhost = $vhost; } #[\Override] diff --git a/src/Status/Environment/Remote.php b/src/Status/Environment/Remote.php index 8e3dddd..556daa5 100644 --- a/src/Status/Environment/Remote.php +++ b/src/Status/Environment/Remote.php @@ -13,24 +13,13 @@ final class Remote implements Environment { - private Host $host; - private Port $port; - private string $username; - private string $password; - private ?Path $vhost; - private function __construct( - Host $host, - Port $port, - string $username, - string $password, - ?Path $vhost, + private Host $host, + private Port $port, + private string $username, + private string $password, + private ?Path $vhost, ) { - $this->host = $host; - $this->port = $port; - $this->username = $username; - $this->password = $password; - $this->vhost = $vhost; } #[\Override]