Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 9 |
CRAP | |
0.00% |
0 / 1 |
| ClientConnection | |
0.00% |
0 / 11 |
|
0.00% |
0 / 9 |
90 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| getId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getAccount | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getSocket | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setSocket | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getHandshake | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setHandshake | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| isConnected | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setConnected | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Jingga |
| 4 | * |
| 5 | * PHP Version 8.1 |
| 6 | * |
| 7 | * @package phpOMS\Socket\Client |
| 8 | * @copyright Dennis Eichhorn |
| 9 | * @license OMS License 2.0 |
| 10 | * @version 1.0.0 |
| 11 | * @link https://jingga.app |
| 12 | */ |
| 13 | declare(strict_types=1); |
| 14 | |
| 15 | namespace phpOMS\Socket\Client; |
| 16 | |
| 17 | use phpOMS\Account\Account; |
| 18 | |
| 19 | /** |
| 20 | * Client socket class. |
| 21 | * |
| 22 | * @package phpOMS\Socket\Client |
| 23 | * @license OMS License 2.0 |
| 24 | * @link https://jingga.app |
| 25 | * @since 1.0.0 |
| 26 | */ |
| 27 | class ClientConnection |
| 28 | { |
| 29 | private $id = 0; |
| 30 | |
| 31 | private $socket = null; |
| 32 | |
| 33 | private $handshake = false; |
| 34 | |
| 35 | private $pid = null; |
| 36 | |
| 37 | private $connected = true; |
| 38 | |
| 39 | private Account $account; |
| 40 | |
| 41 | /** |
| 42 | * Constructor. |
| 43 | * |
| 44 | * @param Account $account Account |
| 45 | * @param mixed $socket Socket connection |
| 46 | * |
| 47 | * @since 1.0.0 |
| 48 | */ |
| 49 | public function __construct(Account $account, $socket) |
| 50 | { |
| 51 | $this->id = $account->getId(); |
| 52 | $this->account = $account; |
| 53 | $this->socket = $socket; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Get client id. |
| 58 | * |
| 59 | * @return int |
| 60 | * |
| 61 | * @since 1.0.0 |
| 62 | */ |
| 63 | public function getId() : int |
| 64 | { |
| 65 | return $this->id; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Get account |
| 70 | * |
| 71 | * @return Account |
| 72 | * |
| 73 | * @since 1.0.0 |
| 74 | */ |
| 75 | public function getAccount() : Account |
| 76 | { |
| 77 | return $this->account; |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Get socket |
| 82 | * |
| 83 | * @return mixed |
| 84 | * |
| 85 | * @since 1.0.0 |
| 86 | */ |
| 87 | public function getSocket() |
| 88 | { |
| 89 | return $this->socket; |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * Set socket |
| 94 | * |
| 95 | * @param mixed $socket Socket connection |
| 96 | * |
| 97 | * @return void |
| 98 | * |
| 99 | * @since 1.0.0 |
| 100 | */ |
| 101 | public function setSocket($socket) : void |
| 102 | { |
| 103 | $this->socket = $socket; |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * Get handshake data |
| 108 | * |
| 109 | * @return mixed |
| 110 | * |
| 111 | * @sicne 1.0.0 |
| 112 | */ |
| 113 | public function getHandshake() |
| 114 | { |
| 115 | return $this->handshake; |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * Set handshake data |
| 120 | * |
| 121 | * @param mixed $handshake Handshake |
| 122 | * |
| 123 | * @return void |
| 124 | * |
| 125 | * @since 1.0.0 |
| 126 | */ |
| 127 | public function setHandshake($handshake) : void |
| 128 | { |
| 129 | $this->handshake = $handshake; |
| 130 | } |
| 131 | |
| 132 | /** |
| 133 | * Is connected? |
| 134 | * |
| 135 | * @return bool |
| 136 | * |
| 137 | * @since 1.0.0 |
| 138 | */ |
| 139 | public function isConnected() : bool |
| 140 | { |
| 141 | return $this->connected; |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * Set connected |
| 146 | * |
| 147 | * @param bool $connected Is connected? |
| 148 | * |
| 149 | * @return void |
| 150 | * |
| 151 | * @since 1.0.0 |
| 152 | */ |
| 153 | public function setConnected(bool $connected) : void |
| 154 | { |
| 155 | $this->connected = $connected; |
| 156 | } |
| 157 | } |