ShieldonManager::getFirewall()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 2
rs 10
cc 1
nc 1
nop 0
1
<?php
2
namespace Ubiquity\security\shieldon;
3
4
use Psr\Http\Message\ResponseInterface;
0 ignored issues
show
Bug introduced by
The type Psr\Http\Message\ResponseInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
5
use Shieldon\Firewall\Firewall;
0 ignored issues
show
Bug introduced by
The type Shieldon\Firewall\Firewall was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Shieldon\Firewall\HttpResolver;
0 ignored issues
show
Bug introduced by
The type Shieldon\Firewall\HttpResolver was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Shieldon\Firewall\Panel;
0 ignored issues
show
Bug introduced by
The type Shieldon\Firewall\Panel was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
/**
10
 * Ubiquity\security\shieldon$ShieldonManager
11
 * This class is part of Ubiquity
12
 *
13
 * @author jc
14
 * @version 1.0.0
15
 *
16
 */
17
class ShieldonManager {
18
19
	private static Firewall $firewall;
20
21
	public static function getFirewall(): Firewall {
22
		return self::$firewall;
23
	}
24
25
	/**
26
	 * Starts th Shieldon service.
27
	 *
28
	 * @param string $writable
29
	 */
30
	public static function start(string $writable = null): void {
31
		$writable ??= \ROOT . \DS . 'cache' . \DS . 'shieldon';
32
		self::$firewall = new Firewall();
33
		self::$firewall->configure($writable);
34
		$response = self::$firewall->run();
35
		if ($response->getStatusCode() !== 200) {
36
			$httpResolver = new HttpResolver();
37
			$httpResolver($response);
38
		}
39
	}
40
41
	/**
42
	 * Creates the admin panel.
43
	 */
44
	public static function createPanel(string $uri): Panel {
45
		$panel = new Panel();
46
		self::$firewall->controlPanel($uri);
47
		return $panel;
48
	}
49
50
	/**
51
	 *
52
	 * @return ResponseInterface
53
	 */
54
	public static function run(): ResponseInterface {
55
		return self::$firewall->run();
56
	}
57
}
58