Completed
Push — master ( 09df6b...307ee1 )
by Branko
22s queued 10s
created

Person   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Test Coverage

Coverage 33.33%

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 55
ccs 4
cts 12
cp 0.3333
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 0 8 1
A setIsValid() 0 7 2
1
<?php
2
/**
3
 * @copyright Copyright (c) 2017, Matias De lellis <[email protected]>
4
 * @copyright Copyright (c) 2018, Branko Kokanovic <[email protected]>
5
 *
6
 * @author Branko Kokanovic <[email protected]>
7
 *
8
 * @license GNU AGPL version 3 or any later version
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU Affero General Public License as
12
 * published by the Free Software Foundation, either version 3 of the
13
 * License, or (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU Affero General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU Affero General Public License
21
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
 *
23
 */
24
namespace OCA\FaceRecognition\Db;
25
26
use JsonSerializable;
27
28
use OCP\AppFramework\Db\Entity;
29
30
/**
31
 * Person represent one cluster, set of faces. It belongs to $user_id.
32
 *
33
 * @method string getName()
34
 * @method void setName(string $name)
35
 */
36
class Person extends Entity implements JsonSerializable {
37
	/**
38
	 * User this person belongs to
39
	 *
40
	 * @var string
41
	 * */
42
	protected $user;
43
44
	/**
45
	 * Name for this person/cluster. Must exists, even if linked user is set.
46
	 *
47
	 * @var string
48
	 */
49
	protected $name;
50
51
	/**
52
	 * Whether this person is still valid
53
	 *
54
	 * @var bool
55
	 */
56
	protected $isValid;
57
58
	/**
59
	 * Last timestamp when this person/cluster was created, or when it was refreshed
60
	 *
61
	 * @var timestamp|null
0 ignored issues
show
Bug introduced by
The type OCA\FaceRecognition\Db\timestamp was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
62
	 */
63
	protected $lastGenerationTime;
64
65
	/**
66
	 * Foreign key to other user that this person belongs to (if it is on same Nextcloud instance).
67
	 * It is set by owner of this cluster. It is optional.
68
	 *
69
	 * @var string|null
70
	*/
71
	protected $linkedUser;
72
73
	public function jsonSerialize() {
74
		return [
75
			'id' => $this->id,
76
			'user' => $this->user,
77
			'name' => $this->name,
78
			'is_valid' => $this->isValid,
79
			'last_generation_time' => $this->lastGenerationTime,
80
			'linked_user' => $this->linkedUser
81
		];
82
	}
83
84 1
	public function setIsValid($isValid) {
85 1
		if (is_bool($isValid)) {
86 1
			$this->isValid = $isValid;
87
		} else {
88
			$this->isValid = filter_var($isValid, FILTER_VALIDATE_BOOLEAN);
89
		}
90 1
		$this->markFieldUpdated('isValid');
91 1
	}
92
}
93