Board   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 48
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A jsonSerialize() 0 14 2
A setLabels() 0 5 2
A setAcl() 0 5 2
1
<?php
2
/**
3
 * @copyright Copyright (c) 2016 Julius Härtl <[email protected]>
4
 *
5
 * @author Julius Härtl <[email protected]>
6
 *
7
 * @license GNU AGPL version 3 or any later version
8
 *  
9
 *  This program is free software: you can redistribute it and/or modify
10
 *  it under the terms of the GNU Affero General Public License as
11
 *  published by the Free Software Foundation, either version 3 of the
12
 *  License, or (at your option) any later version.
13
 *  
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU Affero General Public License for more details.
18
 *  
19
 *  You should have received a copy of the GNU Affero General Public License
20
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 *  
22
 */
23
24
namespace OCA\Deck\Db;
25
26
use JsonSerializable;
27
28
class Board extends RelationalEntity implements JsonSerializable {
29
30
	public $id;
31
	protected $title;
32
	protected $owner;
33
	protected $color;
34
	protected $archived = false;
35
	protected $labels;
36
	protected $acl;
37
	protected $shared;
38
39
	public function __construct() {
40
		$this->addType('id', 'integer');
41
		$this->addType('shared', 'integer');
42
		$this->addType('archived', 'boolean');
43
		$this->addRelation('labels');
44
		$this->addRelation('acl');
45
		$this->addRelation('shared');
46
		$this->shared = -1;
47
	}
48
49
	public function jsonSerialize() {
50
		$result = [
51
			'id' => $this->id,
52
			'title' => $this->title,
53
			'owner' => $this->owner,
54
			'color' => $this->color,
55
			'labels' => $this->labels,
56
			'acl' => $this->acl,
57
		];
58
		if ($this->shared !== -1) {
59
			$result['shared'] = $this->shared;
60
		}
61
		return $result;
62
	}
63
64
	public function setLabels($labels) {
65
		foreach ($labels as $l) {
66
			$this->labels[] = $l;
67
		}
68
	}
69
70
	public function setAcl($acl) {
71
		foreach ($acl as $a) {
72
			$this->acl[$a->id] = $a;
73
		}
74
	}
75
}