Test Failed
Pull Request — master (#97)
by Gildonei
03:38
created

YamlImportation   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
eloc 11
c 1
b 0
f 1
dl 0
loc 16
ccs 0
cts 14
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 14 4
1
<?php
2
namespace Ubiquity\translation\import;
3
4
class YamlImportation extends AbstractImportation {
5
6
	public function load() {
7
		$content = file_get_contents($this->file);
8
		$lines = explode("\n", $content);
9
		$result = [];
10
		foreach ($lines as $line) {
11
			$line = trim($line);
12
			if (substr($line, 0, strlen('#')) !== '#') {
13
				$kv = explode(':', $line);
14
				if (sizeof($kv) == 2) {
15
					$result[trim($kv[0])] = trim($kv[1]);
16
				}
17
			}
18
		}
19
		return $result;
20
	}
21
}
22
23