CsrfServiceProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 7
dl 0
loc 21
rs 10
c 2
b 0
f 1
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A bootstrap() 0 1 1
A register() 0 11 1
1
<?php
2
/**
3
 * @package   WPEmerge
4
 * @author    Atanas Angelov <[email protected]>
5
 * @copyright 2017-2019 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\Csrf;
11
12
use WPEmerge\ServiceProviders\ServiceProviderInterface;
13
14
/**
15
 * Provide CSRF dependencies.
16
 *
17
 * @codeCoverageIgnore
18
 */
19
class CsrfServiceProvider implements ServiceProviderInterface {
20
	/**
21
	 * {@inheritDoc}
22
	 */
23
	public function register( $container ) {
24
		$container[ WPEMERGE_CSRF_KEY ] = function () {
25
			return new Csrf();
26
		};
27
28
		$container[ CsrfMiddleware::class ] = function ( $c ) {
29
			return new CsrfMiddleware( $c[ WPEMERGE_CSRF_KEY ] );
30
		};
31
32
		$app = $container[ WPEMERGE_APPLICATION_KEY ];
33
		$app->alias( 'csrf', WPEMERGE_CSRF_KEY );
34
	}
35
36
	/**
37
	 * {@inheritDoc}
38
	 */
39
	public function bootstrap( $container ) {
40
		// Nothing to bootstrap.
41
	}
42
}
43