Completed
Pull Request — master (#138)
by Loïc
04:36 queued 01:35
created

EnsureDirectoryExistsAndIsWritable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 35
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A ensureDirectoryExistsAndIsWritable() 0 8 1
1
<?php
2
3
/*
4
 * This file is part of monofony.
5
 *
6
 * (c) Mobizel
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace App\Command\Helper;
13
14
use App\Installer\Checker\CommandDirectoryChecker;
15
use Symfony\Component\Console\Output\OutputInterface;
16
17
trait EnsureDirectoryExistsAndIsWritable
18
{
19
    /**
20
     * @var CommandDirectoryChecker
21
     */
22
    private $commandDirectoryChecker;
23
24
    /**
25
     * @var string
26
     */
27
    private $commandName;
28
29
    /**
30
     * @param CommandDirectoryChecker $commandDirectoryChecker
31
     * @param string                  $commandName
32
     */
33
    public function __construct(CommandDirectoryChecker $commandDirectoryChecker, string $commandName)
34
    {
35
        $this->commandDirectoryChecker = $commandDirectoryChecker;
36
        $this->commandName = $commandName;
37
    }
38
39
    /**
40
     * @param string          $directory
41
     * @param OutputInterface $output
42
     */
43
    private function ensureDirectoryExistsAndIsWritable($directory, OutputInterface $output)
0 ignored issues
show
Best Practice introduced by
Using PHP4-style constructors that are named like the class is not recommend; better use the more explicit __construct method.
Loading history...
44
    {
45
        $checker = $this->commandDirectoryChecker;
46
        $checker->setCommandName($this->commandName);
47
48
        $checker->ensureDirectoryExists($directory, $output);
49
        $checker->ensureDirectoryIsWritable($directory, $output);
50
    }
51
}
52