Passed
Push — main ( 3e88e0...2cfca0 )
by De Cramer
09:34 queued 07:37
created

ExecutionContext::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 4
1
<?php
2
3
namespace Oliverde8\PhpEtlBundle\Model;
4
5
use Oliverde8\Component\PhpEtl\Model\File\FileSystemInterface;
6
use Oliverde8\Component\PhpEtl\Model\File\LocalFileSystem;
7
use Psr\Log\LoggerInterface;
8
9
class ExecutionContext extends \Oliverde8\Component\PhpEtl\Model\ExecutionContext
10
{
11
    protected string $workDir;
12
13
    public function __construct(array $parameters, FileSystemInterface $fileSystem, LoggerInterface $logger, string $logPath)
14
    {
15
        parent::__construct($parameters, $fileSystem);
16
        $this->logger = $logger;
17
        $this->workDir = $logPath;
18
    }
19
20
    protected function finalise(): void
21
    {
22
23
24
        if ($this->fileSystem instanceof LocalFileSystem && $this->fileSystem->getRootPath() == $this->workDir) {
25
            // Local file system needs no moving of the log file.
26
            return;
27
        }
28
29
        $logPath = $this->workDir . "/execution.log";
30
        if(file_exists($logPath)) {
31
            $this->fileSystem->writeStream("execution.log", fopen($logPath, 'r'));
32
        }
33
    }
34
}
35