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

LocalFilesystem   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 35
rs 10
c 0
b 0
f 0

6 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 createName() 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 createName(Http\FileUpload $fileUpload)
34
	{
35
		return NULL;
36
	}
37
38
	public function remove($relativePath)
39
	{
40
		return @unlink($this->createURI($relativePath));
41
	}
42
}