1 | <?php /** MicroQueue */ |
||
19 | class Queue |
||
20 | { |
||
21 | /** @var array $servers Configuration servers */ |
||
22 | protected $servers = []; |
||
23 | /** @var array $routes Configuration routes */ |
||
24 | protected $routes = []; |
||
25 | /** @var array $brokers Started servers */ |
||
26 | protected $brokers = []; |
||
27 | |||
28 | |||
29 | /** |
||
30 | * Initialize Queue manager |
||
31 | * |
||
32 | * @access public |
||
33 | * |
||
34 | * @param array $servers |
||
35 | * @param array $routes |
||
36 | * |
||
37 | * @result void |
||
38 | */ |
||
39 | public function __construct(array $servers = [], array $routes = []) |
||
44 | |||
45 | /** |
||
46 | * Send message into service on selected server |
||
47 | * |
||
48 | * @access public |
||
49 | * |
||
50 | * @param string $route |
||
51 | * @param array $data |
||
52 | * @param string $type |
||
53 | * @param int $retry |
||
54 | * |
||
55 | * @return mixed |
||
56 | * @throws Exception |
||
57 | */ |
||
58 | public function send($route, array $data = [], $type = 'sync', $retry = 5) |
||
74 | |||
75 | /** |
||
76 | * @param string $uri |
||
77 | * @param string $type |
||
78 | * @param string $retry |
||
79 | * |
||
80 | * @return \Micro\queue\Adapter |
||
81 | * @throws Exception |
||
82 | */ |
||
83 | private function getBroker($uri, $type, $retry) |
||
106 | |||
107 | /** |
||
108 | * Get servers list from routing rule |
||
109 | * |
||
110 | * @access protected |
||
111 | * |
||
112 | * @param array $route Routing rule |
||
113 | * @param string $type Sending type |
||
114 | * |
||
115 | * @return array |
||
116 | * @throws Exception |
||
117 | */ |
||
118 | protected function getServersFromRoute(array $route, $type = '*') |
||
140 | |||
141 | /** |
||
142 | * Get rules from route by pattern |
||
143 | * |
||
144 | * @access protected |
||
145 | * |
||
146 | * @param string $uri URI for match |
||
147 | * |
||
148 | * @return array Rules for URI |
||
149 | * @throws Exception |
||
150 | */ |
||
151 | protected function getRoute($uri) |
||
166 | } |
||
167 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.