Completed
Push — master ( 3f6851...6e71e0 )
by Milan
03:43
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\IDriver,
6
	Nette\Http;
7
use h4kuna\Upload\IStoreFile;
8
9
class LocalFilesystem implements IDriver
10
{
11
	/** @var string */
12
	private $destinationDir;
13
14
	public function __construct($destinationDir)
15
	{
16
		$this->destinationDir = $destinationDir;
17
	}
18
19
	public function save(Http\FileUpload $fileUpload, $pathname)
20
	{
21
		$fileUpload->move($this->createURI($pathname));
22
	}
23
24
	public function createURI($relativePath)
25
	{
26
		if ($relativePath instanceof IStoreFile) {
27
			$relativePath = $relativePath->getRelativePath();
28
		}
29
		return $this->destinationDir . DIRECTORY_SEPARATOR . $relativePath;
30
	}
31
32
	public function isFileExists($pathname)
33
	{
34
		return is_file($this->createURI($pathname));
35
	}
36
37
	public function createName(Http\FileUpload $fileUpload)
38
	{
39
		return NULL;
40
	}
41
42
}