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

File   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 67
Duplicated Lines 22.39 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
c 1
b 0
f 0
lcom 0
cbo 1
dl 15
loc 67
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A __set() 8 8 2
A __get() 7 7 2
A getRelativePath() 0 4 1
A getName() 0 4 1
A getContentType() 0 4 1
A __toString() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
}