| Total Complexity | 6 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | final class Client implements ClientInterface |
||
| 15 | { |
||
| 16 | private $connection; |
||
| 17 | private $process; |
||
| 18 | private $channels; |
||
| 19 | private $channel = 1; |
||
| 20 | |||
| 21 | 8 | public function __construct(Connection $connection, CurrentProcess $process) |
|
| 26 | 8 | } |
|
| 27 | |||
| 28 | 4 | public function channel(): Channel |
|
| 29 | { |
||
| 30 | 4 | $pid = $this->process->id()->toInt(); |
|
| 31 | |||
| 32 | 4 | if ($this->channels->contains($pid)) { |
|
| 33 | 2 | return $this->channels->get($pid); |
|
| 34 | } |
||
| 35 | |||
| 36 | 4 | $channel = new Channel\Channel( |
|
| 37 | 4 | $this->connection, |
|
| 38 | 4 | new Number($this->channel++) |
|
| 39 | ); |
||
| 40 | 4 | $this->channels = $this->channels->put($pid, $channel); |
|
| 41 | |||
| 42 | 4 | return $channel; |
|
| 43 | } |
||
| 44 | |||
| 45 | 2 | public function closed(): bool |
|
| 46 | { |
||
| 47 | 2 | return $this->connection->closed(); |
|
| 48 | } |
||
| 49 | |||
| 50 | 2 | public function close(): void |
|
| 60 | 2 | } |
|
| 61 | } |
||
| 62 |