Ajax::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 6
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 7
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * Ajax Module
7
 *
8
 * @since 0.1.0
9
 * @author Glynn Quelch <[email protected]>
10
 * @license http://www.opensource.org/licenses/mit-license.html  MIT License
11
 * @package PinkCrab\Ajax
12
 */
13
14
namespace PinkCrab\Ajax\Module;
15
16
use PinkCrab\HTTP\HTTP_Helper;
17
use PinkCrab\Loader\Hook_Loader;
18
use PinkCrab\Perique\Interfaces\Module;
19
use PinkCrab\Ajax\Module\Ajax_Middleware;
20
use PinkCrab\Perique\Application\App_Config;
21
use Psr\Http\Message\ServerRequestInterface;
22
use PinkCrab\Perique\Interfaces\DI_Container;
23
24
class Ajax implements Module {
25
26
	public function __construct( DI_Container $di_container ) {
27
		$di_container->addRule(
28
			'*',
29
			array(
30
				'substitutions' => array(
31
					ServerRequestInterface::class => array(
32
						\Dice\Dice::INSTANCE => fn() => HTTP_Helper::global_server_request(),
33
					),
34
				),
35
			)
36
		);
37
	}
38
39
	/** @inheritDoc */
40
	public function get_middleware(): ?string {
41
		return Ajax_Middleware::class;
42
	}
43
44
	## Unused methods
45
	public function pre_register( App_Config $config, Hook_Loader $loader, DI_Container $di_container ): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed
46
	public function pre_boot( App_Config $config, Hook_Loader $loader, DI_Container $di_container ): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed
47
	public function post_register( App_Config $config, Hook_Loader $loader, DI_Container $di_container ): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed
48
}
49