Formatter::formatComment()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Codervio\Envmanager\Editor;
4
5
class Formatter
6
{
7
    protected $values = null;
8
9
    public function setKeys($item)
10
    {
11
        if (array_key_exists('key', $item)) {
12
            $key = $item['key'];
13
            $value = array_key_exists('value', $item) ? '"'.$item['value'].'"' : null;
14
            $comment = array_key_exists('comment', $item) ? $item['comment'] : null;
15
            $export = array_key_exists('export', $item) ? $item['export'] : null;
16
17
            $packArray = compact('key', 'value', 'comment', 'export');
18
19
            $this->values = $packArray;
20
        }
21
22
        return $this->values;
23
    }
24
25
    public function formatSetter($value)
26
    {
27
        if ($value['export']) {
28
            $value['export'] = 'export ';
29
        } else {
30
            $value['export'] = '';
31
        }
32
33
        if (isset($value['comment'])) {
34
            $value['comment'] = ' # '.$value['comment'];
35
        }
36
37
        return (string)"{$value['export']}{$value['key']}={$value['value']}{$value['comment']}";
38
    }
39
40
    public function formatComment($comment)
41
    {
42
        return (string)'# '.$comment;
43
    }
44
45
    public function addEmptyLine()
46
    {
47
        return (string)PHP_EOL;
48
    }
49
}