Txt::getLinks()   B
last analyzed

Complexity

Conditions 5
Paths 6

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 5

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 18
ccs 11
cts 11
cp 1
rs 8.8571
cc 5
eloc 11
nc 6
nop 1
crap 5
1
<?php
2
namespace Tartana\Component\Decrypter;
3
4
use Tartana\Util;
5
6
class Txt extends BaseDecrypter
7
{
8
9 4
	public function getLinks($content)
10
	{
11 4
		$mustUnset = false;
12 4
		$links     = explode(PHP_EOL, $content);
13 4
		foreach ($links as $key => $link) {
14 4
			$uri = Util::parseUrl($link);
15 4
			if (!$uri['scheme']) {
16 2
				unset($links[$key]);
17 4
				$mustUnset = true;
18
			}
19
		}
20
21 4
		if ($mustUnset && empty($links)) {
22 2
			throw new \RuntimeException('Invalid content');
23
		}
24
25 2
		return $links;
26
	}
27
}
28