Passed
Push — master ( c0a3a7...3b84a4 )
by Jeroen
58:51
created

site_notifications/classes/SiteNotification.php (2 issues)

Checks if properties have been declared.

Best Practice Bug Major
1
<?php
2
/**
3
 * Site notification class
4
 */
5
6
class SiteNotification extends ElggObject {
7
8
	const HAS_ACTOR = "hasActor";
9
10
	/**
11
	 * {@inheritDoc}
12
	 */
13 2
	protected function initializeAttributes() {
14 2
		parent::initializeAttributes();
15 2
		$this->attributes['subtype'] = 'site_notification';
16 2
	}
17
18
	/**
19
	 * Get the actor involved in the notification
20
	 *
21
	 * @return ElggEntity|null
22
	 */
23
	public function getActor() {
24
		$actor = $this->getEntitiesFromRelationship(['relationship' => self::HAS_ACTOR]);
25
		if ($actor) {
26
			$actor = $actor[0];
27
		}
28
29
		return $actor;
30
	}
31
32
	/**
33
	 * Set the actor involved in the notification
34
	 *
35
	 * @param ElggEntity $entity Actor
36
	 *
37
	 * @return void
38
	 */
39 2
	public function setActor($entity) {
40 2
		$this->addRelationship($entity->guid, self::HAS_ACTOR);
41 2
	}
42
43
	/**
44
	 * {@inheritDoc}
45
	 */
46
	public function getURL() {
47
		return (string) $this->url;
48
	}
49
50
	/**
51
	 * Set the url for the notification
52
	 *
53
	 * @param string $url The URL for the notification link
54
	 *
55
	 * @return void
56
	 */
57 2
	public function setURL($url) {
58 2
		if ($url) {
59 2
			$this->url = $url;
0 ignored issues
show
Bug Best Practice introduced by
The property url does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
60
		}
61 2
	}
62
63
	/**
64
	 * Set the read status
65
	 *
66
	 * @param bool $read Has the notification been read
67
	 *
68
	 * @return void
69
	 */
70 2
	public function setRead($read) {
71 2
		$this->read = $read;
0 ignored issues
show
Bug Best Practice introduced by
The property read does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
72 2
	}
73
74
	/**
75
	 * Has the notification been read?
76
	 *
77
	 * @return bool
78
	 */
79
	public function isRead() {
80
		return (bool) $this->read;
81
	}
82
}
83