| Conditions | 4 |
| Paths | 8 |
| Total Lines | 21 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | protected function findByIdOrIdentifier($id) |
||
| 12 | { |
||
| 13 | $module = $this->controller->module; |
||
| 14 | |||
| 15 | try { |
||
| 16 | /** @var Oauth2Client $client */ |
||
| 17 | $client = $module->getClientRepository()->findModelByPk($id); |
||
| 18 | } catch (\Exception $e) { |
||
| 19 | // Silently ignore |
||
|
|
|||
| 20 | } |
||
| 21 | |||
| 22 | if (empty($client)) { |
||
| 23 | // try to find by `identifier` |
||
| 24 | $client = $module->getClientRepository()->findModelByIdentifier($id); |
||
| 25 | } |
||
| 26 | |||
| 27 | if (empty($client)) { |
||
| 28 | throw new Exception('No client with id or identifier "' . $id . '" found.' . PHP_EOL); |
||
| 29 | } |
||
| 30 | |||
| 31 | return $client; |
||
| 32 | } |
||
| 34 |