FileSystemFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 7
c 1
b 0
f 0
dl 0
loc 19
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 7 2
A __construct() 0 3 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