Completed
Push — master ( 48abf8...8f7739 )
by C
13:50
created

DecrypterFactory::createDecryptor()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 20
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 20
ccs 9
cts 9
cp 1
rs 9.4285
cc 3
eloc 9
nc 3
nop 1
crap 3
1
<?php
2
namespace Tartana\Component\Decrypter;
3
use Tartana\Mixins\LoggerAwareTrait;
4
5
class DecrypterFactory
6
{
7
	use LoggerAwareTrait;
8
9
	/**
10
	 *
11
	 * @param string $filename
0 ignored issues
show
Documentation introduced by
There is no parameter named $filename. Did you maybe mean $fileName?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
12
	 * @return \Tartana\Component\Decrypter\DecrypterInterface
13
	 */
14 5
	public function createDecryptor ($fileName)
15
	{
16 5
		$className = 'Tartana\\Component\\Decrypter\\' . ucfirst(strtolower(pathinfo($fileName, PATHINFO_EXTENSION)));
17
18
		// Check if the class exists for the host to download
19 5
		if (! class_exists($className))
20
		{
21 2
			return null;
22
		}
23
24 3
		$decrypter = new $className();
25 3
		if (! $decrypter instanceof DecrypterInterface)
26
		{
27 1
			return null;
28
		}
29
30 2
		$decrypter->setLogger($this->getLogger());
31
32 2
		return $decrypter;
33
	}
34
}