Completed
Push — master ( e6850e...e5139b )
by Pol
02:35 queued 21s
created

Touch   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 23
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A exec() 0 11 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace drupol\phpvfs\Command;
6
7
use drupol\phpvfs\Filesystem\FilesystemInterface;
8
use drupol\phpvfs\Node\File;
9
10
class Touch
11
{
12
    /**
13
     * @param \drupol\phpvfs\Filesystem\FilesystemInterface $vfs
14
     * @param string $id
15
     * @param string $content
16
     * @param array $attributes
17
     *
18
     * @throws \Exception
19
     *
20
     * @return \drupol\phpvfs\Node\File
21
     */
22 1
    public static function exec(FilesystemInterface $vfs, string $id, string $content = '', array $attributes = [])
23
    {
24 1
        if (Exist::exec($vfs, $id)) {
25 1
            throw new \Exception('File already exist.');
26
        }
27
28 1
        $file = File::create($id, $content, $attributes);
29
30 1
        $vfs->getCwd()->add($file);
31
32 1
        return $file;
33
    }
34
}
35