SourceConfig   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A defaults() 0 4 1
A type() 0 3 1
A setType() 0 9 2
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