Parser   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 31
rs 10
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A parseContents() 0 29 5
1
<?php
2
/**
3
 * Copyright © Vaimo Group. All rights reserved.
4
 * See LICENSE_VAIMO.txt for license details.
5
 */
6
namespace Vaimo\ComposerPatches\Patch\File\Header;
7
8
class Parser
9
{
10
    public function parseContents($header)
11
    {
12
        $lines = explode(PHP_EOL, $header);
13
14
        $key = 'label';
15
16
        $data = array();
17
18
        foreach ($lines as $line) {
19
            if (strpos($line, '@') === 0) {
20
                $tag = strstr($line, ' ', true);
21
22
                if (!$tag) {
23
                    $tag = $line;
24
                }
25
26
                $key = ltrim($tag, '@');
27
28
                $line = ltrim(strstr($line, ' '), ' ');
29
            }
30
31
            if (!isset($data[$key])) {
32
                $data[$key] = array();
33
            }
34
35
            $data[$key][] = $line;
36
        }
37
38
        return array_diff_key($data, array(''));
39
    }
40
}
41