Completed
Push — master ( 3cea42...86bc77 )
by Milan
06:50
created

File::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace h4kuna\Upload\Store;
4
5
use h4kuna\Upload;
6
7
class File implements Upload\IStoreFile
8
{
9
	/** @var string */
10
	private $relativePath;
11
12
	/** @var string */
13
	private $name;
14
15
	/** @var string */
16
	private $contentType;
17
18
	/** @var array */
19
	private $extend = [];
20
21
	public function __construct($relativePath, $name, $contentType)
22
	{
23
		$this->relativePath = $relativePath;
24
		$this->name = $name;
25
		$this->contentType = $contentType;
26
	}
27
28 View Code Duplication
	public function __set($name, $value)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
29
	{
30
		if (isset($this->{$name})) {
31
			throw new Upload\InvalidArgumentException('This name "' . $name . '" is reserved.');
32
		}
33
34
		return $this->extend[$name] = $value;
35
	}
36
37 View Code Duplication
	public function __get($name)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
	{
39
		if (!isset($this->extend[$name])) {
40
			throw new Upload\InvalidArgumentException('This name "' . $name . '" does not exists.');
41
		}
42
		return $this->extend[$name];
43
	}
44
45
	/**
46
	 * @return string
47
	 */
48
	public function getRelativePath()
49
	{
50
		return $this->relativePath;
51
	}
52
53
	/**
54
	 * @return string
55
	 */
56
	public function getName()
57
	{
58
		return $this->name;
59
	}
60
61
	/**
62
	 * @return string
63
	 */
64
	public function getContentType()
65
	{
66
		return $this->contentType;
67
	}
68
69
	public function __toString()
70
	{
71
		return (string)$this->getRelativePath();
72
	}
73
}