FileSystemFactory::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Oliverde8\PhpEtlBundle\Services;
4
5
use Oliverde8\Component\PhpEtl\Model\File\FileSystemInterface;
6
use Oliverde8\Component\PhpEtl\Model\File\LocalFileSystem;
7
use Oliverde8\PhpEtlBundle\Entity\EtlExecution;
8
use Psr\Log\LoggerInterface;
9
10
class FileSystemFactory implements FileSystemFactoryInterface
11
{
12
    private ChainWorkDirManager $chainWorkDirManager;
13
14
    /** @var LoggerInterface[] */
15
    private array $loggers = [];
16
17
    public function __construct(ChainWorkDirManager $chainWorkDirManager)
18
    {
19
        $this->chainWorkDirManager = $chainWorkDirManager;
20
    }
21
22
    public function get(EtlExecution $execution): FileSystemInterface
23
    {
24
        if (!isset($this->loggers[$execution->getId()])) {
25
            $this->loggers[$execution->getId()] = new LocalFileSystem($this->chainWorkDirManager->getLocalTmpWorkDir($execution));
26
        }
27
28
        return $this->loggers[$execution->getId()];
29
    }
30
}
31