ContentHashNamingStrategy   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A provideName() 0 14 2
1
<?php
2
3
namespace FileNamingResolver\NamingStrategy;
4
5
use FileNamingResolver\FileInfo;
6
7
/**
8
 * @author Victor Bocharsky <[email protected]>
9
 */
10
class ContentHashNamingStrategy extends AbstractHashNamingStrategy
11
{
12
    /**
13
     * {@inheritdoc}
14
     *
15
     * @throws \InvalidArgumentException If source file does not exist
16
     */
17 4
    public function provideName(FileInfo $srcFileInfo)
18
    {
19 4
        if (!$srcFileInfo->isFile()) {
20 1
            throw new \InvalidArgumentException(sprintf(
21 1
                'The source file does not exist on "%s" specified path.',
22 1
                $srcFileInfo->toString()
23 1
            ));
24
        }
25 3
        $hash = hash_file($this->algorithm, $srcFileInfo->toString());
26
27 3
        $dstFileInfo = $this->provideNameByHash($srcFileInfo, $hash);
28
29 3
        return $dstFileInfo;
30
    }
31
}
32