TouchSqliteFile   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A touchSqliteFile() 0 4 1
A touchFile() 0 9 2
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