| @@ 6-56 (lines=51) @@ | ||
| 3 | ||
| 4 | namespace Innmind\AMQP\Model\Channel; |
|
| 5 | ||
| 6 | final class Close |
|
| 7 | { |
|
| 8 | private $replyCode; |
|
| 9 | private $replyText; |
|
| 10 | private $cause; |
|
| 11 | ||
| 12 | public static function reply(int $code, string $text): self |
|
| 13 | { |
|
| 14 | $self = new self; |
|
| 15 | $self->replyCode = $code; |
|
| 16 | $self->replyText = $text; |
|
| 17 | ||
| 18 | return $self; |
|
| 19 | } |
|
| 20 | ||
| 21 | /** |
|
| 22 | * @param string $method ie: exchange.declare, channel.open, etc |
|
| 23 | */ |
|
| 24 | public function causedBy(string $method): self |
|
| 25 | { |
|
| 26 | $self = clone $this; |
|
| 27 | $self->cause = $method; |
|
| 28 | ||
| 29 | return $self; |
|
| 30 | } |
|
| 31 | ||
| 32 | public function hasReply(): bool |
|
| 33 | { |
|
| 34 | return is_int($this->replyCode); |
|
| 35 | } |
|
| 36 | ||
| 37 | public function replyCode(): int |
|
| 38 | { |
|
| 39 | return $this->replyCode; |
|
| 40 | } |
|
| 41 | ||
| 42 | public function replyText(): string |
|
| 43 | { |
|
| 44 | return $this->replyText; |
|
| 45 | } |
|
| 46 | ||
| 47 | public function causedKnown(): bool |
|
| 48 | { |
|
| 49 | return is_string($this->cause); |
|
| 50 | } |
|
| 51 | ||
| 52 | public function cause(): string |
|
| 53 | { |
|
| 54 | return $this->cause; |
|
| 55 | } |
|
| 56 | } |
|
| 57 | ||
| @@ 6-56 (lines=51) @@ | ||
| 3 | ||
| 4 | namespace Innmind\AMQP\Model\Connection; |
|
| 5 | ||
| 6 | final class Close |
|
| 7 | { |
|
| 8 | private $replyCode; |
|
| 9 | private $replyText; |
|
| 10 | private $cause; |
|
| 11 | ||
| 12 | public static function reply(int $code, string $text): self |
|
| 13 | { |
|
| 14 | $self = new self; |
|
| 15 | $self->replyCode = $code; |
|
| 16 | $self->replyText = $text; |
|
| 17 | ||
| 18 | return $self; |
|
| 19 | } |
|
| 20 | ||
| 21 | /** |
|
| 22 | * @param string $method ie: exchange.declare, channel.open, etc |
|
| 23 | */ |
|
| 24 | public function causedBy(string $method): self |
|
| 25 | { |
|
| 26 | $self = clone $this; |
|
| 27 | $self->cause = $method; |
|
| 28 | ||
| 29 | return $self; |
|
| 30 | } |
|
| 31 | ||
| 32 | public function hasReply(): bool |
|
| 33 | { |
|
| 34 | return is_int($this->replyCode); |
|
| 35 | } |
|
| 36 | ||
| 37 | public function replyCode(): int |
|
| 38 | { |
|
| 39 | return $this->replyCode; |
|
| 40 | } |
|
| 41 | ||
| 42 | public function replyText(): string |
|
| 43 | { |
|
| 44 | return $this->replyText; |
|
| 45 | } |
|
| 46 | ||
| 47 | public function causedKnown(): bool |
|
| 48 | { |
|
| 49 | return is_string($this->cause); |
|
| 50 | } |
|
| 51 | ||
| 52 | public function cause(): string |
|
| 53 | { |
|
| 54 | return $this->cause; |
|
| 55 | } |
|
| 56 | } |
|
| 57 | ||