-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathObservableListener.interface.php
79 lines (79 loc) · 1.7 KB
/
ObservableListener.interface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/**
* Hold Observableand Listener interface definitions
*
* @version $Id$
* @filesource
* @package Seraphp
* @author Peter Nagy <[email protected]>
*/
namespace Seraphp;
/**
* Listener interface definition
*
* Classes implementing this interface will be able to receive
* notification from classes implementing the Observable interface.
*
* @package Seraphp
*/
interface Listener
{
/**
* Returns a unique name of the Observer instance
*
* @return string
*/
public function getName();
/**
* Notification method
*
* Calling this method will mean, that the Listener's status has been
* changed.
*
* @param Listener $instance
* @return void
*/
public function update(\Seraphp\Observable $instance);
}
/**
* Listener interface definition
*
* Classes implementing this interface will be able to
* notify classes implementing the Observer interface.
*
* @package Seraphp
*/
interface Observable
{
/**
* Attaches an listener
*
* The instance will receives the update notifications.
*
* @param Listener $instance
* @return boolean
*/
public function attach(\Seraphp\Listener $instance);
/**
* Notifies listeners
*
* Flicks through all registered listeners and notify them about update
* @return void
*/
public function notify();
/**
* Return observed status report
*
* @return mixed
*/
public function getState();
/**
* Deatches an listener
*
* The instance will not receive updates anymore.
*
* @param string $str Name of the Listener object
* @return boolean
*/
public function detach($str);
}