ResultTaskFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 10
c 1
b 0
f 0
dl 0
loc 26
ccs 10
cts 10
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createCsvResultTask() 0 9 1
1
<?php
2
declare(strict_types=1);
3
4
namespace IntegerNet\DeployerTimer;
5
6
use Deployer\Deployer;
7
use Deployer\Task\Task;
8
9
class ResultTaskFactory
10
{
11
    /**
12
     * @var TimerTaskDecorator
13
     */
14
    private $timer;
15
    /**
16
     * @var Deployer
17
     */
18
    private $deployer;
19
20 3
    public function __construct(Deployer $deployer, TimerTaskDecorator $timer)
21
    {
22 3
        $this->deployer = $deployer;
23 3
        $this->timer = $timer;
24 3
    }
25
26 3
    public function createCsvResultTask($fileName): string
27
    {
28 3
        $taskName = uniqid('timer_result-', true);
29
        $taskBody = function () use ($fileName) {
30 3
            file_put_contents($fileName, $this->timer->resultsAsCsv());
31 3
        };
32 3
        $this->deployer->tasks->set($taskName, new Task($taskName, $taskBody));
33
34 3
        return $taskName;
35
    }
36
}
37