SubstitutionFactory::inPlace()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Cocotte\Shell\EnvironmentSubstitution;
4
5
use Cocotte\Console\Style;
6
use Cocotte\Filesystem\Filesystem;
7
use Cocotte\Finder\Finder;
8
use Cocotte\Shell\ProcessRunner;
9
10
final class SubstitutionFactory
11
{
12
    /**
13
     * @var Style
14
     */
15
    private $style;
16
17
    /**
18
     * @var ProcessRunner
19
     */
20
    private $processRunner;
21
22
    /**
23
     * @var Filesystem
24
     */
25
    private $filesystem;
26
27
    public function __construct(Style $style, ProcessRunner $processRunner, Filesystem $filesystem)
28
    {
29
        $this->style = $style;
30
        $this->processRunner = $processRunner;
31
        $this->filesystem = $filesystem;
32
    }
33
34
    public function dumpFile(string $filename, string $contents): DumpFileSubstitution
35
    {
36
        return new DumpFileSubstitution(
37
            $filename,
38
            $contents,
39
            $this->style,
40
            $this->processRunner,
41
            $this->filesystem
42
        );
43
    }
44
45
    public function inPlace(Finder $finder): InPlaceSubstitution
46
    {
47
        return new InPlaceSubstitution(
48
            $finder,
49
            $this->style,
50
            $this->processRunner,
51
            $this->filesystem
52
        );
53
    }
54
}