Touch::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 6
cts 6
cp 1
rs 9.8666
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Twistor\Flysystem\Plugin;
4
5
use League\Flysystem\Util;
6
7
class Touch extends AbstractPlugin
8
{
9
    /**
10
     * @inheritdoc
11
     */
12 210
    public function getMethod()
13
    {
14 210
        return 'touch';
15
    }
16
17
    /**
18
     * Emulates touch().
19
     *
20
     * @param string $path
21
     *
22
     * @return bool True on success, false on failure.
23
     */
24 27
    public function handle($path)
25
    {
26 27
        $path = Util::normalizePath($path);
27
28 27
        $adapter = $this->filesystem->getAdapter();
29
30 27
        if ($adapter->has($path)) {
31 6
            return true;
32
        }
33
34 27
        return (bool) $adapter->write($path, '', $this->defaultConfig());
35
    }
36
}
37