SourceConfig::defaults()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Charcoal\Source;
4
5
use InvalidArgumentException;
6
7
// From 'charcoal-config'
8
use Charcoal\Config\AbstractConfig;
9
10
/**
11
 * Source Config
12
 */
13
class SourceConfig extends AbstractConfig
14
{
15
    /**
16
     * @var string $type
17
     */
18
    private $type;
19
20
    /**
21
     * @return array
22
     */
23
    public function defaults()
24
    {
25
        return [
26
            'type' => ''
27
        ];
28
    }
29
30
    /**
31
     * @param string $type The type of source.
32
     * @throws InvalidArgumentException If parameter is not a string.
33
     * @return self
34
     */
35
    public function setType($type)
36
    {
37
        if (!is_string($type)) {
0 ignored issues
show
introduced by
The condition is_string($type) is always true.
Loading history...
38
            throw new InvalidArgumentException(
39
                'Source type must be a string.'
40
            );
41
        }
42
        $this->type = $type;
43
        return $this;
44
    }
45
46
    /**
47
     * @return string
48
     */
49
    public function type()
50
    {
51
        return $this->type;
52
    }
53
}
54