TouchSqliteFile::touchSqliteFile()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Acacha\Llum\Traits;
4
5
use Symfony\Component\Console\Output\OutputInterface;
6
7
/**
8
 * Class TouchSqliteFile.
9
 *
10
 * @property OutputInterface $output
11
 */
12
trait TouchSqliteFile
13
{
14
    /**
15
     * Touch sqlite database file.
16
     *
17
     * @param string $file
18
     */
19
    protected function touchSqliteFile($file = 'database/database.sqlite')
20
    {
21
        $this->touchFile($file);
22
    }
23
24
    /**
25
     * Touch a file.
26
     *
27
     * @param string $file
28
     */
29
    protected function touchFile($file)
30
    {
31
        passthru('touch '.$file, $error);
32
        if ($error !== 0) {
33
            $this->output->writeln('<error>Error creating file '.$file.'</error>');
34
        } else {
35
            $this->output->writeln('<info>File '.$file.' created successfully</info>');
36
        }
37
    }
38
}
39