Completed
Push — master ( c9fc28...4733eb )
by Sander
11s
created

Notebook::setter()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 2
eloc 5
nc 2
nop 2
1
<?php
2
/**
3
 * Nextcloud - NextNote
4
 *
5
 *
6
 * @copyright Copyright (c) 2017, Sander Brand ([email protected])
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\NextNote\Db;
25
26
use \OCP\AppFramework\Db\Entity;
27
28
/**
29
 * @method integer getId()
30
 * @method void setId(int $value)
31
 * @method integer getParentId()
32
 * @method void setParentId(int $value)
33
 * @method void setUid(string $value)
34
 * @method string getUid()
35
 * @method void setName(string $value)
36
 * @method string getName()
37
 * @method void setGuid(string $value)
38
 * @method string getGuid()
39
 * @method string getColor()
40
 * @method string setColor(string $value)
41
 * @method void setDeleted(integer $value)
42
 * @method integer getDeleted()
43
 * @method void setNoteCount(integer $value)
44
 * @method integer getNoteCount()
45
 */
46
class Notebook extends Entity implements \JsonSerializable {
47
48
	use EntityJSONSerializer;
49
50
	protected $name;
51
	protected $guid;
52
	protected $uid;
53
	protected $parentId;
54
	protected $color;
55
	protected $deleted;
56
	protected $noteCount;
57
58
	public function __construct() {
59
		// add types in constructor
60
		$this->addType('parentId', 'integer');
61
		$this->addType('deleted', 'integer');
62
		$this->addType('note_count', 'integer');
63
	}
64
65
	protected function setter($name, $args) {
66
		if($name != 'noteCount') {
67
			parent::setter($name, $args);
68
		} else {
69
			$this->$name = $args[0];
70
		}
71
	}
72
73
	/**
74
	 * Turns entity attributes into an array
75
	 */
76
	public function jsonSerialize() {
77
		return [
78
			'id' => $this->getId(),
79
			'guid' => $this->getGuid(),
80
			'parent_id' => $this->getParentId(),
81
			'name' => $this->getName(),
82
			'color' => $this->getColor(),
83
			'note_count' => $this->getNoteCount(),
84
			'permissions' => 31
85
		];
86
	}
87
}
88