Passed
Push — master ( b3e27e...db1dbb )
by Jean-Christophe
01:47
created

ContentSecurityManager   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
eloc 6
c 1
b 0
f 1
dl 0
loc 15
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getNonce() 0 2 1
A isStarted() 0 2 1
A start() 0 3 1
1
<?php
2
namespace Ubiquity\security\csp;
3
4
class ContentSecurityManager {
5
6
	private static NonceGenerator $nonceGenerator;
7
8
	public static function start(string $nonceGeneratorClass = null) {
9
		$nonceGeneratorClass ??= NonceGenerator::class;
10
		self::$nonceGenerator = new $nonceGeneratorClass();
11
	}
12
13
	public static function getNonce(string $name) {
14
		return self::$nonceGenerator->getNonce($name);
15
	}
16
17
	public static function isStarted(): bool {
18
		return isset(self::$nonceGenerator);
19
	}
20
}
21
22