@@ -80,7 +80,6 @@ |
||
| 80 | 80 | * |
| 81 | 81 | * @access public |
| 82 | 82 | * @param string $name name of the event |
| 83 | - * @param Callable|PEIP\INF\Handler\Handler $listener listener to connect |
|
| 84 | 83 | * @return |
| 85 | 84 | */ |
| 86 | 85 | public function disconnectAll($name){
|
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | public function connect($name, $listener){
|
| 48 | 48 | Test::ensureHandler($listener); |
| 49 | 49 | if (!$this->hasListeners($name)){
|
| 50 | - $this->listeners[$name] = array(); |
|
| 50 | + $this->listeners[$name] = array(); |
|
| 51 | 51 | } |
| 52 | 52 | $this->listeners[$name][] = $listener; |
| 53 | 53 | return true; |
@@ -67,10 +67,10 @@ discard block |
||
| 67 | 67 | } |
| 68 | 68 | $res = false; |
| 69 | 69 | foreach ($this->listeners[$name] as $i => $callable){
|
| 70 | - if ($listener === $callable){
|
|
| 70 | + if ($listener === $callable){
|
|
| 71 | 71 | unset($this->listeners[$name][$i]); |
| 72 | 72 | $res = true; |
| 73 | - } |
|
| 73 | + } |
|
| 74 | 74 | } |
| 75 | 75 | return $res; |
| 76 | 76 | } |
@@ -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]; |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | * @see PEIP\ABS\Handler\MessageHandler::doSetInputChannel |
| 55 | 55 | * @access public |
| 56 | 56 | * @param \PEIP\INF\Channel\Channel $inputChannel the input-channel |
| 57 | - * @return PEIP\ABS\Handler\MessageHandler $this; |
|
| 57 | + * @return MessageHandler $this; |
|
| 58 | 58 | */ |
| 59 | 59 | public function setInputChannel(\PEIP\INF\Channel\Channel $inputChannel){
|
| 60 | 60 | $this->doSetInputChannel($inputChannel); |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * @return |
| 44 | 44 | */ |
| 45 | 45 | public function handle($message){
|
| 46 | - $this->doHandle($this->getMessageFromObject($message)); |
|
| 46 | + $this->doHandle($this->getMessageFromObject($message)); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | && $object->getName() == 'postSend' |
| 91 | 91 | && $object->hasHeader(Pipe::HEADER_MESSAGE) |
| 92 | 92 | && $content instanceof \PEIP\INF\Channel\PollableChannel |
| 93 | - ){
|
|
| 93 | + ){
|
|
| 94 | 94 | $object = $content->receive(); |
| 95 | 95 | } |
| 96 | 96 | if (!($object instanceof \PEIP\INF\Message\Message)) {
|
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * @param object $message the message to handle |
| 43 | 43 | * @return |
| 44 | 44 | */ |
| 45 | - public function handle($message){
|
|
| 45 | + public function handle($message) {
|
|
| 46 | 46 | $this->doHandle($this->getMessageFromObject($message)); |
| 47 | 47 | } |
| 48 | 48 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * @param \PEIP\INF\Channel\Channel $inputChannel the input-channel |
| 57 | 57 | * @return PEIP\ABS\Handler\MessageHandler $this; |
| 58 | 58 | */ |
| 59 | - public function setInputChannel(\PEIP\INF\Channel\Channel $inputChannel){
|
|
| 59 | + public function setInputChannel(\PEIP\INF\Channel\Channel $inputChannel) {
|
|
| 60 | 60 | $this->doSetInputChannel($inputChannel); |
| 61 | 61 | return $this; |
| 62 | 62 | } |
@@ -73,24 +73,24 @@ discard block |
||
| 73 | 73 | * @param \PEIP\INF\Channel\Channel $inputChannel the input-channel to connect the handler to |
| 74 | 74 | * @return |
| 75 | 75 | */ |
| 76 | - protected function doSetInputChannel(\PEIP\INF\Channel\Channel $inputChannel){
|
|
| 76 | + protected function doSetInputChannel(\PEIP\INF\Channel\Channel $inputChannel) {
|
|
| 77 | 77 | $this->inputChannel = $inputChannel; |
| 78 | - if($this->inputChannel instanceof \PEIP\INF\Channel\SubscribableChannel){
|
|
| 78 | + if ($this->inputChannel instanceof \PEIP\INF\Channel\SubscribableChannel) {
|
|
| 79 | 79 | $this->inputChannel->subscribe($this); |
| 80 | - }else{
|
|
| 80 | + }else {
|
|
| 81 | 81 | $this->unwrapEvents = true; |
| 82 | 82 | $this->inputChannel->connect('postSend', $this);
|
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - protected function getMessageFromObject($object){
|
|
| 86 | + protected function getMessageFromObject($object) {
|
|
| 87 | 87 | $content = $object->getContent(); |
| 88 | - if($this->unwrapEvents |
|
| 88 | + if ($this->unwrapEvents |
|
| 89 | 89 | && $object instanceof \PEIP\INF\Event\Event |
| 90 | 90 | && $object->getName() == 'postSend' |
| 91 | 91 | && $object->hasHeader(Pipe::HEADER_MESSAGE) |
| 92 | 92 | && $content instanceof \PEIP\INF\Channel\PollableChannel |
| 93 | - ){
|
|
| 93 | + ) {
|
|
| 94 | 94 | $object = $content->receive(); |
| 95 | 95 | } |
| 96 | 96 | if (!($object instanceof \PEIP\INF\Message\Message)) {
|
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * @access public |
| 107 | 107 | * @return \PEIP\INF\Channel\Channel input-channel for this handler |
| 108 | 108 | */ |
| 109 | - public function getInputChannel(){
|
|
| 109 | + public function getInputChannel() {
|
|
| 110 | 110 | return $this->inputChannel; |
| 111 | 111 | } |
| 112 | 112 | |
@@ -77,7 +77,7 @@ |
||
| 77 | 77 | $this->inputChannel = $inputChannel; |
| 78 | 78 | if($this->inputChannel instanceof \PEIP\INF\Channel\SubscribableChannel){
|
| 79 | 79 | $this->inputChannel->subscribe($this); |
| 80 | - }else{
|
|
| 80 | + } else{
|
|
| 81 | 81 | $this->unwrapEvents = true; |
| 82 | 82 | $this->inputChannel->connect('postSend', $this);
|
| 83 | 83 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * Connects the handler to the output-channel. |
| 54 | 54 | * |
| 55 | 55 | * @access protected |
| 56 | - * @param \PEIP\INF\Channel\Channel $inputChannel the output-channel to connect the handler to |
|
| 56 | + * @param \PEIP\INF\Channel\Channel $outputChannel the output-channel to connect the handler to |
|
| 57 | 57 | * @return |
| 58 | 58 | */ |
| 59 | 59 | protected function doSetOutputChannel(\PEIP\INF\Channel\Channel $outputChannel){
|
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * |
| 163 | 163 | * @access public |
| 164 | 164 | * @param string $messageClass name of the message-class to create reply-messages from. |
| 165 | - * @return PEIP\ABS\Handler\ReplyProducingMessageHandler $this |
|
| 165 | + * @return ReplyProducingMessageHandler $this |
|
| 166 | 166 | */ |
| 167 | 167 | public function setMessageClass($messageClass){
|
| 168 | 168 | $this->messageClass = $messageClass; |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | * |
| 196 | 196 | * @access public |
| 197 | 197 | * @param array $headerNames array of message-header names to look for a reply-channel |
| 198 | - * @return PEIP\ABS\Handler\ReplyProducingMessageHandler $this |
|
| 198 | + * @return ReplyProducingMessageHandler $this |
|
| 199 | 199 | */ |
| 200 | 200 | public function setReplyChannelHeaders(array $headerNames){
|
| 201 | 201 | $this->replyChannelHeaders = $headerNames; |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | * @param \PEIP\INF\Channel\Channel $outputChannel the output-channel |
| 45 | 45 | * @return \PEIP\ABS\Handler\MessageHandler $this; |
| 46 | 46 | */ |
| 47 | - public function setOutputChannel(\PEIP\INF\Channel\Channel $outputChannel){
|
|
| 47 | + public function setOutputChannel(\PEIP\INF\Channel\Channel $outputChannel) {
|
|
| 48 | 48 | $this->doSetOutputChannel($outputChannel); |
| 49 | 49 | return $this; |
| 50 | 50 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * @param \PEIP\INF\Channel\Channel $inputChannel the output-channel to connect the handler to |
| 57 | 57 | * @return |
| 58 | 58 | */ |
| 59 | - protected function doSetOutputChannel(\PEIP\INF\Channel\Channel $outputChannel){
|
|
| 59 | + protected function doSetOutputChannel(\PEIP\INF\Channel\Channel $outputChannel) {
|
|
| 60 | 60 | $this->outputChannel = $outputChannel; |
| 61 | 61 | } |
| 62 | 62 | |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * @access public |
| 67 | 67 | * @return \PEIP\INF\Channel\Channel output-channel for this handler |
| 68 | 68 | */ |
| 69 | - public function getOutputChannel(){
|
|
| 69 | + public function getOutputChannel() {
|
|
| 70 | 70 | return $this->outputChannel; |
| 71 | 71 | } |
| 72 | 72 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * @param \PEIP\INF\Message\Message $message the message to resolve output-channel for |
| 81 | 81 | * @return \PEIP\INF\Channel\Channel the output-channel for the message |
| 82 | 82 | */ |
| 83 | - protected function doGetOutputChannel(\PEIP\INF\Message\Message $message){
|
|
| 83 | + protected function doGetOutputChannel(\PEIP\INF\Message\Message $message) {
|
|
| 84 | 84 | $replyChannel = $this->resolveReplyChannel($message); |
| 85 | 85 | return $replyChannel ? $replyChannel : $this->getOutputChannel(); |
| 86 | 86 | } |
@@ -94,9 +94,9 @@ discard block |
||
| 94 | 94 | * @param \PEIP\INF\Message\Message $message |
| 95 | 95 | * @return \PEIP\INF\Channel\Channel the reply-channel if found |
| 96 | 96 | */ |
| 97 | - protected function resolveReplyChannel(\PEIP\INF\Message\Message $message){
|
|
| 98 | - foreach($this->replyChannelHeaders as $header){
|
|
| 99 | - if($message->hasHeader($header)){
|
|
| 97 | + protected function resolveReplyChannel(\PEIP\INF\Message\Message $message) {
|
|
| 98 | + foreach ($this->replyChannelHeaders as $header) {
|
|
| 99 | + if ($message->hasHeader($header)) {
|
|
| 100 | 100 | return $message->getHeader($header); |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * @access protected |
| 114 | 114 | * @param mixed $content \PEIP\INF\Message\Message or content/payload for new message |
| 115 | 115 | */ |
| 116 | - protected function replyMessage($content){
|
|
| 116 | + protected function replyMessage($content) {
|
|
| 117 | 117 | $message = $this->ensureMessage($content); |
| 118 | 118 | $this->doGetOutputChannel($message)->send($message); |
| 119 | 119 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * @param mixed $message \PEIP\INF\Message\Message or content/payload for new message |
| 128 | 128 | * @return \PEIP\INF\Message\Message |
| 129 | 129 | */ |
| 130 | - protected function ensureMessage($message){
|
|
| 130 | + protected function ensureMessage($message) {
|
|
| 131 | 131 | return ($message instanceof \PEIP\INF\Message\Message) ? $message : $this->buildMessage($message); |
| 132 | 132 | } |
| 133 | 133 | |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | * @return \PEIP\INF\Message\Message |
| 141 | 141 | * @see MessageBuilder |
| 142 | 142 | */ |
| 143 | - protected function buildMessage($content){
|
|
| 143 | + protected function buildMessage($content) {
|
|
| 144 | 144 | return $this->getMessageBuilder()->setContent($content)->build(); |
| 145 | 145 | } |
| 146 | 146 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | * @access protected |
| 152 | 152 | * @return MessageBuilder builder for the registered message class |
| 153 | 153 | */ |
| 154 | - protected function getMessageBuilder(){
|
|
| 154 | + protected function getMessageBuilder() {
|
|
| 155 | 155 | return isset($this->messageBuilder) && ($this->messageBuilder->getMessageClass() == $this->getMessageClass()) |
| 156 | 156 | ? $this->messageBuilder |
| 157 | 157 | : $this->messageBuilder = MessageBuilder::getInstance($this->messageClass); |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | * @param string $messageClass name of the message-class to create reply-messages from. |
| 165 | 165 | * @return PEIP\ABS\Handler\ReplyProducingMessageHandler $this |
| 166 | 166 | */ |
| 167 | - public function setMessageClass($messageClass){
|
|
| 167 | + public function setMessageClass($messageClass) {
|
|
| 168 | 168 | $this->messageClass = $messageClass; |
| 169 | 169 | return $this; |
| 170 | 170 | } |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | * @access public |
| 176 | 176 | * @return string name of the message-class to create reply-messages from. |
| 177 | 177 | */ |
| 178 | - public function getMessageClass(){
|
|
| 178 | + public function getMessageClass() {
|
|
| 179 | 179 | return $this->messageClass; |
| 180 | 180 | } |
| 181 | 181 | |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | * @param string $headerName name of a message-header to look for a reply-channel |
| 187 | 187 | * @return void |
| 188 | 188 | */ |
| 189 | - public function addReplyChannelHeader($headerName){
|
|
| 189 | + public function addReplyChannelHeader($headerName) {
|
|
| 190 | 190 | $this->replyChannelHeaders[] = $headerName; |
| 191 | 191 | } |
| 192 | 192 | |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | * @param array $headerNames array of message-header names to look for a reply-channel |
| 198 | 198 | * @return PEIP\ABS\Handler\ReplyProducingMessageHandler $this |
| 199 | 199 | */ |
| 200 | - public function setReplyChannelHeaders(array $headerNames){
|
|
| 200 | + public function setReplyChannelHeaders(array $headerNames) {
|
|
| 201 | 201 | $this->replyChannelHeaders = $headerNames; |
| 202 | 202 | return $this; |
| 203 | 203 | } |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | * @access public |
| 209 | 209 | * @return array array of message-header names to look for a reply-channel |
| 210 | 210 | */ |
| 211 | - public function getReplyChannelHeaders(){
|
|
| 211 | + public function getReplyChannelHeaders() {
|
|
| 212 | 212 | return $this->replyChannelHeaders; |
| 213 | 213 | } |
| 214 | 214 | |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | * @param \PEIP\INF\Message\Message $message |
| 223 | 223 | * @return |
| 224 | 224 | */ |
| 225 | - protected function doHandle(\PEIP\INF\Message\Message $message){
|
|
| 225 | + protected function doHandle(\PEIP\INF\Message\Message $message) {
|
|
| 226 | 226 | return $this->doReply($message); |
| 227 | 227 | } |
| 228 | 228 | |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | * @implements \PEIP\INF\Gateway\MessagingGateway, \PEIP\INF\Message\MessageBuilder |
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | -use PEIP\Message\GenericMessage; |
|
| 23 | +use PEIP\Message\GenericMessage; |
|
| 24 | 24 | use PEIP\Message\MessageBuilder; |
| 25 | 25 | |
| 26 | 26 | class SimpleMessagingGateway |
@@ -71,7 +71,6 @@ |
||
| 71 | 71 | * notifies all listeners on a event on a subject |
| 72 | 72 | * |
| 73 | 73 | * @access public |
| 74 | - * @param string $name name of the event |
|
| 75 | 74 | * @param mixed $subject the subject |
| 76 | 75 | * @return |
| 77 | 76 | */ |
@@ -18,11 +18,11 @@ discard block |
||
| 18 | 18 | * @param Callable|PEIP\INF\Handler\Handler $listener listener to connect |
| 19 | 19 | * @return |
| 20 | 20 | */ |
| 21 | - public function connect($name, $listener){
|
|
| 21 | + public function connect($name, $listener) {
|
|
| 22 | 22 | $name = is_object($name) ? get_class($name) : (string)$name; |
| 23 | - if(Test::assertClassOrInterfaceExists($name)){
|
|
| 23 | + if (Test::assertClassOrInterfaceExists($name)) {
|
|
| 24 | 24 | parent::connect($name, $listener); |
| 25 | - }else{
|
|
| 25 | + }else {
|
|
| 26 | 26 | throw new \InvalidArgumentException($name." is not an Class nor Interface"); |
| 27 | 27 | } |
| 28 | 28 | } |
@@ -35,10 +35,10 @@ discard block |
||
| 35 | 35 | * @param mixed $subject the subject |
| 36 | 36 | * @return |
| 37 | 37 | */ |
| 38 | - public function notify($name, $subject){
|
|
| 38 | + public function notify($name, $subject) {
|
|
| 39 | 39 | $res = false; |
| 40 | - foreach(Reflection::getImplementedClassesAndInterfaces($name) as $cls){
|
|
| 41 | - if(parent::hasListeners($cls)){
|
|
| 40 | + foreach (Reflection::getImplementedClassesAndInterfaces($name) as $cls) {
|
|
| 41 | + if (parent::hasListeners($cls)) {
|
|
| 42 | 42 | self::doNotify($this->getListeners($cls), $subject); |
| 43 | 43 | $res = true; |
| 44 | 44 | } |
@@ -56,10 +56,10 @@ discard block |
||
| 56 | 56 | * @param mixed $subject the subject |
| 57 | 57 | * @return \PEIP\INF\Handler\Handler listener which returned a boolean true value |
| 58 | 58 | */ |
| 59 | - public function notifyUntil($name, $subject){
|
|
| 59 | + public function notifyUntil($name, $subject) {
|
|
| 60 | 60 | $res = NULL; |
| 61 | - foreach(Reflection::getImplementedClassesAndInterfaces($name) as $cls){
|
|
| 62 | - if(!$res && parent::hasListeners($cls)){
|
|
| 61 | + foreach (Reflection::getImplementedClassesAndInterfaces($name) as $cls) {
|
|
| 62 | + if (!$res && parent::hasListeners($cls)) {
|
|
| 63 | 63 | $res = self::doNotifyUntil($this->getListeners($cls), $subject); |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * @param mixed $subject the subject |
| 76 | 76 | * @return |
| 77 | 77 | */ |
| 78 | - public function notifyOfInstance($subject){
|
|
| 78 | + public function notifyOfInstance($subject) {
|
|
| 79 | 79 | |
| 80 | 80 | return $this->notify(get_class($subject), $subject); |
| 81 | 81 | } |
@@ -86,9 +86,9 @@ discard block |
||
| 86 | 86 | * @param string $name name of the event |
| 87 | 87 | * @return boolean wether any listener is registered for event-name |
| 88 | 88 | */ |
| 89 | - public function hasListeners($name){
|
|
| 90 | - foreach(Reflection::getImplementedClassesAndInterfaces($name) as $cls){
|
|
| 91 | - if(parent::hasListeners($cls)){
|
|
| 89 | + public function hasListeners($name) {
|
|
| 90 | + foreach (Reflection::getImplementedClassesAndInterfaces($name) as $cls) {
|
|
| 91 | + if (parent::hasListeners($cls)) {
|
|
| 92 | 92 | return true; |
| 93 | 93 | } |
| 94 | 94 | } |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | * @implements \PEIP\INF\Base\Container, \PEIP\INF\Message\Message, \PEIP\INF\Base\Buildable |
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | -use PEIP\Util\Test; |
|
| 23 | +use PEIP\Util\Test; |
|
| 24 | 24 | use PEIP\Base\GenericBuilder; |
| 25 | 25 | |
| 26 | 26 | class GenericMessage |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | protected function getMessage($object){
|
| 18 | 18 | if($this->channel instanceof \PEIP\INF\Channel\SubscribableChannel){
|
| 19 | 19 | return $object; |
| 20 | - }else{
|
|
| 20 | + } else{
|
|
| 21 | 21 | return $object->getContent()->receive(); |
| 22 | 22 | } |
| 23 | 23 | } |
@@ -65,7 +65,6 @@ |
||
| 65 | 65 | * Disconnects all listeners. |
| 66 | 66 | * |
| 67 | 67 | * @access public |
| 68 | - * @param Callable|PEIP\INF\Handler\Handler $listener |
|
| 69 | 68 | * @return void |
| 70 | 69 | */ |
| 71 | 70 | public function disconnectAll(){
|
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * @param Callable|PEIP\INF\Handler\Handler $listener |
| 41 | 41 | * @return void |
| 42 | 42 | */ |
| 43 | - public function connect($listener){
|
|
| 43 | + public function connect($listener) {
|
|
| 44 | 44 | Test::ensureHandler($listener); |
| 45 | 45 | $this->listeners[] = $listener; |
| 46 | 46 | } |
@@ -52,10 +52,10 @@ discard block |
||
| 52 | 52 | * @param Callable|PEIP\INF\Handler\Handler $listener |
| 53 | 53 | * @return void |
| 54 | 54 | */ |
| 55 | - public function disconnect($listener){
|
|
| 55 | + public function disconnect($listener) {
|
|
| 56 | 56 | Test::ensureHandler($listener); |
| 57 | - foreach ($this->listeners as $i => $callable){
|
|
| 58 | - if ($listener === $callable){
|
|
| 57 | + foreach ($this->listeners as $i => $callable) {
|
|
| 58 | + if ($listener === $callable) {
|
|
| 59 | 59 | unset($this->listeners[$i]); |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @param Callable|PEIP\INF\Handler\Handler $listener |
| 69 | 69 | * @return void |
| 70 | 70 | */ |
| 71 | - public function disconnectAll(){
|
|
| 71 | + public function disconnectAll() {
|
|
| 72 | 72 | $this->listeners = array(); |
| 73 | 73 | } |
| 74 | 74 | |
@@ -78,8 +78,8 @@ discard block |
||
| 78 | 78 | * @access public |
| 79 | 79 | * @return boolean wether any listeners are registered |
| 80 | 80 | */ |
| 81 | - public function hasListeners(){
|
|
| 82 | - return (boolean) count($this->listeners); |
|
| 81 | + public function hasListeners() {
|
|
| 82 | + return (boolean)count($this->listeners); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -89,9 +89,9 @@ discard block |
||
| 89 | 89 | * @param mixed $subject the subject |
| 90 | 90 | * @return void |
| 91 | 91 | */ |
| 92 | - public function notify($subject){
|
|
| 92 | + public function notify($subject) {
|
|
| 93 | 93 | $res = NULL; |
| 94 | - if($this->hasListeners()){
|
|
| 94 | + if ($this->hasListeners()) {
|
|
| 95 | 95 | $res = self::doNotify($this->getListeners(), $subject); |
| 96 | 96 | } |
| 97 | 97 | return $res; |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | * @param mixed $subject the subject |
| 105 | 105 | * @return \PEIP\INF\Handler\Handler the listener which returned a boolean true value |
| 106 | 106 | */ |
| 107 | - public function notifyUntil($subject){
|
|
| 108 | - if($this->hasListeners()){
|
|
| 107 | + public function notifyUntil($subject) {
|
|
| 108 | + if ($this->hasListeners()) {
|
|
| 109 | 109 | $res = self::doNotifyUntil($this->getListeners(), $subject); |
| 110 | 110 | } |
| 111 | 111 | return $res; |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | * @access public |
| 118 | 118 | * @return array the listeners |
| 119 | 119 | */ |
| 120 | - public function getListeners(){
|
|
| 120 | + public function getListeners() {
|
|
| 121 | 121 | return $this->listeners; |
| 122 | 122 | } |
| 123 | 123 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * @access public |
| 24 | 24 | * @param string $name name of the event |
| 25 | 25 | * @param \PEIP\INF\Event\Event $object an event object |
| 26 | - * @return boolean |
|
| 26 | + * @return boolean|null |
|
| 27 | 27 | */ |
| 28 | 28 | public function notify($name, $object){
|
| 29 | 29 | if($object instanceof \PEIP\INF\Event\Event){
|
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * @param array $headers headers of the event-object as key/value pairs |
| 54 | 54 | * @param string $eventClass event-class to create instances from |
| 55 | 55 | * @return |
| 56 | - * @see EventBuilder |
|
| 56 | + boolean|null @see EventBuilder |
|
| 57 | 57 | */ |
| 58 | 58 | public function buildAndNotify($name, $object, array $headers = array(), $eventClass = false, $type = false){
|
| 59 | 59 | if(!$this->hasListeners($name, ($object))){
|
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | * |
| 12 | 12 | * @author timo |
| 13 | 13 | */ |
| 14 | -use PEIP\Event\EventBuilder; |
|
| 14 | +use PEIP\Event\EventBuilder; |
|
| 15 | 15 | use PEIP\Util\ReflectionPool; |
| 16 | 16 | |
| 17 | 17 | class EventClassDispatcher |
@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | $this->getListeners( |
| 33 | 33 | $name, |
| 34 | 34 | $object |
| 35 | - ), |
|
| 36 | - $object->getContent() |
|
| 37 | - ); |
|
| 35 | + ), |
|
| 36 | + $object->getContent() |
|
| 37 | + ); |
|
| 38 | 38 | }else{
|
| 39 | 39 | throw new \InvalidArgumentException('instance of \PEIP\INF\Event\Event must contain subject');
|
| 40 | 40 | } |
@@ -43,18 +43,18 @@ discard block |
||
| 43 | 43 | } |
| 44 | 44 | } //put your code here |
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Creates an event-object with given object as content/subject and notifies |
|
| 48 | - * all registers listeners of the event. |
|
| 49 | - * |
|
| 50 | - * @access public |
|
| 51 | - * @param string $name name of the event |
|
| 52 | - * @param object $object the subject of the event |
|
| 53 | - * @param array $headers headers of the event-object as key/value pairs |
|
| 54 | - * @param string $eventClass event-class to create instances from |
|
| 55 | - * @return |
|
| 56 | - * @see EventBuilder |
|
| 57 | - */ |
|
| 46 | + /** |
|
| 47 | + * Creates an event-object with given object as content/subject and notifies |
|
| 48 | + * all registers listeners of the event. |
|
| 49 | + * |
|
| 50 | + * @access public |
|
| 51 | + * @param string $name name of the event |
|
| 52 | + * @param object $object the subject of the event |
|
| 53 | + * @param array $headers headers of the event-object as key/value pairs |
|
| 54 | + * @param string $eventClass event-class to create instances from |
|
| 55 | + * @return |
|
| 56 | + * @see EventBuilder |
|
| 57 | + */ |
|
| 58 | 58 | public function buildAndNotify($name, $object, array $headers = array(), $eventClass = false, $type = false){
|
| 59 | 59 | if(!$this->hasListeners($name, ($object))){
|
| 60 | 60 | return false; |
@@ -25,9 +25,9 @@ discard block |
||
| 25 | 25 | * @param \PEIP\INF\Event\Event $object an event object |
| 26 | 26 | * @return boolean |
| 27 | 27 | */ |
| 28 | - public function notify($name, $object){
|
|
| 29 | - if($object instanceof \PEIP\INF\Event\Event){
|
|
| 30 | - if(is_object($object->getContent())){
|
|
| 28 | + public function notify($name, $object) {
|
|
| 29 | + if ($object instanceof \PEIP\INF\Event\Event) {
|
|
| 30 | + if (is_object($object->getContent())) {
|
|
| 31 | 31 | return self::doNotify( |
| 32 | 32 | $this->getListeners( |
| 33 | 33 | $name, |
@@ -35,10 +35,10 @@ discard block |
||
| 35 | 35 | ), |
| 36 | 36 | $object->getContent() |
| 37 | 37 | ); |
| 38 | - }else{
|
|
| 38 | + }else {
|
|
| 39 | 39 | throw new \InvalidArgumentException('instance of \PEIP\INF\Event\Event must contain subject');
|
| 40 | 40 | } |
| 41 | - }else{
|
|
| 41 | + }else {
|
|
| 42 | 42 | throw new \InvalidArgumentException('object must be instance of \PEIP\INF\Event\Event');
|
| 43 | 43 | } |
| 44 | 44 | } //put your code here |
@@ -55,8 +55,8 @@ discard block |
||
| 55 | 55 | * @return |
| 56 | 56 | * @see EventBuilder |
| 57 | 57 | */ |
| 58 | - public function buildAndNotify($name, $object, array $headers = array(), $eventClass = false, $type = false){
|
|
| 59 | - if(!$this->hasListeners($name, ($object))){
|
|
| 58 | + public function buildAndNotify($name, $object, array $headers = array(), $eventClass = false, $type = false) {
|
|
| 59 | + if (!$this->hasListeners($name, ($object))) {
|
|
| 60 | 60 | return false; |
| 61 | 61 | } |
| 62 | 62 | |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | * @param object $object object to check for listeners |
| 80 | 80 | * @return boolean |
| 81 | 81 | */ |
| 82 | - public function hasListeners($name, $object){
|
|
| 82 | + public function hasListeners($name, $object) {
|
|
| 83 | 83 | return parent::hasListeners( |
| 84 | 84 | $name, |
| 85 | 85 | ReflectionPool::getInstance($object) |
@@ -70,10 +70,10 @@ |
||
| 70 | 70 | ), |
| 71 | 71 | $object |
| 72 | 72 | ); |
| 73 | - }else{
|
|
| 73 | + } else{
|
|
| 74 | 74 | throw new \InvalidArgumentException('instance of \PEIP\INF\Event\Event must contain subject');
|
| 75 | 75 | } |
| 76 | - }else{
|
|
| 76 | + } else{
|
|
| 77 | 77 | throw new \InvalidArgumentException('object must be instance of \PEIP\INF\Event\Event');
|
| 78 | 78 | } |
| 79 | 79 | } //put your code here |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | * @access public |
| 39 | 39 | * @param string $name name of the event |
| 40 | 40 | * @param \PEIP\INF\Event\Event $object an event object |
| 41 | - * @return boolean |
|
| 41 | + * @return boolean|null |
|
| 42 | 42 | */ |
| 43 | 43 | public function notify($name, $object){
|
| 44 | 44 | if($object instanceof \PEIP\INF\Event\Event){
|
@@ -40,16 +40,16 @@ discard block |
||
| 40 | 40 | * @param \PEIP\INF\Event\Event $object an event object |
| 41 | 41 | * @return boolean |
| 42 | 42 | */ |
| 43 | - public function notify($name, $object){
|
|
| 44 | - if($object instanceof \PEIP\INF\Event\Event){
|
|
| 45 | - if(is_object($object->getContent())){
|
|
| 46 | - if($this->hasListeners($name, $object->getContent())){
|
|
| 43 | + public function notify($name, $object) {
|
|
| 44 | + if ($object instanceof \PEIP\INF\Event\Event) {
|
|
| 45 | + if (is_object($object->getContent())) {
|
|
| 46 | + if ($this->hasListeners($name, $object->getContent())) {
|
|
| 47 | 47 | return self::doNotify($this->getListeners($name, $object->getContent()), $object); |
| 48 | 48 | } |
| 49 | - }else{
|
|
| 49 | + }else {
|
|
| 50 | 50 | throw new \InvalidArgumentException('instance of \PEIP\INF\Event\Event must contain subject');
|
| 51 | 51 | } |
| 52 | - }else{
|
|
| 52 | + }else {
|
|
| 53 | 53 | throw new \InvalidArgumentException('object must be instance of \PEIP\INF\Event\Event');
|
| 54 | 54 | } |
| 55 | 55 | } |
@@ -66,8 +66,8 @@ discard block |
||
| 66 | 66 | * @return |
| 67 | 67 | * @see EventBuilder |
| 68 | 68 | */ |
| 69 | - public function buildAndNotify($name, $object, array $headers = array(), $eventClass = false, $type = false){
|
|
| 70 | - if(!$this->hasListeners($name, $object)){
|
|
| 69 | + public function buildAndNotify($name, $object, array $headers = array(), $eventClass = false, $type = false) {
|
|
| 70 | + if (!$this->hasListeners($name, $object)) {
|
|
| 71 | 71 | return false; |
| 72 | 72 | } |
| 73 | 73 | $event = EventBuilder::getInstance($eventClass)->build( |
@@ -70,10 +70,10 @@ |
||
| 70 | 70 | ), |
| 71 | 71 | $object |
| 72 | 72 | ); |
| 73 | - }else{
|
|
| 73 | + } else{
|
|
| 74 | 74 | throw new \InvalidArgumentException('instance of \PEIP\INF\Event\Event must contain subject');
|
| 75 | 75 | } |
| 76 | - }else{
|
|
| 76 | + } else{
|
|
| 77 | 77 | throw new \InvalidArgumentException('object must be instance of \PEIP\INF\Event\Event');
|
| 78 | 78 | } |
| 79 | 79 | } //put your code here |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * @access public |
| 163 | 163 | * @param $name |
| 164 | 164 | * @param $subject |
| 165 | - * @return mixed |
|
| 165 | + * @return \PEIP\INF\Handler\Handler |
|
| 166 | 166 | */ |
| 167 | 167 | public function notifyUntil($name, $subject){
|
| 168 | 168 | if($this->hasListeners($name, $subject)){
|
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | * @access protected |
| 206 | 206 | * @param $name |
| 207 | 207 | * @param $object |
| 208 | - * @return boolean |
|
| 208 | + * @return boolean|null |
|
| 209 | 209 | */ |
| 210 | 210 | protected static function doNotify(array $listeners, $subject){
|
| 211 | 211 | foreach($listeners as $listener){
|
@@ -209,11 +209,11 @@ |
||
| 209 | 209 | */ |
| 210 | 210 | protected static function doNotify(array $listeners, $subject){
|
| 211 | 211 | foreach($listeners as $listener){
|
| 212 | - if($listener instanceof \PEIP\INF\Handler\Handler){
|
|
| 212 | + if($listener instanceof \PEIP\INF\Handler\Handler){
|
|
| 213 | 213 | $listener->handle($subject); |
| 214 | - }elseif(is_callable($listener)){
|
|
| 215 | - call_user_func($listener, $subject); |
|
| 216 | - } |
|
| 214 | + }elseif(is_callable($listener)){
|
|
| 215 | + call_user_func($listener, $subject); |
|
| 216 | + } |
|
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | |
@@ -43,13 +43,13 @@ discard block |
||
| 43 | 43 | * @param Callable|PEIP\INF\Handler\Handler $listener event-handler |
| 44 | 44 | * @return boolean |
| 45 | 45 | */ |
| 46 | - public function connect($name, $object, $listener){
|
|
| 46 | + public function connect($name, $object, $listener) {
|
|
| 47 | 47 | Test::ensureHandler($listener); |
| 48 | 48 | $listners = $this->doGetListeners(); |
| 49 | - if (!$this->listeners->contains($object)){
|
|
| 49 | + if (!$this->listeners->contains($object)) {
|
|
| 50 | 50 | $this->listeners->attach($object, new \ArrayObject); |
| 51 | 51 | } |
| 52 | - if (!array_key_exists($name, $listners[$object])){
|
|
| 52 | + if (!array_key_exists($name, $listners[$object])) {
|
|
| 53 | 53 | $this->listeners[$object][$name] = array(); |
| 54 | 54 | } |
| 55 | 55 | $hash = $this->getListenerHash($listener); |
@@ -67,14 +67,14 @@ discard block |
||
| 67 | 67 | * @param \PEIP\INF\Handler\Handler $listener event-handler |
| 68 | 68 | * @return boolean |
| 69 | 69 | */ |
| 70 | - public function disconnect($name, $object, $listener){
|
|
| 70 | + public function disconnect($name, $object, $listener) {
|
|
| 71 | 71 | $listners = $this->doGetListeners(); |
| 72 | - if (!$listners->contains($object) || !isset($listners[$object][$name])){
|
|
| 72 | + if (!$listners->contains($object) || !isset($listners[$object][$name])) {
|
|
| 73 | 73 | return false; |
| 74 | 74 | } |
| 75 | 75 | $eventListeners = $listners[$object][$name]; |
| 76 | 76 | $hash = $this->getListenerHash($listener); |
| 77 | - if(isset($eventListeners[$hash])){
|
|
| 77 | + if (isset($eventListeners[$hash])) {
|
|
| 78 | 78 | unset($eventListeners[$hash]); |
| 79 | 79 | |
| 80 | 80 | $listners[$object][$name] = $eventListeners; |
@@ -83,10 +83,10 @@ discard block |
||
| 83 | 83 | return false; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - public function disconnectAll($name, $object){
|
|
| 87 | - if(is_object($object)){
|
|
| 86 | + public function disconnectAll($name, $object) {
|
|
| 87 | + if (is_object($object)) {
|
|
| 88 | 88 | $listners = $this->doGetListeners(); |
| 89 | - if($listners && $this->hadListeners($name, $object)){
|
|
| 89 | + if ($listners && $this->hadListeners($name, $object)) {
|
|
| 90 | 90 | $listners[$object][$name] = array(); |
| 91 | 91 | } |
| 92 | 92 | } |
@@ -100,13 +100,13 @@ discard block |
||
| 100 | 100 | * @param object $object object to check for listeners |
| 101 | 101 | * @return boolean |
| 102 | 102 | */ |
| 103 | - public function hasListeners($name, $object){
|
|
| 103 | + public function hasListeners($name, $object) {
|
|
| 104 | 104 | $listners = $this->doGetListeners(); |
| 105 | - if (!$this->hadListeners($name, $object)){
|
|
| 105 | + if (!$this->hadListeners($name, $object)) {
|
|
| 106 | 106 | $res = false; |
| 107 | - }else{
|
|
| 107 | + }else {
|
|
| 108 | 108 | $listners = $this->doGetListeners(); |
| 109 | - $res = (boolean) count($listners[$object][$name]); |
|
| 109 | + $res = (boolean)count($listners[$object][$name]); |
|
| 110 | 110 | } |
| 111 | 111 | return $res; |
| 112 | 112 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | * @param object $object object to check for listeners |
| 120 | 120 | * @return boolean |
| 121 | 121 | */ |
| 122 | - public function hadListeners($name, $object){
|
|
| 122 | + public function hadListeners($name, $object) {
|
|
| 123 | 123 | $listners = $this->doGetListeners(); |
| 124 | 124 | return ($listners->contains($object) && isset($listners[$object][$name])) ? true : false; |
| 125 | 125 | } |
@@ -131,9 +131,9 @@ discard block |
||
| 131 | 131 | * @param object $object object to get event-names for |
| 132 | 132 | * @return string[] array of event-names |
| 133 | 133 | */ |
| 134 | - public function getEventNames($object){
|
|
| 134 | + public function getEventNames($object) {
|
|
| 135 | 135 | $listeners = $this->doGetListeners(); |
| 136 | - if (!$listeners->contains($object)){
|
|
| 136 | + if (!$listeners->contains($object)) {
|
|
| 137 | 137 | return array(); |
| 138 | 138 | } |
| 139 | 139 | return array_keys($listeners[$object]->getArrayCopy()); |
@@ -147,8 +147,8 @@ discard block |
||
| 147 | 147 | * @param $object |
| 148 | 148 | * @return boolean |
| 149 | 149 | */ |
| 150 | - public function notify($name, $object){
|
|
| 151 | - if($this->hasListeners($name, $object)){
|
|
| 150 | + public function notify($name, $object) {
|
|
| 151 | + if ($this->hasListeners($name, $object)) {
|
|
| 152 | 152 | $listners = $this->doGetListeners(); |
| 153 | 153 | self::doNotify($listners[$object][$name], $object); |
| 154 | 154 | } |
@@ -164,8 +164,8 @@ discard block |
||
| 164 | 164 | * @param $subject |
| 165 | 165 | * @return mixed |
| 166 | 166 | */ |
| 167 | - public function notifyUntil($name, $subject){
|
|
| 168 | - if($this->hasListeners($name, $subject)){
|
|
| 167 | + public function notifyUntil($name, $subject) {
|
|
| 168 | + if ($this->hasListeners($name, $subject)) {
|
|
| 169 | 169 | $res = self::doNotifyUntil($this->getListeners($name, $subject), $subject); |
| 170 | 170 | } |
| 171 | 171 | return $res; |
@@ -179,8 +179,8 @@ discard block |
||
| 179 | 179 | * @param object $object object to check for listeners |
| 180 | 180 | * @return array array of listeners |
| 181 | 181 | */ |
| 182 | - public function getListeners($name, $object){
|
|
| 183 | - if (!$this->hadListeners($name, $object)){
|
|
| 182 | + public function getListeners($name, $object) {
|
|
| 183 | + if (!$this->hadListeners($name, $object)) {
|
|
| 184 | 184 | return array(); |
| 185 | 185 | } |
| 186 | 186 | $listeners = $this->listeners[$object]->getArrayCopy(); |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | * @access protected |
| 195 | 195 | * @return ObjectStorage |
| 196 | 196 | */ |
| 197 | - protected function doGetListeners(){
|
|
| 197 | + protected function doGetListeners() {
|
|
| 198 | 198 | return isset($this->listeners) ? $this->listeners : $this->listeners = new ObjectStorage(); |
| 199 | 199 | } |
| 200 | 200 | |
@@ -207,11 +207,11 @@ discard block |
||
| 207 | 207 | * @param $object |
| 208 | 208 | * @return boolean |
| 209 | 209 | */ |
| 210 | - protected static function doNotify(array $listeners, $subject){
|
|
| 211 | - foreach($listeners as $listener){
|
|
| 212 | - if($listener instanceof \PEIP\INF\Handler\Handler){
|
|
| 210 | + protected static function doNotify(array $listeners, $subject) {
|
|
| 211 | + foreach ($listeners as $listener) {
|
|
| 212 | + if ($listener instanceof \PEIP\INF\Handler\Handler) {
|
|
| 213 | 213 | $listener->handle($subject); |
| 214 | - }elseif(is_callable($listener)){
|
|
| 214 | + }elseif (is_callable($listener)) {
|
|
| 215 | 215 | call_user_func($listener, $subject); |
| 216 | 216 | } |
| 217 | 217 | } |
@@ -226,12 +226,12 @@ discard block |
||
| 226 | 226 | * @param $object |
| 227 | 227 | * @return \PEIP\INF\Handler\Handler the listener which returned a boolean true value |
| 228 | 228 | */ |
| 229 | - protected static function doNotifyUntil(array $listeners, $subject){
|
|
| 229 | + protected static function doNotifyUntil(array $listeners, $subject) {
|
|
| 230 | 230 | $res = NULL; |
| 231 | - foreach ($listeners as $listener){
|
|
| 232 | - if($listener instanceof \PEIP\INF\Handler\Handler){
|
|
| 231 | + foreach ($listeners as $listener) {
|
|
| 232 | + if ($listener instanceof \PEIP\INF\Handler\Handler) {
|
|
| 233 | 233 | $res = $listener->handle($subject); |
| 234 | - if ($res){
|
|
| 234 | + if ($res) {
|
|
| 235 | 235 | return $listener; |
| 236 | 236 | } |
| 237 | 237 | } |
@@ -239,8 +239,8 @@ discard block |
||
| 239 | 239 | return $res; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - protected function getListenerHash($listener){
|
|
| 243 | - if(!is_object($listener)){
|
|
| 242 | + protected function getListenerHash($listener) {
|
|
| 243 | + if (!is_object($listener)) {
|
|
| 244 | 244 | $o = new \stdClass(); |
| 245 | 245 | $o->listener = $listener; |
| 246 | 246 | $listener = $o; |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | $listners = $this->doGetListeners(); |
| 105 | 105 | if (!$this->hadListeners($name, $object)){
|
| 106 | 106 | $res = false; |
| 107 | - }else{
|
|
| 107 | + } else{
|
|
| 108 | 108 | $listners = $this->doGetListeners(); |
| 109 | 109 | $res = (boolean) count($listners[$object][$name]); |
| 110 | 110 | } |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | foreach($listeners as $listener){
|
| 212 | 212 | if($listener instanceof \PEIP\INF\Handler\Handler){
|
| 213 | 213 | $listener->handle($subject); |
| 214 | - }elseif(is_callable($listener)){
|
|
| 214 | + } elseif(is_callable($listener)){
|
|
| 215 | 215 | call_user_func($listener, $subject); |
| 216 | 216 | } |
| 217 | 217 | } |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | * @implements \PEIP\INF\Base\Container, \PEIP\INF\Message\Message, \PEIP\INF\Base\Buildable |
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | -use PEIP\Util\Test; |
|
| 23 | +use PEIP\Util\Test; |
|
| 24 | 24 | use PEIP\Base\GenericBuilder; |
| 25 | 25 | |
| 26 | 26 | class GenericMessage |
@@ -49,7 +49,6 @@ |
||
| 49 | 49 | * @access public |
| 50 | 50 | * @param mixed $subject the subject for the event |
| 51 | 51 | * @param string $name the name of the event |
| 52 | - * @param array|ArrayAccess $headers the headers for the event |
|
| 53 | 52 | */ |
| 54 | 53 | public function __construct($subject, $name, $parameters = array(), $type = false){
|
| 55 | 54 | parent::__construct($subject, Test::ensureArrayAccess($parameters)); |
@@ -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 | } |