Completed
Push — master ( 054527...be0150 )
by Milan
01:52
created

LocalFilesystem   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 30
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A save() 0 4 1
A createURI() 0 4 1
A isFileExists() 0 4 1
A remove() 0 4 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 remove($relativePath)
34
	{
35
		return @unlink($this->createURI($relativePath));
36
	}
37
}