1 | <?php |
||
56 | class Manager extends ObjectAbstract implements ManagerInterface |
||
57 | { |
||
58 | /** |
||
59 | * drivers |
||
60 | * |
||
61 | * @var DriverInterface[] |
||
62 | * @access protected |
||
63 | */ |
||
64 | protected $drivers = []; |
||
65 | |||
66 | /** |
||
67 | * driver weight factor |
||
68 | * |
||
69 | * @var array |
||
70 | * @access protected |
||
71 | */ |
||
72 | protected $factors = []; |
||
73 | |||
74 | /** |
||
75 | * Specify a weighting factor for the driver. normally 1 - 10 |
||
76 | * |
||
77 | * {@inheritDoc} |
||
78 | * @param int $factor weight factor for round-robin |
||
79 | */ |
||
80 | public function addDriver(DriverInterface $driver, /*# int */ $factor = 1) |
||
93 | |||
94 | /** |
||
95 | * Get a driver with a tag matched |
||
96 | * |
||
97 | * {@inheritDoc} |
||
98 | */ |
||
99 | public function getDriver(/*# string */ $tag = '')/*# : DriverInterface */ |
||
114 | |||
115 | /** |
||
116 | * Return a unique string id of the driver |
||
117 | * |
||
118 | * @param DriverInterface $driver |
||
119 | * @return string |
||
120 | * @access protected |
||
121 | */ |
||
122 | protected function getDriverId(DriverInterface $driver)/*# : string */ |
||
126 | |||
127 | /** |
||
128 | * Make sure factor in the range of 1 - 10 |
||
129 | * |
||
130 | * @param int $factor |
||
131 | * @return int |
||
132 | * @access protected |
||
133 | */ |
||
134 | protected function fixFactor(/*# int */ $factor)/*# : int */ |
||
139 | |||
140 | /** |
||
141 | * Match drivers with tag |
||
142 | * |
||
143 | * @param string $tag tag to match |
||
144 | * @return array |
||
145 | * @access protected |
||
146 | */ |
||
147 | protected function driverMatcher(/*# string */ $tag)/*# : array */ |
||
157 | |||
158 | /** |
||
159 | * Expand into $matched with factor weight |
||
160 | * |
||
161 | * @param array &$matched |
||
162 | * @param string $id |
||
163 | * @access protected |
||
164 | */ |
||
165 | protected function expandWithFactor(array &$matched, /*# string */ $id) |
||
172 | |||
173 | /** |
||
174 | * Match driver with $tag |
||
175 | * |
||
176 | * @param string $tag |
||
177 | * @param DriverInterface $driver |
||
178 | * @return bool |
||
179 | * @access protected |
||
180 | */ |
||
181 | protected function tagMatched( |
||
197 | } |
||
198 |