BaseDecrypter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
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 30
ccs 12
cts 12
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A decrypt() 0 22 3
getLinks() 0 1 ?
1
<?php
2
namespace Tartana\Component\Decrypter;
3
4
use League\Flysystem\Adapter\Local;
5
use Monolog\Logger;
6
use Tartana\Mixins\LoggerAwareTrait;
7
8
abstract class BaseDecrypter implements DecrypterInterface
9
{
10
11
	use LoggerAwareTrait;
12
13 16
	public function decrypt($dlc)
14
	{
15 16
		$this->log('Started file decrypting', Logger::INFO);
16
17 16
		if (@file_exists(realpath($dlc))) {
18 7
			$dlc     = realpath($dlc);
19 7
			$fs      = new Local(dirname($dlc));
20 7
			$content = $fs->read($fs->removePathPrefix($dlc))['contents'];
21
		} else {
22 9
			$content = $dlc;
23
		}
24
25 16
		if (!$content) {
26 3
			throw new \RuntimeException('Empty content.');
27
		}
28
29 13
		$links = $this->getLinks($content);
30
31 7
		$this->log('Finished file decrypting', Logger::INFO);
32
33 7
		return $links;
34
	}
35
36
	abstract protected function getLinks($content);
37
}
38