Passed
Push — master ( c4d71c...15ef35 )
by Morris
13:37 queued 11s
created

Version::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 9
dl 0
loc 20
rs 9.9666
c 0
b 0
f 0

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
declare(strict_types=1);
3
/**
4
 * @copyright Copyright (c) 2018 Robin Appelman <[email protected]>
5
 *
6
 * @license GNU AGPL version 3 or any later version
7
 *
8
 * This program is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU Affero General Public License as
10
 * published by the Free Software Foundation, either version 3 of the
11
 * License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU Affero General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Affero General Public License
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
 *
21
 */
22
23
namespace OCA\Files_Versions\Versions;
24
25
use OCP\Files\FileInfo;
26
use OCP\IUser;
27
28
class Version implements IVersion {
29
	/** @var int */
30
	private $timestamp;
31
32
	/** @var int */
33
	private $revisionId;
34
35
	/** @var string */
36
	private $name;
37
38
	/** @var int */
39
	private $size;
40
41
	/** @var string */
42
	private $mimetype;
43
44
	/** @var string */
45
	private $path;
46
47
	/** @var FileInfo */
48
	private $sourceFileInfo;
49
50
	/** @var IVersionBackend */
51
	private $backend;
52
53
	/** @var IUser */
54
	private $user;
55
56
	public function __construct(
57
		int $timestamp,
58
		int $revisionId,
59
		string $name,
60
		int $size,
61
		string $mimetype,
62
		string $path,
63
		FileInfo $sourceFileInfo,
64
		IVersionBackend $backend,
65
		IUser $user
66
	) {
67
		$this->timestamp = $timestamp;
68
		$this->revisionId = $revisionId;
69
		$this->name = $name;
70
		$this->size = $size;
71
		$this->mimetype = $mimetype;
72
		$this->path = $path;
73
		$this->sourceFileInfo = $sourceFileInfo;
74
		$this->backend = $backend;
75
		$this->user = $user;
76
	}
77
78
	public function getBackend(): IVersionBackend {
79
		return $this->backend;
80
	}
81
82
	public function getSourceFile(): FileInfo {
83
		return $this->sourceFileInfo;
84
	}
85
86
	public function getRevisionId(): int {
87
		return $this->revisionId;
88
	}
89
90
	public function getTimestamp(): int {
91
		return $this->timestamp;
92
	}
93
94
	public function getSize(): int {
95
		return $this->size;
96
	}
97
98
	public function getSourceFileName(): string {
99
		return $this->name;
100
	}
101
102
	public function getMimeType(): string {
103
		return $this->mimetype;
104
	}
105
106
	public function getVersionPath(): string {
107
		return $this->path;
108
	}
109
110
	public function getUser(): IUser {
111
		return $this->user;
112
	}
113
}
114