Passed
Push — master ( 2d893f...5de32f )
by Atanas
02:41
created

FlashServiceProvider::register()   A

Complexity

Conditions 3
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
nc 1
nop 1
dl 0
loc 12
c 0
b 0
f 0
cc 3
rs 10
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\Flash;
11
12
use WPEmerge\Facades\Application;
13
use WPEmerge\ServiceProviders\ServiceProviderInterface;
14
15
/**
16
 * Provide flash dependencies.
17
 *
18
 * @codeCoverageIgnore
19
 */
20
class FlashServiceProvider implements ServiceProviderInterface {
21
	/**
22
	 * {@inheritDoc}
23
	 */
24
	public function register( $container ) {
25
		$container[ WPEMERGE_FLASH_KEY ] = function ( $c ) {
26
			$session = null;
27
			if ( isset( $c[ WPEMERGE_SESSION_KEY ] ) ) {
28
				$session = &$c[ WPEMERGE_SESSION_KEY ];
29
			} else if ( isset( $_SESSION ) ) {
30
				$session = &$_SESSION;
31
			}
32
			return new Flash( $session );
33
		};
34
35
		Application::alias( 'Flash', \WPEmerge\Facades\Flash::class );
36
	}
37
38
	/**
39
	 * {@inheritDoc}
40
	 */
41
	public function bootstrap( $container ) {
42
		// Nothing to bootstrap.
43
	}
44
}
45