RenameCommand::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
namespace pastuhov\FileStream;
3
4
/**
5
 * Rename file command
6
 */
7
class RenameCommand implements CommandInterface
8
{
9
    /**
10
     * @var string destination directory
11
     */
12
    protected $dstDir;
13
14
    /**
15
     * @var string destination file suffix
16
     */
17
    protected $suffix;
18
19
    /**
20
     * @param string $dstDir
21
     * @param string $suffix
22
     */
23 3
    public function __construct($dstDir, $suffix = '')
24
    {
25 3
        $this->dstDir = rtrim($dstDir, '/');
26 3
        $this->suffix = $suffix;
27 3
    }
28
29
    /**
30
     * @param string $filename
31
     */
32 3
    public function runCommand($filename)
33
    {
34 3
        rename(
35 3
            $filename,
36 3
            $this->dstDir . '/' . basename($filename) . $this->suffix
37 3
        );
38 3
    }
39
}
40