CheckIfUsingFrameworkInstance()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
/**
3
* @author SignpostMarv
4
*/
5
declare(strict_types=1);
6
7
namespace SignpostMarv\DaftFramework;
8
9
use BadMethodCallException;
10
11
trait AttachDaftFramework
12
{
13
	/**
14
	* @var Framework|null
15
	*/
16
	protected $daftFrameworkInstance;
17
18 2
	public function AttachDaftFramework(Framework $framework) : void
19
	{
20 2
		if ($this->daftFrameworkInstance instanceof Framework) {
21 1
			throw new BadMethodCallException(
22 1
				'Framework must not be attached if a framework is already attached!'
23
			);
24
		}
25
26 2
		$this->daftFrameworkInstance = $framework;
27 2
	}
28
29 2
	public function DetachDaftFramework() : ? Framework
30
	{
31 2
		$out = $this->daftFrameworkInstance;
32
33 2
		if ($out instanceof Framework) {
34 1
			$this->daftFrameworkInstance = null;
35
		}
36
37 2
		return $out;
38
	}
39
40 2
	public function GetDaftFramework() : ? Framework
41
	{
42 2
		return $this->daftFrameworkInstance;
43
	}
44
45 1
	public function CheckIfUsingFrameworkInstance(Framework ...$instances) : bool
46
	{
47 1
		return in_array($this->daftFrameworkInstance, $instances, true);
48
	}
49
}
50