Completed
Push — master ( 0f8b02...a5df1d )
by Greg
02:58
created

BaseTask::configPostfix()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace Robo\Task;
3
4
use Robo\Common\InflectionTrait;
5
use Robo\Contract\InflectionInterface;
6
7
use Robo\Common\TaskIO;
8
use Robo\Contract\TaskInterface;
9
use Robo\Contract\ProgressIndicatorAwareInterface;
10
use Robo\Contract\VerbosityThresholdInterface;
11
use Robo\Common\ProgressIndicatorAwareTrait;
12
use Robo\Contract\ConfigAwareInterface;
13
use Psr\Log\LoggerAwareInterface;
14
use Robo\Contract\OutputAwareInterface;
15
16
abstract class BaseTask implements TaskInterface, LoggerAwareInterface, VerbosityThresholdInterface, ConfigAwareInterface, ProgressIndicatorAwareInterface, InflectionInterface
17
{
18
    use TaskIO; // uses LoggerAwareTrait, VerbosityThresholdTrait and ConfigAwareTrait
19
    use ProgressIndicatorAwareTrait;
20
    use InflectionTrait;
21
22
    /**
23
     * ConfigAwareInterface uses this to decide where configuration
24
     * items come from. Default is this prefix + class name + key,
25
     * e.g. `task.Remote.Ssh.remoteDir`.
26
     */
27
    protected static function configPrefix()
28
    {
29
        return 'task.';
30
    }
31
32
    /**
33
     * ConfigAwareInterface uses this to decide where configuration
34
     * items come from. Default is this prefix + class name + key,
35
     * e.g. `task.Ssh.remoteDir`.
36
     */
37
    protected static function configPostfix()
38
    {
39
        return '.settings';
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function injectDependencies(InflectionInterface $child)
46
    {
47
        if ($child instanceof LoggerAwareInterface && $this->logger) {
48
            $child->setLogger($this->logger);
49
        }
50
        if ($child instanceof ProgressIndicatorAwareInterface && $this->progressIndicator) {
51
            $child->setProgressIndicator($this->progressIndicator);
52
        }
53
        if ($child instanceof ConfigAwareInterface && $this->getConfig()) {
54
            $child->setConfig($this->getConfig());
55
        }
56
        if ($child instanceof VerbosityThresholdInterface && $this->outputAdapter()) {
57
            $child->setOutputAdapter($this->outputAdapter());
58
        }
59
    }
60
}
61