Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/Control.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 5 additions & 8 deletions src/Control/Permissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}

/**
Expand Down
13 changes: 5 additions & 8 deletions src/Control/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}

/**
Expand Down
13 changes: 5 additions & 8 deletions src/Control/VHosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}

/**
Expand Down
46 changes: 11 additions & 35 deletions src/Model/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<PointInTime> */
private Maybe $idleSince;

/**
* @param Maybe<PointInTime> $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;
}

/**
Expand Down
13 changes: 3 additions & 10 deletions src/Model/Channel/Messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/Model/Channel/Name.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@
*/
final class Name
{
private string $value;

private function __construct(string $value)
private function __construct(private string $value)
{
$this->value = $value;
}

/**
Expand Down
57 changes: 14 additions & 43 deletions src/Model/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/Model/Connection/Name.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@
*/
final class Name
{
private string $value;

private function __construct(string $value)
private function __construct(private string $value)
{
$this->value = $value;
}

/**
Expand Down
11 changes: 4 additions & 7 deletions src/Model/Connection/Peer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
}

/**
Expand Down
12 changes: 4 additions & 8 deletions src/Model/Connection/Timeout.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,25 @@
*/
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
{
return new self($value);
}

/**
* @return 0|positive-int
* @return int<0, max>
*/
public function toInt(): int
{
Expand Down
25 changes: 6 additions & 19 deletions src/Model/Consumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/Model/Consumer/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@
*/
final class Tag
{
private string $value;

private function __construct(string $value)
private function __construct(private string $value)
{
$this->value = $value;
}

/**
Expand Down
Loading
Loading