ModuleMaker::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: thales
5
 * Date: 24/11/2018
6
 * Time: 22:41
7
 */
8
9
namespace Saci\Console\Infrastructure\Domain\Services;
10
11
12
use Saci\Console\Domain\Entity\Module;
13
use Saci\Console\Domain\Exceptions\ModuleAlreadyExists;
14
use Symfony\Component\Filesystem\Filesystem;
15
16
class ModuleMaker implements \Saci\Console\Domain\Services\ModuleMaker
17
{
18
19
    /**
20
     * @var Filesystem
21
     */
22
    private $filesystem;
23
24 4
    public function __construct(Filesystem $filesystem)
25
    {
26 4
        $this->filesystem = $filesystem;
27 4
    }
28
29
    /**
30
     * @param Module $module
31
     * @throws \Saci\Console\Domain\Exceptions\ModuleAlreadyExists
32
     */
33 3
    public function make(Module $module)
34
    {
35
36 3
        if ($this->filesystem->exists($module->getPathModule())) {
37 1
            throw new ModuleAlreadyExists($module->getName());
38
        }
39
40 2
        $this->filesystem->mkdir($module->getPaths());
41
    }
42
}