Completed
Push — master ( 27271f...9988ed )
by Greg
01:45
created

AnnotationData::keys()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
namespace Consolidation\AnnotatedCommand;
3
4
use Consolidation\AnnotatedCommand\Parser\Internal\CsvUtils;
5
6
class AnnotationData extends \ArrayObject
7
{
8
    public function get($key, $default = '')
9
    {
10
        return $this->has($key) ? CsvUtils::toString($this[$key]) : $default;
11
    }
12
13
    public function getList($key, $default = [])
14
    {
15
        return $this->has($key) ? CsvUtils::toList($this[$key]) : $default;
16
    }
17
18
    public function has($key)
19
    {
20
        return isset($this[$key]);
21
    }
22
23
    public function keys()
24
    {
25
        return array_keys($this->getArrayCopy());
26
    }
27
28
    public function set($key, $value = '')
29
    {
30
        $this->offsetSet($key, $value);
31
        return $this;
32
    }
33
34
    public function append($key, $value = '')
35
    {
36
        $data = $this->offsetGet($key);
37
        if (is_array($data)) {
38
            $this->offsetSet($key, array_merge($data, $value));
39
        } elseif (is_scalar($data)) {
40
            $this->offsetSet($key, $data . $value);
41
        }
42
        return $this;
43
    }
44
}
45