FileSystem::createProjectDirectory()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 2
1
<?php
2
namespace PressCLI\Lib;
3
4
use Symfony\Component\Console\Output\OutputInterface;
5
6
trait FileSystem
7
{
8
    /**
9
     * Create project directory.
10
     *
11
     * @return InitCommand
12
     */
13
    protected function createProjectDirectory($directory, OutputInterface $output)
14
    {
15
        $output->writeln("<info>Creating project directory...</info>");
16
17
        if (file_exists($directory)) {
18
            $output->writeln("<comment>Project directory already exists at {$directory}.</comment>");
19
20
            return $this;
21
        }
22
23
        mkdir($directory, 0755, true);
24
25
        $output->writeln("<info>Project directory created at {$directory}!</info>");
26
27
        return $this;
28
    }
29
}
30