DeleteStrategy::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
/**
3
 * @author stev leibelt <[email protected]>
4
 * @since 2014-06-07
5
 */
6
7
namespace Net\Bazzline\Component\Locator\FileExistsStrategy;
8
9
/**
10
 * Class DeleteStrategy
11
 * @package Net\Bazzline\Component\Locator\FileExistsStrategy
12
 */
13
class DeleteStrategy extends AbstractStrategy
14
{
15
    /**
16
     * @throws RuntimeException
17
     */
18
    public function execute()
19
    {
20
        $fullQualifiedFilePath = $this->getFilePath() . DIRECTORY_SEPARATOR .
21
            $this->getFileName();
22
        $fileCouldNotBeRemoved = (unlink($fullQualifiedFilePath) !== true);
23
24
        if ($fileCouldNotBeRemoved) {
25
            throw new RuntimeException(
26
                'could not delete file "' . $fullQualifiedFilePath . '"'
27
            );
28
        }
29
    }
30
}