Completed
Pull Request — master (#1)
by Greg
02:04
created

PropertyParser::parse()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
namespace Consolidation\OutputFormatters\Transformations;
3
4
use Symfony\Component\Yaml\Yaml;
5
6
/**
7
 * Transform a string of properties into a PHP associative array.
8
 *
9
 * Input:
10
 *
11
 *   one: red
12
 *   two: white
13
 *   three: blue
14
 *
15
 * Output:
16
 *
17
 *   [
18
 *      'one' => 'red',
19
 *      'two' => 'white',
20
 *      'three' => 'blue',
21
 *   ]
22
 */
23
class PropertyParser
24
{
25
    public static function parse($data)
26
    {
27
        if (is_string($data)) {
28
            $data = Yaml::parse(trim($data));
29
        }
30
        return $data;
31
    }
32
}
33