| Conditions | 4 |
| Paths | 4 |
| Total Lines | 19 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 19 | public function authenticate(array $data, array $providers) |
||
| 20 | { |
||
| 21 | // Initialize the exceptions stack |
||
| 22 | $exceptions = []; |
||
| 23 | |||
| 24 | // Try to authenticate |
||
| 25 | foreach ($providers as $provider) { |
||
| 26 | if ($provider instanceof Provider) { |
||
| 27 | try { |
||
| 28 | return $provider->authenticate($data); |
||
| 29 | } catch (Exception $e) { |
||
| 30 | $exceptions[] = $e; |
||
| 31 | } |
||
| 32 | } |
||
| 33 | } |
||
| 34 | |||
| 35 | // If no values are returned, throw the first exception |
||
| 36 | throw array_shift($exceptions); |
||
| 37 | } |
||
| 38 | } |
||
| 39 |