Passed
Push — feature/909_Ampache_API_improv... ( 943762...5a3d3f )
by Pauli
12:26
created

Entity::getNameString()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 7
nc 3
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
/**
4
 * ownCloud - Music app
5
 *
6
 * This file is licensed under the Affero General Public License version 3 or
7
 * later. See the COPYING file.
8
 *
9
 * @author Pauli Järvinen <[email protected]>
10
 * @copyright Pauli Järvinen 2021 - 2023
11
 */
12
13
namespace OCA\Music\Db;
14
15
use OCP\IL10N;
16
17
/**
18
 * Base class for all the entities belonging to the data model of the Music app
19
 * 
20
 * @method string getUserId()
21
 * @method void setUserId(string $userId)
22
 * @method string getCreated()
23
 * @method setCreated(string $timestamp)
24
 * @method string getUpdated()
25
 * @method setUpdated(string $timestamp)
26
 */
27
class Entity extends \OCP\AppFramework\Db\Entity {
28
	public $userId;
29
	public $created;
30
	public $updated;
31
32
	/**
33
	 * All entities have a non-empty human-readable name, although the exact name of the
34
	 * corresponding DB column varies and in some cases, the value may be technically
35
	 * empty but replaced with some localized place-holder text.
36
	 *
37
	 * The derived classes may override this as neeeded.
38
	 */
39
	public function getNameString(IL10N $l10n) : string {
40
		($l10n); // unused in this base implementation
41
		if (\property_exists($this, 'name')) {
42
			return $this->getName();
0 ignored issues
show
Bug introduced by
The method getName() does not exist on OCA\Music\Db\Entity. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

42
			return $this->/** @scrutinizer ignore-call */ getName();
Loading history...
Bug Best Practice introduced by
The expression return $this->getName() could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
43
		} elseif (\property_exists($this, 'title')) {
44
			return $this->getTitle();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getTitle() could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
Bug introduced by
The method getTitle() does not exist on OCA\Music\Db\Entity. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

44
			return $this->/** @scrutinizer ignore-call */ getTitle();
Loading history...
45
		} else {
46
			return 'UNIMPLEMENTED';
47
		}
48
	}
49
}
50