Failed Conditions
Branch refactor/kernels (cc9370)
by Atanas
02:23
created

src/Exceptions/ExceptionsServiceProvider.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
 * @package   WPEmerge
4
 * @author    Atanas Angelov <[email protected]>
5
 * @copyright 2018 Atanas Angelov
6
 * @license   https://www.gnu.org/licenses/gpl-2.0.html GPL-2.0
7
 * @link      https://wpemerge.com/
8
 */
9
10
namespace WPEmerge\Exceptions;
11
12
use Whoops\Handler\PrettyPageHandler;
13
use Whoops\Run;
14
use WPEmerge\Facades\Application;
15
use WPEmerge\ServiceProviders\ExtendsConfigTrait;
16
use WPEmerge\ServiceProviders\ServiceProviderInterface;
17
18
/**
19
 * Provide exceptions dependencies.
20
 *
21
 * @codeCoverageIgnore
22
 */
23
class ExceptionsServiceProvider implements ServiceProviderInterface {
24
	use ExtendsConfigTrait;
25
26
	/**
27
	 * {@inheritDoc}
28
	 */
29
	public function register( $container ) {
30
		$this->extendConfig( $container, 'debug', [
31
			'pretty_errors' => true,
32
		] );
33
34
		$container['whoops'] = function () {
35
			if ( ! class_exists( Run::class ) ) {
36
				return null;
37
			}
38
39
			$run = new Run();
40
			$run->allowQuit( false );
41
			$run->pushHandler( new PrettyPageHandler() );
42
			return $run;
43
		};
44
45
		$container[ WPEMERGE_EXCEPTIONS_ERROR_HANDLER_KEY ] = function ( $c ) {
46
			$whoops = $c[ WPEMERGE_CONFIG_KEY ]['debug']['pretty_errors'] ? $c['whoops'] : null;
47
			return new ErrorHandler( $whoops, Application::debugging() );
0 ignored issues
show
The method debugging() does not exist on WPEmerge\Facades\Application. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

47
			return new ErrorHandler( $whoops, Application::/** @scrutinizer ignore-call */ debugging() );
Loading history...
48
		};
49
	}
50
51
	/**
52
	 * {@inheritDoc}
53
	 */
54
	public function bootstrap( $container ) {
55
		// Nothing to bootstrap.
56
	}
57
}
58