Passed
Push — master ( feec22...d030f3 )
by Milan
01:50
created

Options::getFilter()   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 0
1
<?php
2
3
namespace h4kuna\Upload\Upload;
4
5
use h4kuna\Upload\Store,
6
	Nette\Http;
7
8
final class Options
9
{
10
11
	/** @var string */
12
	private $path = '';
13
14
	/** @var callback */
15
	private $extendStoredFile;
16
17
	/** @var Filename */
18
	private $filename;
19
20
	/** @var Filter */
21
	private $filter;
22
23
24
	public function __construct($path = '', callable $extendStoredFile = null, Filename $filename = null, Filter $filter = null)
25
	{
26
		if ($path !== '') {
27
			$path = trim($path, '\/') . DIRECTORY_SEPARATOR;
28
		}
29
30
		$this->path = $path;
31
		$this->filename = $filename ?: new Filename();
32
		$this->filter = $filter ?: new Filter();
33
		$this->extendStoredFile = $extendStoredFile;
34
	}
35
36
37
	/**
38
	 * @return string
39
	 */
40
	public function getPath()
41
	{
42
		return $this->path;
43
	}
44
45
46
	/**
47
	 * @param Store\File $storeFile
48
	 * @param Http\FileUpload $fileUpload
49
	 */
50
	public function runExtendStoredFile(Store\File $storeFile, Http\FileUpload $fileUpload)
51
	{
52
		$this->extendStoredFile !== null && call_user_func($this->extendStoredFile, $storeFile, $fileUpload);
53
	}
54
55
56
	/**
57
	 * @return Filename
58
	 */
59
	public function getFilename()
60
	{
61
		return $this->filename;
62
	}
63
64
65
	/**
66
	 * @return Filter
67
	 */
68
	public function getFilter()
69
	{
70
		return $this->filter;
71
	}
72
}