Passed
Push — master ( b59adb...796449 )
by Rick
05:25
created

ComponentTrait::fromContainer()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3.072

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
ccs 4
cts 5
cp 0.8
rs 9.6666
cc 3
eloc 5
nc 2
nop 1
crap 3.072
1
<?php
2
/**
3
 * Copyright 2017 NanoSector
4
 *
5
 * You should have received a copy of the MIT license with the project.
6
 * See the LICENSE file for more information.
7
 */
8
9
namespace Yoshi2889\Container;
10
11
trait ComponentTrait
12
{
13
	/**
14
	 * @param ComponentContainer $container
15
	 *
16
	 * @return static
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use NoType.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
17
	 * @throws NotFoundException
18
	 */
19 1
	public static function fromContainer(ComponentContainer $container)
20
	{
21 1
		$obj = $container->get(__CLASS__);
22
23 1
		if ($obj && $obj instanceof static)
24 1
			return $obj;
25
26
		throw new NotFoundException();
27
	}
28
}