DecrypterFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 28
ccs 9
cts 9
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createDecryptor() 0 18 3
1
<?php
2
namespace Tartana\Component\Decrypter;
3
4
use Tartana\Mixins\LoggerAwareTrait;
5
6
class DecrypterFactory
7
{
8
	use LoggerAwareTrait;
9
10
	/**
11
	 *
12
	 * @param string $fileName
13
	 * @return \Tartana\Component\Decrypter\DecrypterInterface
14
	 */
15 5
	public function createDecryptor($fileName)
16
	{
17 5
		$className = 'Tartana\\Component\\Decrypter\\' . ucfirst(strtolower(pathinfo($fileName, PATHINFO_EXTENSION)));
18
19
		// Check if the class exists for the host to download
20 5
		if (!class_exists($className)) {
21 2
			return null;
22
		}
23
24 3
		$decrypter = new $className();
25 3
		if (!$decrypter instanceof DecrypterInterface) {
26 1
			return null;
27
		}
28
29 2
		$decrypter->setLogger($this->getLogger());
30
31 2
		return $decrypter;
32
	}
33
}
34