Passed
Pull Request — master (#2)
by Pol
02:28
created

AppendTask::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 0
loc 15
ccs 0
cts 12
cp 0
crap 2
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace PhpTaskman\Core\Plugin\Task;
6
7
use PhpTaskman\Core\Plugin\BaseTask;
8
use Robo\Task\File\loadTasks;
9
10
final class AppendTask extends BaseTask
11
{
12
    use loadTasks;
13
14
    public const ARGUMENTS = [
15
        'file',
16
        'text',
17
    ];
18
    public const NAME = 'append';
19
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function run()
24
    {
25
        $arguments = $this->getTaskArguments();
26
27
        /** @var \PhpTaskman\Core\Plugin\Task\ProcessTask $processTask */
28
        $processTask = $this->task(ProcessTask::class);
29
        $processTask->setTaskArguments([
30
            'from' => $arguments['file'],
31
            'to' => $arguments['file'],
32
        ]);
33
34
        return $this->collectionBuilder()->addTaskList([
35
            $this->taskWriteToFile($arguments['file'])->append()->text($arguments['text']),
36
            $processTask,
37
        ])->run();
38
    }
39
}
40