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

ComponentTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 80%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 18
ccs 4
cts 5
cp 0.8
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromContainer() 0 9 3
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
}