Completed
Push — master ( b3b6a4...b2f402 )
by Sergi Tur
03:43
created

TouchSqliteFile::touchFile()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: sergi
5
 * Date: 15/03/16
6
 * Time: 19:29.
7
 */
8
namespace Acacha\Llum\Traits;
9
10
trait TouchSqliteFile
11
{
12
    /**
13
     * Touch sqlite database file.
14
     *
15
     * @param string $file
16
     */
17
    protected function touchSqliteFile($file = 'database/database.sqlite')
18
    {
19
        $this->touchFile($file);
20
    }
21
22
    /**
23
     * Touch a file.
24
     * @param string $file
25
     */
26
    protected function touchFile($file)
27
    {
28
        passthru('touch '.$file, $error);
29
        if ($error !== 0) {
30
            $this->output->writeln('<error>Error creating file '.$file.'</error>');
0 ignored issues
show
Bug introduced by
The property output does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
31
        } else {
32
            $this->output->writeln('<info>File '.$file.' created successfully</info>');
33
        }
34
    }
35
}
36