RenameCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 33
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A runCommand() 0 7 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