Test Setup Failed
Push — master ( 9b017d...5cb4e7 )
by Milan
02:16
created

LocalFilesystem::remove()   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
		if ($relativePath instanceof Upload\IStoreFile) {
26
			$relativePath = $relativePath->getRelativePath();
27
		}
28
		return $this->destinationDir . DIRECTORY_SEPARATOR . $relativePath;
29
	}
30
31
	public function isFileExists($relativePath)
32
	{
33
		return is_file($this->createURI($relativePath));
34
	}
35
36
	public function createName(Http\FileUpload $fileUpload)
37
	{
38
		return NULL;
39
	}
40
41
	public function remove($relativePath)
42
	{
43
		return @unlink($this->createURI($relativePath));
44
	}
45
}