| Conditions | 6 |
| Paths | 3 |
| Total Lines | 31 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 18 |
| CRAP Score | 6 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 22 | 1 | protected function getHoneybadger(): Honeybadger |
|
| 23 | { |
||
| 24 | 1 | static $honeybadger; |
|
| 25 | |||
| 26 | 1 | if ($honeybadger) { |
|
| 27 | 1 | return $honeybadger; |
|
| 28 | } |
||
| 29 | |||
| 30 | 1 | $config = $this->config; |
|
| 31 | |||
| 32 | // Globally disable error handlers, record the errors via the logger |
||
| 33 | 1 | $config['handlers'] = [ |
|
| 34 | 1 | 'exception' => false, |
|
| 35 | 1 | 'error' => false, |
|
| 36 | 1 | 'shutdown' => false, |
|
| 37 | 1 | ]; |
|
| 38 | |||
| 39 | 1 | $context = ArrayHelper::remove($config, 'context'); |
|
| 40 | |||
| 41 | 1 | $honeybadger = Honeybadger::new($config); |
|
| 42 | |||
| 43 | 1 | if (!empty($context) && is_array($context)) { |
|
| 44 | 1 | foreach ($context as $key => $value) { |
|
| 45 | 1 | if ($value instanceof Closure) { |
|
| 46 | 1 | $context[$key] = call_user_func($value); |
|
| 47 | } |
||
| 48 | } |
||
| 49 | 1 | $honeybadger->context($context); |
|
|
|
|||
| 50 | } |
||
| 51 | |||
| 52 | 1 | return $honeybadger; |
|
| 53 | } |
||
| 78 |