Group::columnToProperty()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 7
cp 0
rs 9.9332
c 0
b 0
f 0
cc 3
nc 3
nop 1
crap 12
1
<?php
2
declare(strict_types=1);
3
/**
4
 * @copyright Copyright (c) 2019 Joas Schilling <[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\AnnouncementCenter\Model;
24
25
26
use OCP\AppFramework\Db\Entity;
27
28
/**
29
 * @method void setGroup(string $group)
30
 * @method string getGroup()
31
 */
32
class Group extends Entity {
33
34
	/** @var string */
35
	protected $group;
36
37 1
	public function __construct() {
38 1
		$this->addType('group', 'string');
39 1
	}
40
41
	/**
42
	 * @param string $columnName the name of the column
43
	 * @return string the property name
44
	 */
45
	public function columnToProperty($columnName): string {
46
		switch ($columnName) {
47
			case 'announcement_id':
48
				return 'id';
49
			case 'gid':
50
				return 'group';
51
		}
52
53
		return parent::columnToProperty($columnName);
54
	}
55
56
	/**
57
	 * @param string $property the name of the property
58
	 * @return string the column name
59
	 */
60
	public function propertyToColumn($property): string {
61
		switch ($property) {
62
			case 'id':
63
				return 'announcement_id';
64
			case 'group':
65
				return 'gid';
66
		}
67
68
		return parent::propertyToColumn($property);
69
	}
70
}
71