@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @param string $name the name of the event |
52 | 52 | * @param array|ArrayAccess $headers the headers for the event |
53 | 53 | */ |
54 | - public function __construct($subject, $name, $parameters = array(), $type = false){ |
|
54 | + public function __construct($subject, $name, $parameters = array(), $type = false) { |
|
55 | 55 | parent::__construct($subject, Test::ensureArrayAccess($parameters)); |
56 | 56 | $this->name = $name; |
57 | 57 | $this->type = $type ? $type : get_class($this); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @access public |
64 | 64 | * @return string the name of the event |
65 | 65 | */ |
66 | - public function getName(){ |
|
66 | + public function getName() { |
|
67 | 67 | return $this->name; |
68 | 68 | } |
69 | 69 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @access public |
75 | 75 | * @return string the type of the event |
76 | 76 | */ |
77 | - public function getType(){ |
|
77 | + public function getType() { |
|
78 | 78 | return $this->name; |
79 | 79 | } |
80 | 80 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @access public |
85 | 85 | * @param mixed $value the return-value to set |
86 | 86 | */ |
87 | - public function setReturnValue($value){ |
|
87 | + public function setReturnValue($value) { |
|
88 | 88 | $this->value = $value; |
89 | 89 | } |
90 | 90 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @access public |
95 | 95 | * @return mixed the return-value to set |
96 | 96 | */ |
97 | - public function getReturnValue(){ |
|
97 | + public function getReturnValue() { |
|
98 | 98 | return $this->value; |
99 | 99 | } |
100 | 100 | |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | * @access public |
105 | 105 | * @param boolean $processed |
106 | 106 | */ |
107 | - public function setProcessed($processed){ |
|
108 | - $this->processed = (boolean) $processed; |
|
107 | + public function setProcessed($processed) { |
|
108 | + $this->processed = (boolean)$processed; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @access public |
115 | 115 | * @return boolean wether the event is processed |
116 | 116 | */ |
117 | - public function isProcessed(){ |
|
117 | + public function isProcessed() { |
|
118 | 118 | return $this->processed; |
119 | 119 | } |
120 | 120 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @access public |
125 | 125 | * @return mixed the subject/content |
126 | 126 | */ |
127 | - public function getSubject(){ |
|
127 | + public function getSubject() { |
|
128 | 128 | return $this->getContent(); |
129 | 129 | } |
130 | 130 | } |
@@ -33,16 +33,16 @@ discard block |
||
33 | 33 | * @param mixed $subject subject to notify the listeners of |
34 | 34 | * @return void |
35 | 35 | */ |
36 | - protected static function doNotify(array $listeners, $subject){ |
|
37 | - foreach($listeners as $listener){ |
|
36 | + protected static function doNotify(array $listeners, $subject) { |
|
37 | + foreach ($listeners as $listener) { |
|
38 | 38 | self::doNotifyOne($listener, $subject); |
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
42 | - protected static function doNotifyOne($listener, $subject){ |
|
43 | - if(is_callable($listener)){ |
|
42 | + protected static function doNotifyOne($listener, $subject) { |
|
43 | + if (is_callable($listener)) { |
|
44 | 44 | $res = call_user_func($listener, $subject); |
45 | - }else{ |
|
45 | + }else { |
|
46 | 46 | $res = $listener->handle($subject); |
47 | 47 | } |
48 | 48 | return $res; |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | * @param mixed $subject subject to notify the listeners of |
59 | 59 | * @return \PEIP\INF\Handler\Handler listener that returned a boolean true value |
60 | 60 | */ |
61 | - protected static function doNotifyUntil(array $listeners, $subject){ |
|
62 | - foreach ($listeners as $listener){ |
|
63 | - if (self::doNotifyOne($listener, $subject)){ |
|
61 | + protected static function doNotifyUntil(array $listeners, $subject) { |
|
62 | + foreach ($listeners as $listener) { |
|
63 | + if (self::doNotifyOne($listener, $subject)) { |
|
64 | 64 | return $listener; |
65 | 65 | } |
66 | 66 | } |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | * @param Callable|PEIP\INF\Handler\Handler $listener listener to connect |
45 | 45 | * @return |
46 | 46 | */ |
47 | - public function connect($name, $listener){ |
|
47 | + public function connect($name, $listener) { |
|
48 | 48 | Test::ensureHandler($listener); |
49 | - if (!$this->hasListeners($name)){ |
|
49 | + if (!$this->hasListeners($name)) { |
|
50 | 50 | $this->listeners[$name] = array(); |
51 | 51 | } |
52 | 52 | $this->listeners[$name][] = $listener; |
@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | * @param Callable|PEIP\INF\Handler\Handler $listener listener to connect |
62 | 62 | * @return |
63 | 63 | */ |
64 | - public function disconnect($name, $listener){ |
|
65 | - if (!$this->hasListeners($name)){ |
|
64 | + public function disconnect($name, $listener) { |
|
65 | + if (!$this->hasListeners($name)) { |
|
66 | 66 | return false; |
67 | 67 | } |
68 | 68 | $res = false; |
69 | - foreach ($this->listeners[$name] as $i => $callable){ |
|
70 | - if ($listener === $callable){ |
|
69 | + foreach ($this->listeners[$name] as $i => $callable) { |
|
70 | + if ($listener === $callable) { |
|
71 | 71 | unset($this->listeners[$name][$i]); |
72 | 72 | $res = true; |
73 | 73 | } |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | * @param Callable|PEIP\INF\Handler\Handler $listener listener to connect |
84 | 84 | * @return |
85 | 85 | */ |
86 | - public function disconnectAll($name){ |
|
87 | - if (!isset($this->listeners[$name])){ |
|
86 | + public function disconnectAll($name) { |
|
87 | + if (!isset($this->listeners[$name])) { |
|
88 | 88 | return false; |
89 | 89 | } |
90 | 90 | $this->listeners[$name] = array(); |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | * @param string $name name of the event |
99 | 99 | * @return boolean wether any listener is registered for event-name |
100 | 100 | */ |
101 | - public function hasListeners($name){ |
|
102 | - if (!isset($this->listeners[$name])){ |
|
101 | + public function hasListeners($name) { |
|
102 | + if (!isset($this->listeners[$name])) { |
|
103 | 103 | return false; |
104 | 104 | } |
105 | - return (boolean) count($this->listeners[$name]); |
|
105 | + return (boolean)count($this->listeners[$name]); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | * @param mixed $subject the subject |
114 | 114 | * @return boolean success |
115 | 115 | */ |
116 | - public function notify($name, $subject){ |
|
117 | - if($this->hasListeners($name)){ |
|
116 | + public function notify($name, $subject) { |
|
117 | + if ($this->hasListeners($name)) { |
|
118 | 118 | self::doNotify($this->getListeners($name), $subject); |
119 | 119 | return true; |
120 | 120 | } |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | * @param mixed $subject the subject |
130 | 130 | * @return \PEIP\INF\Handler\Handler listener which returned a boolean true value |
131 | 131 | */ |
132 | - public function notifyUntil($name, $subject){ |
|
133 | - if($this->hasListeners($name)){ |
|
132 | + public function notifyUntil($name, $subject) { |
|
133 | + if ($this->hasListeners($name)) { |
|
134 | 134 | return self::doNotifyUntil($this->getListeners($name), $subject); |
135 | 135 | } |
136 | 136 | return NULL; |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | * @param $name |
144 | 144 | * @return array array of \PEIP\INF\Handler\Handler instances |
145 | 145 | */ |
146 | - public function getListeners($name){ |
|
147 | - if (!isset($this->listeners[$name])){ |
|
146 | + public function getListeners($name) { |
|
147 | + if (!isset($this->listeners[$name])) { |
|
148 | 148 | return array(); |
149 | 149 | } |
150 | 150 | return $this->listeners[$name]; |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | |
23 | 23 | |
24 | 24 | abstract class Container |
25 | - implements \PEIP\INF\Base\Container{ |
|
25 | + implements \PEIP\INF\Base\Container { |
|
26 | 26 | |
27 | 27 | protected $content; |
28 | 28 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @access public |
34 | 34 | * @return |
35 | 35 | */ |
36 | - public function getContent(){ |
|
36 | + public function getContent() { |
|
37 | 37 | return $this->content; |
38 | 38 | } |
39 | 39 |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | * @subpackage base |
18 | 18 | */ |
19 | 19 | |
20 | -abstract class Connectable implements \PEIP\INF\Event\Connectable{ |
|
20 | +abstract class Connectable implements \PEIP\INF\Event\Connectable { |
|
21 | 21 | |
22 | 22 | const |
23 | 23 | DEFAULT_CLASS_MESSAGE_DISPATCHER = '\PEIP\Dispatcher\Dispatcher', |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param Callable|PEIP\INF\Handler\Handler $listener |
43 | 43 | * @return |
44 | 44 | */ |
45 | - public function connect($name, $listener){ |
|
45 | + public function connect($name, $listener) { |
|
46 | 46 | \PEIP\Util\Test::ensureHandler($listener); |
47 | 47 | $this->getEventDispatcher()->connect($name, $this, $listener); |
48 | 48 | $this->doFireEvent( |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @param Callable|PEIP\INF\Handler\Handler $listener |
62 | 62 | * @return |
63 | 63 | */ |
64 | - public function disconnect($name, $listener){ |
|
64 | + public function disconnect($name, $listener) { |
|
65 | 65 | \PEIP\Util\Test::ensureHandler($listener); |
66 | 66 | $this->getEventDispatcher()->disconnect($name, $this, $listener); |
67 | 67 | $this->doFireEvent( |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @param $name |
83 | 83 | * @return |
84 | 84 | */ |
85 | - public function hasListeners($name){ |
|
85 | + public function hasListeners($name) { |
|
86 | 86 | return $this->getEventDispatcher()->hasListeners($name, $this); |
87 | 87 | } |
88 | 88 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * @param $name |
93 | 93 | * @return |
94 | 94 | */ |
95 | - public function getListeners($name){ |
|
95 | + public function getListeners($name) { |
|
96 | 96 | return $this->getEventDispatcher()->getListeners($name, $this); |
97 | 97 | } |
98 | 98 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @param $callable |
103 | 103 | * @return |
104 | 104 | */ |
105 | - public function disconnectAll($name){ |
|
105 | + public function disconnectAll($name) { |
|
106 | 106 | $this->getEventDispatcher()->disconnectAll($name, $this); |
107 | 107 | } |
108 | 108 | |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | * @param $transferListners |
113 | 113 | * @return |
114 | 114 | */ |
115 | - public function setEventDispatcher(\PEIP\Dispatcher\ObjectEventDispatcher $dispatcher, $transferListners = true){ |
|
116 | - if($transferListners){ |
|
117 | - foreach($this->getEventDispatcher()->getEventNames($this) as $name){ |
|
118 | - if($this->getEventDispatcher()->hasListeners($name, $this)){ |
|
119 | - foreach($this->getEventDispatcher()->getListeners($name, $this) as $listener){ |
|
115 | + public function setEventDispatcher(\PEIP\Dispatcher\ObjectEventDispatcher $dispatcher, $transferListners = true) { |
|
116 | + if ($transferListners) { |
|
117 | + foreach ($this->getEventDispatcher()->getEventNames($this) as $name) { |
|
118 | + if ($this->getEventDispatcher()->hasListeners($name, $this)) { |
|
119 | + foreach ($this->getEventDispatcher()->getListeners($name, $this) as $listener) { |
|
120 | 120 | $dispatcher->connect($name, $this, $listener); |
121 | 121 | } |
122 | 122 | } |
@@ -131,11 +131,11 @@ discard block |
||
131 | 131 | * @access public |
132 | 132 | * @return |
133 | 133 | */ |
134 | - public function getEventDispatcher(){ |
|
134 | + public function getEventDispatcher() { |
|
135 | 135 | return $this->eventDispatcher ? $this->eventDispatcher : $this->eventDispatcher = self::getSharedEventDispatcher(); |
136 | 136 | } |
137 | 137 | |
138 | - protected static function getSharedEventDispatcher(){ |
|
138 | + protected static function getSharedEventDispatcher() { |
|
139 | 139 | $defaultDispatcher = self::DEFAULT_CLASS_EVENT_DISPATCHER; |
140 | 140 | return self::$sharedEventDispatcher ? self::$sharedEventDispatcher : self::$sharedEventDispatcher = new $defaultDispatcher; |
141 | 141 | } |
@@ -148,12 +148,12 @@ discard block |
||
148 | 148 | * @param $eventClass |
149 | 149 | * @return |
150 | 150 | */ |
151 | - protected function doFireEvent($name, array $headers = array(), $eventClass = '', $type = false){ |
|
151 | + protected function doFireEvent($name, array $headers = array(), $eventClass = '', $type = false) { |
|
152 | 152 | $eventClass = trim($eventClass) == '' ? static::DEFAULT_EVENT_CLASS : $eventClass; |
153 | 153 | return $this->getEventDispatcher()->buildAndNotify($name, $this, $headers, $eventClass, $type); |
154 | 154 | } |
155 | 155 | |
156 | - protected static function getDefaultEventClass(){ |
|
156 | + protected static function getDefaultEventClass() { |
|
157 | 157 | return self::DEFAULT_EVENT_CLASS; |
158 | 158 | } |
159 | 159 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | * @access public |
33 | 33 | * @return mixed content |
34 | 34 | */ |
35 | - public function getContent(){ |
|
35 | + public function getContent() { |
|
36 | 36 | return parent::getContent(); |
37 | 37 | } |
38 | 38 | } |
39 | 39 | \ No newline at end of file |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * @param string $eventName name of the event to listen to |
39 | 39 | * @param \PEIP\INF\Event\Connectable $connectable instance of \PEIP\INF\Event\Connectable to listen to |
40 | 40 | */ |
41 | - protected function doListen($eventName, \PEIP\INF\Event\Connectable $connectable){ |
|
42 | - if(!$connectable->hasListener($eventName, $this)){ |
|
41 | + protected function doListen($eventName, \PEIP\INF\Event\Connectable $connectable) { |
|
42 | + if (!$connectable->hasListener($eventName, $this)) { |
|
43 | 43 | $connectable->connect($eventName, $this); |
44 | 44 | $this->connections[spl_object_hash($connectable)] = $connectable; |
45 | 45 | } |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | * @param string $eventName name of the event to unlisten |
53 | 53 | * @param \PEIP\INF\Event\Connectable $connectable instance of \PEIP\INF\Event\Connectable to unlisten to |
54 | 54 | */ |
55 | - protected function doUnlisten($eventName, \PEIP\INF\Event\Connectable $connectable){ |
|
56 | - if(!$connectable->hasListener($eventName, $this)){ |
|
55 | + protected function doUnlisten($eventName, \PEIP\INF\Event\Connectable $connectable) { |
|
56 | + if (!$connectable->hasListener($eventName, $this)) { |
|
57 | 57 | $connectable->disconnect($eventName, $this); |
58 | 58 | unset($this->connections[spl_object_hash($connectable)]); |
59 | 59 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @access public |
66 | 66 | * @return array array of \PEIP\INF\Event\Connectable instances |
67 | 67 | */ |
68 | - public function doGetConnected(){ |
|
68 | + public function doGetConnected() { |
|
69 | 69 | return array_values($this->connections); |
70 | 70 | } |
71 | 71 |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | * @param \PEIP\INF\Channel\Channel $outputChannel the outputs-channel |
38 | 38 | * @return |
39 | 39 | */ |
40 | - public function __construct(\PEIP\INF\Channel\Channel $inputChannel, \PEIP\INF\Channel\Channel $outputChannel = NULL){ |
|
40 | + public function __construct(\PEIP\INF\Channel\Channel $inputChannel, \PEIP\INF\Channel\Channel $outputChannel = NULL) { |
|
41 | 41 | $this->setInputChannel($inputChannel); |
42 | - if(is_object($outputChannel)){ |
|
42 | + if (is_object($outputChannel)) { |
|
43 | 43 | $this->setOutputChannel($outputChannel); |
44 | 44 | } |
45 | 45 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @param \PEIP\INF\Message\Message $message message to transform content |
52 | 52 | * @return |
53 | 53 | */ |
54 | - public function doReply(\PEIP\INF\Message\Message $message){ |
|
54 | + public function doReply(\PEIP\INF\Message\Message $message) { |
|
55 | 55 | $this->replyMessage($this->transform($message)); |
56 | 56 | } |
57 | 57 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @param \PEIP\INF\Message\Message $message |
63 | 63 | * @return mixed result of transforming the message |
64 | 64 | */ |
65 | - public function transform(\PEIP\INF\Message\Message $message){ |
|
65 | + public function transform(\PEIP\INF\Message\Message $message) { |
|
66 | 66 | return $this->doTransform($message); |
67 | 67 | } |
68 | 68 |
@@ -34,7 +34,7 @@ |
||
34 | 34 | * @param \PEIP\INF\Message\Message $message |
35 | 35 | * @return mixed result of transforming the message payload/content |
36 | 36 | */ |
37 | - protected function doTransform(\PEIP\INF\Message\Message $message){ |
|
37 | + protected function doTransform(\PEIP\INF\Message\Message $message) { |
|
38 | 38 | return $this->transformContent($message->getContent()); |
39 | 39 | } |
40 | 40 |