Task::getSources()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 6
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace JK\Sam\Task;
4
5
use JK\Sam\Configuration\ConfigurationInterface;
6
7
/**
8
 * Represent a task to execute with a specific filter on sources files to destination file.
9
 */
10
class Task
11
{
12
    /**
13
     * @var string
14
     */
15
    protected $name;
16
17
    /**
18
     * @var ConfigurationInterface
19
     */
20
    protected $configuration;
21
22
    /**
23
     * Task constructor.
24
     * 
25
     * @param $name
26
     * @param TaskConfiguration $configuration
27
     */
28 2
    public function __construct($name, TaskConfiguration $configuration)
29
    {
30 2
        $this->name = $name;
31 2
        $this->configuration = $configuration;
32 2
    }
33
34
    /**
35
     * @return string
36
     */
37 1
    public function getName()
38
    {
39 1
        return $this->name;
40
    }
41
42
    /**
43
     * @return ConfigurationInterface
44
     */
45 2
    public function getConfiguration()
46
    {
47 2
        return $this->configuration;
48
    }
49
50
    /**
51
     * Return the configured sources.
52
     *
53
     * @return string[]
54
     */
55 2
    public function getSources()
56
    {
57
        return $this
58 2
            ->configuration
59 2
            ->getParameter('sources');
60
    }
61
62
    /**
63
     * Define the task new sources.
64
     *
65
     * @param array $sources
66
     */
67 1
    public function setSources(array $sources)
68
    {
69
        $parameters = $this
70 1
            ->configuration
71 1
            ->getParameters();
72 1
        $parameters['sources'] = $sources;
73
74
        $this
75 1
            ->configuration
76 1
            ->setParameters($parameters);
77 1
    }
78
79
    /**
80
     * Return the configured destinations.
81
     *
82
     * @return string[]
83
     */
84 1
    public function getDestinations()
85
    {
86
        return $this
87 1
            ->configuration
88 1
            ->getParameter('destinations');
89
    }
90
91
    /**
92
     * Return true if the task is in debug mode.
93
     *
94
     * @return boolean
95
     */
96 1
    public function isDebug()
97
    {
98
        return $this
99 1
            ->configuration
100 1
            ->getParameter('debug');
101
    }
102
}
103