1 | <?php |
||
24 | class ClientHolder |
||
25 | { |
||
26 | protected $clients = []; |
||
27 | |||
28 | /** |
||
29 | * add |
||
30 | * |
||
31 | * Add a new client or replace existing one. |
||
32 | * |
||
33 | * @param ClientInterface $client |
||
34 | * @return ClientHolder $this |
||
35 | */ |
||
36 | public function add(ClientInterface $client) |
||
42 | |||
43 | /** |
||
44 | * has |
||
45 | * |
||
46 | * Tell if a client is in the pool or not. |
||
47 | * |
||
48 | * @param string $type |
||
49 | * @param string $name |
||
50 | * @return bool |
||
51 | */ |
||
52 | public function has($type, $name) |
||
56 | |||
57 | /** |
||
58 | * get |
||
59 | * |
||
60 | * Return a client by its name or null if no client exist for that name. |
||
61 | * |
||
62 | * @param string $type |
||
63 | * @param string $name |
||
64 | * @return ClientInterface |
||
65 | */ |
||
66 | public function get($type, $name) |
||
70 | |||
71 | /** |
||
72 | * getAllFor |
||
73 | * |
||
74 | * Return all clients for a given type. |
||
75 | * |
||
76 | * @param string $type |
||
77 | * @return array |
||
78 | */ |
||
79 | public function getAllFor($type) |
||
87 | |||
88 | /** |
||
89 | * clear |
||
90 | * |
||
91 | * Call shutdown and remove a client from the pool. If the client does not |
||
92 | * exist, nothing is done. |
||
93 | * |
||
94 | * @param string $type |
||
95 | * @param string $name |
||
96 | * @return ClientHolder $this |
||
97 | */ |
||
98 | public function clear($type, $name) |
||
107 | |||
108 | /** |
||
109 | * shutdown |
||
110 | * |
||
111 | * Call shutdown for all registered clients and unset the clients so they |
||
112 | * can be cleaned by GC. It would have been better by far to use a |
||
113 | * RecursiveArrayIterator to do this but it is not possible in PHP using |
||
114 | * built'in iterators hence the double foreach recursion. |
||
115 | * see http://fr2.php.net/manual/en/class.recursivearrayiterator.php#106519 |
||
116 | * |
||
117 | * @return array exceptions caught during the shutdown |
||
118 | */ |
||
119 | public function shutdown() |
||
137 | } |
||
138 |