1 | <?php |
||
10 | abstract class AbstractHashNamingStrategy extends AbstractNamingStrategy |
||
11 | { |
||
12 | const ALGORITHM_MD5 = 'md5'; |
||
13 | const ALGORITHM_SHA1 = 'sha1'; |
||
14 | |||
15 | /** |
||
16 | * @var string Hash algorithm |
||
17 | */ |
||
18 | protected $algorithm; |
||
19 | |||
20 | /** |
||
21 | * @var int Count of parts |
||
22 | */ |
||
23 | protected $partCount; |
||
24 | |||
25 | /** |
||
26 | * @var int Length of each part |
||
27 | */ |
||
28 | protected $partLength; |
||
29 | |||
30 | /** |
||
31 | * @var bool |
||
32 | */ |
||
33 | protected $shouldFullFilenameBeKept; |
||
34 | |||
35 | 10 | /** |
|
36 | * @param string $algorithm |
||
37 | 10 | * @param int $partCount |
|
38 | 10 | * @param int $partLength |
|
39 | 10 | * @param bool $shouldFullFilenameBeKept |
|
40 | 10 | */ |
|
41 | public function __construct($algorithm = self::ALGORITHM_MD5, $partCount = 2, $partLength = 2, $shouldFullFilenameBeKept = false) |
||
48 | 2 | ||
49 | /** |
||
50 | 2 | * @param FileInfo $srcFileInfo |
|
51 | 2 | * @param string $hash |
|
52 | 2 | * |
|
53 | 2 | * @return FileInfo |
|
54 | 2 | */ |
|
55 | 2 | public function provideNameByHash(FileInfo $srcFileInfo, $hash) |
|
74 | |||
75 | 2 | /** |
|
76 | * @return string |
||
77 | 2 | */ |
|
78 | public function getAlgorithm() |
||
82 | |||
83 | 2 | /** |
|
84 | * @return int |
||
85 | 2 | */ |
|
86 | public function getPartCount() |
||
90 | |||
91 | /** |
||
92 | * @return int |
||
93 | */ |
||
94 | public function getPartLength() |
||
98 | |||
99 | /** |
||
100 | * @return boolean |
||
101 | */ |
||
102 | public function shouldFullFilenameBeKept() |
||
106 | } |
||
107 |