1 | <?php |
||
15 | class AMQPConnection |
||
16 | { |
||
17 | /** |
||
18 | * @const array Default connections parameters |
||
19 | */ |
||
20 | const DEFAULTS = [ |
||
21 | 'hostname' => '127.0.0.1', |
||
22 | 'port' => 5672, |
||
23 | 'username' => 'guest', |
||
24 | 'password' => 'guest', |
||
25 | 'vhost' => '/', |
||
26 | |||
27 | # whether the connection should be lazy |
||
28 | 'lazy' => true, |
||
29 | |||
30 | # More info about timeouts can be found on https://www.rabbitmq.com/networking.html |
||
31 | 'read_write_timeout' => 3, // default timeout for writing/reading (in seconds) |
||
32 | 'connect_timeout' => 3, |
||
33 | 'heartbeat' => 0, |
||
34 | 'keep_alive' => false |
||
35 | ]; |
||
36 | |||
37 | /** |
||
38 | * @var array |
||
39 | */ |
||
40 | protected $connectionDetails = []; |
||
41 | |||
42 | /** |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $aliasName = ''; |
||
46 | |||
47 | /** |
||
48 | * @var null|AbstractConnection |
||
49 | */ |
||
50 | private $connection = null; |
||
51 | |||
52 | /** |
||
53 | * @var null|AMQPChannel |
||
54 | */ |
||
55 | private $channel = null; |
||
56 | |||
57 | /** |
||
58 | * @param string $aliasName |
||
59 | * @param array $connectionDetails |
||
60 | * @return AMQPConnection |
||
61 | */ |
||
62 | 10 | public static function createConnection(string $aliasName, array $connectionDetails) |
|
79 | |||
80 | /** |
||
81 | * AMQPConnection constructor. |
||
82 | * |
||
83 | * @param string $aliasName |
||
84 | * @param array $connectionDetails |
||
85 | */ |
||
86 | 11 | public function __construct(string $aliasName, array $connectionDetails = []) |
|
95 | |||
96 | /** |
||
97 | * @return AbstractConnection |
||
98 | */ |
||
99 | protected function getConnection(): AbstractConnection |
||
118 | |||
119 | /** |
||
120 | * @param $type |
||
121 | * @return mixed |
||
|
|||
122 | */ |
||
123 | private function createConnectionByType($type) |
||
146 | |||
147 | /** |
||
148 | * Reconnect |
||
149 | */ |
||
150 | 1 | public function reconnect() |
|
156 | |||
157 | /** |
||
158 | * @return \PhpAmqpLib\Channel\AMQPChannel |
||
159 | */ |
||
160 | 1 | public function getChannel() |
|
167 | |||
168 | /** |
||
169 | * Retrieve the connection alias name |
||
170 | * |
||
171 | * @return string |
||
172 | */ |
||
173 | 1 | public function getAliasName(): string |
|
177 | } |
||
178 |
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.