Passed
Push — master ( 0815be...726d01 )
by Morris
16:26 queued 11s
created

SystemTag::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @copyright Copyright (c) 2016, ownCloud, Inc.
7
 *
8
 * @author Joas Schilling <[email protected]>
9
 * @author Roeland Jago Douma <[email protected]>
10
 * @author Vincent Petry <[email protected]>
11
 *
12
 * @license AGPL-3.0
13
 *
14
 * This code is free software: you can redistribute it and/or modify
15
 * it under the terms of the GNU Affero General Public License, version 3,
16
 * as published by the Free Software Foundation.
17
 *
18
 * This program is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
 * GNU Affero General Public License for more details.
22
 *
23
 * You should have received a copy of the GNU Affero General Public License, version 3,
24
 * along with this program. If not, see <http://www.gnu.org/licenses/>
25
 *
26
 */
27
28
namespace OC\SystemTag;
29
30
use OCP\SystemTag\ISystemTag;
31
32
class SystemTag implements ISystemTag {
33
34
	/**
35
	 * @var string
36
	 */
37
	private $id;
38
39
	/**
40
	 * @var string
41
	 */
42
	private $name;
43
44
	/**
45
	 * @var bool
46
	 */
47
	private $userVisible;
48
49
	/**
50
	 * @var bool
51
	 */
52
	private $userAssignable;
53
54
	/**
55
	 * Constructor.
56
	 *
57
	 * @param string $id tag id
58
	 * @param string $name tag name
59
	 * @param bool $userVisible whether the tag is user visible
60
	 * @param bool $userAssignable whether the tag is user assignable
61
	 */
62
	public function __construct(string $id, string $name, bool $userVisible, bool $userAssignable) {
63
		$this->id = $id;
64
		$this->name = $name;
65
		$this->userVisible = $userVisible;
66
		$this->userAssignable = $userAssignable;
67
	}
68
69
	/**
70
	 * {@inheritdoc}
71
	 */
72
	public function getId(): string {
73
		return $this->id;
74
	}
75
76
	/**
77
	 * {@inheritdoc}
78
	 */
79
	public function getName(): string {
80
		return $this->name;
81
	}
82
83
	/**
84
	 * {@inheritdoc}
85
	 */
86
	public function isUserVisible(): bool {
87
		return $this->userVisible;
88
	}
89
90
	/**
91
	 * {@inheritdoc}
92
	 */
93
	public function isUserAssignable(): bool {
94
		return $this->userAssignable;
95
	}
96
97
	/**
98
	 * {@inheritdoc}
99
	 */
100
	public function getAccessLevel(): int {
101
		if ($this->userVisible) {
102
			if ($this->userAssignable) {
103
				return self::ACCESS_LEVEL_PUBLIC;
104
			} else {
105
				return self::ACCESS_LEVEL_RESTRICTED;
106
			}
107
		} else {
108
			return self::ACCESS_LEVEL_INVISIBLE;
109
		}
110
	}
111
}
112