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

Txt::getLinks()   B

Complexity

Conditions 5
Paths 6

Size

Total Lines 21
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 5

Importance

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