1 | <?php |
||
11 | class PhpAmqpLib implements AdapterInterface |
||
12 | { |
||
13 | |||
14 | /** |
||
15 | * @var Connection |
||
16 | */ |
||
17 | protected $connection; |
||
18 | /** |
||
19 | * @var Channel |
||
20 | */ |
||
21 | protected $channelPrototype; |
||
22 | |||
23 | /** |
||
24 | * PhpAmqpLib constructor. |
||
25 | * |
||
26 | * @param Connection|ConnectionOptions|array|\Traversable|LibConnection $connection |
||
27 | * @param Channel $channelPrototype |
||
28 | * @throws Exception\BadMethodCallException |
||
29 | * @throws Exception\InvalidArgumentException |
||
30 | * @throws Exception\RuntimeException |
||
31 | */ |
||
32 | 4 | public function __construct($connection, Channel $channelPrototype = null) |
|
33 | { |
||
34 | 4 | if (!$connection instanceof Connection) { |
|
35 | 1 | $connection = new Connection($connection); |
|
|
|||
36 | } |
||
37 | 4 | $this->registerConnection($connection); |
|
38 | 4 | $this->registerChannel($channelPrototype ?: new Channel()); |
|
39 | 4 | } |
|
40 | |||
41 | /** |
||
42 | * @param Connection $connection |
||
43 | */ |
||
44 | 4 | public function registerConnection(Connection $connection) |
|
45 | { |
||
46 | 4 | $this->connection = $connection; |
|
47 | 4 | } |
|
48 | |||
49 | /** |
||
50 | * @param Channel $channel |
||
51 | */ |
||
52 | 4 | public function registerChannel(Channel $channel) |
|
53 | { |
||
54 | 4 | $this->channelPrototype = $channel; |
|
55 | 4 | } |
|
56 | |||
57 | /** |
||
58 | * @param LibChannel $resource |
||
59 | * @return Channel |
||
60 | * @throws Exception\RuntimeException |
||
61 | * @throws Exception\InvalidArgumentException |
||
62 | */ |
||
63 | 3 | public function createChannel($resource = null) |
|
80 | |||
81 | /** |
||
82 | * @return Connection |
||
83 | */ |
||
84 | 4 | public function getConnection() |
|
88 | } |
||
89 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.