Passed
Push — master ( 868bbf...054527 )
by Milan
01:31
created

LocalFilesystem::createName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace h4kuna\Upload\Driver;
4
5
use h4kuna\Upload,
6
	Nette\Http;
7
8
class LocalFilesystem implements Upload\IDriver
9
{
10
	/** @var string */
11
	private $destinationDir;
12
13
	public function __construct($destinationDir)
14
	{
15
		$this->destinationDir = $destinationDir;
16
	}
17
18
	public function save(Http\FileUpload $fileUpload, $relativePath)
19
	{
20
		$fileUpload->move($this->createURI($relativePath));
21
	}
22
23
	public function createURI($relativePath)
24
	{
25
		return $this->destinationDir . DIRECTORY_SEPARATOR . Upload\Utils::makeRelativePath($relativePath);
26
	}
27
28
	public function isFileExists($relativePath)
29
	{
30
		return is_file($this->createURI($relativePath));
31
	}
32
33
	public function createName(Http\FileUpload $fileUpload)
34
	{
35
		return NULL;
36
	}
37
38
	public function remove($relativePath)
39
	{
40
		return @unlink($this->createURI($relativePath));
41
	}
42
}