Passed
Push — master ( 4cb925...613187 )
by Marek
10:16
created

RemoveFinishedTicketTask::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
c 0
b 0
f 0
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace AppBuilder\Application\Module\TaskManager\Task;
6
7
use AppBuilder\Application\Configuration\ValueObject\Parameters;
8
use AppBuilder\Application\Model\ValueObject\Ticket;
9
use AppBuilder\Application\Utils\FileManager\FileManagerService;
10
use Symfony\Component\Filesystem\Exception\IOException;
11
12
class RemoveFinishedTicketTask implements Task
13
{
14
    /** @var Ticket */
15
    private $ticket;
16
17
    /** @var string */
18
    private $projectHomeDir;
19
20
    /** @var string */
21
    private $publicHostDir;
22
23
    /** @var FileManagerService */
24
    private $fileManager;
25
26 1
    public function __construct(Ticket $ticket, Parameters $applicationParams, FileManagerService $fileManager)
27
    {
28 1
        $this->ticket             = $ticket;
29 1
        $this->projectHomeDir     = $applicationParams->projectsHomeDir();
30 1
        $this->publicHostDir      = $applicationParams->symlinkTarget($ticket->key());
31 1
        $this->fileManager        = $fileManager;
32 1
    }
33
34
    /**
35
     * Removes application and symlinks directories when its finished.
36
     *
37
     * @throws IOException
38
     */
39 1
    public function execute() : bool
40
    {
41 1
        $this->fileManager->remove($this->projectHomeDir . $this->ticket->key());
42 1
        $this->fileManager->remove($this->publicHostDir);
43
44 1
        return true;
45
    }
46
}
47