@@ -39,7 +39,7 @@ |
||
39 | 39 | * |
40 | 40 | * @access public |
41 | 41 | * @param string $className class-name to create objects for |
42 | - * @param ReflectionClass $reflectionClass reflection-class for class. default: NULL |
|
42 | + * @param \ReflectionClass $reflectionClass reflection-class for class. default: NULL |
|
43 | 43 | * @param boolean $storeRef wether to store a reference for new instance. default: true |
44 | 44 | * @return |
45 | 45 | */ |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | * @param boolean $storeRef wether to store a reference for new instance. default: true |
44 | 44 | * @return |
45 | 45 | */ |
46 | - public function __construct($className, \ReflectionClass $reflectionClass = NULL, $storeRef = true){ |
|
47 | - if($reflectionClass ){ |
|
46 | + public function __construct($className, \ReflectionClass $reflectionClass = NULL, $storeRef = true) { |
|
47 | + if ($reflectionClass) { |
|
48 | 48 | |
49 | - if($reflectionClass->getName() != $className){ |
|
49 | + if ($reflectionClass->getName() != $className) { |
|
50 | 50 | throw new \Exception( |
51 | 51 | 'Constructing GenericBuilder with wrong ReflectionClass' |
52 | 52 | ); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $this->reflectionClass = $reflectionClass; |
57 | 57 | } |
58 | 58 | $this->className = $className; |
59 | - if($storeRef){ |
|
59 | + if ($storeRef) { |
|
60 | 60 | self::$instances[$this->className] = $this; |
61 | 61 | } |
62 | 62 | } |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * @param string $className class-name to return builder instance for |
69 | 69 | * @return GenericBuilder builder instance for class |
70 | 70 | */ |
71 | - public static function getInstance($className){ |
|
72 | - if(!array_key_exists((string)$className, self::$instances)) { |
|
71 | + public static function getInstance($className) { |
|
72 | + if (!array_key_exists((string)$className, self::$instances)) { |
|
73 | 73 | new GenericBuilder($className); |
74 | 74 | } |
75 | 75 | return self::$instances[$className]; |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | * @param array $arguments array of constructore arguments |
83 | 83 | * @return object the created object instance |
84 | 84 | */ |
85 | - public function build(array $arguments = array()){ |
|
86 | - if(Test::assertClassHasConstructor($this->className)){ |
|
87 | - if(!Test::assertRequiredConstructorParameters($this->className, $arguments)){ |
|
85 | + public function build(array $arguments = array()) { |
|
86 | + if (Test::assertClassHasConstructor($this->className)) { |
|
87 | + if (!Test::assertRequiredConstructorParameters($this->className, $arguments)) { |
|
88 | 88 | throw new \Exception('Missing Argument '.(count($arguments) + 1).' for '.$this->className.'::__construct'); |
89 | 89 | } |
90 | 90 | return $this->getReflectionClass()->newInstanceArgs($arguments); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @access public |
99 | 99 | * @return ReflectionClass |
100 | 100 | */ |
101 | - public function getReflectionClass(){ |
|
101 | + public function getReflectionClass() { |
|
102 | 102 | return ReflectionPool::getInstance($this->className); |
103 | 103 | } |
104 | 104 |
@@ -83,7 +83,6 @@ |
||
83 | 83 | * @param ObjectEventDispatcher $dispatcher the dispatcher to dispatch the event |
84 | 84 | * @param mixed $subject the subject for the event |
85 | 85 | * @param string $name the name of the event |
86 | - * @param array $parameters the headers for the event |
|
87 | 86 | * @return |
88 | 87 | */ |
89 | 88 | public function buildAndDispatch(ObjectEventDispatcher $dispatcher, $subject, $name, array $headers = array()){ |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @param string $eventClass the event-class the builder shall create instances for |
38 | 38 | * @param array $defaultHeaders default headers for the created events |
39 | 39 | */ |
40 | - public function __construct($eventClass = '\PEIP\Event\Event', array $defaultHeaders = array()){ |
|
40 | + public function __construct($eventClass = '\PEIP\Event\Event', array $defaultHeaders = array()) { |
|
41 | 41 | $this->eventClass = $eventClass; |
42 | 42 | $this->defaultParameters = $defaultHeaders; |
43 | 43 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param string $eventClass the event-class the builder shall create instances for |
50 | 50 | * @return EventBuilder the instance of EventBuilder for the given event-class |
51 | 51 | */ |
52 | - public static function getInstance($eventClass = '\PEIP\Event\Event'){ |
|
52 | + public static function getInstance($eventClass = '\PEIP\Event\Event') { |
|
53 | 53 | |
54 | 54 | return isset(self::$instances[$eventClass]) |
55 | 55 | ? self::$instances[$eventClass] |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param array $headers the headers for the event |
68 | 68 | * @return object event instance |
69 | 69 | */ |
70 | - public function build($subject, $name, array $headers = array()){ |
|
70 | + public function build($subject, $name, array $headers = array()) { |
|
71 | 71 | |
72 | 72 | return new $this->eventClass( |
73 | 73 | $subject, |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @param array $parameters the headers for the event |
87 | 87 | * @return |
88 | 88 | */ |
89 | - public function buildAndDispatch(ObjectEventDispatcher $dispatcher, $subject, $name, array $headers = array()){ |
|
89 | + public function buildAndDispatch(ObjectEventDispatcher $dispatcher, $subject, $name, array $headers = array()) { |
|
90 | 90 | |
91 | 91 | return $dispatcher->notify( |
92 | 92 | $name, |
@@ -43,7 +43,7 @@ |
||
43 | 43 | class_exists($className); |
44 | 44 | $res = ReflectionPool::getInstance($className) |
45 | 45 | ->implementsInterface($interfaceName); |
46 | - } catch (\Exception $e){ |
|
46 | + } catch (\Exception $e){ |
|
47 | 47 | $res = false; |
48 | 48 | } |
49 | 49 | return $res;; |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | class Test { |
16 | 16 | |
17 | 17 | |
18 | - public static function assertClassHasConstructor($className){ |
|
19 | - return (boolean) ReflectionPool::getInstance($className)->getConstructor(); |
|
18 | + public static function assertClassHasConstructor($className) { |
|
19 | + return (boolean)ReflectionPool::getInstance($className)->getConstructor(); |
|
20 | 20 | } |
21 | 21 | |
22 | - public static function assertRequiredConstructorParameters($className, $parameters){ |
|
22 | + public static function assertRequiredConstructorParameters($className, $parameters) { |
|
23 | 23 | return (boolean) |
24 | 24 | !self::assertClassHasConstructor($className) || |
25 | 25 | count($parameters) >= ReflectionPool::getInstance($className) |
@@ -27,55 +27,55 @@ discard block |
||
27 | 27 | ->getNumberOfRequiredParameters(); |
28 | 28 | } |
29 | 29 | |
30 | - public static function assertInstanceOf($className, $object){ |
|
31 | - return (boolean) ReflectionPool::getInstance($className) |
|
30 | + public static function assertInstanceOf($className, $object) { |
|
31 | + return (boolean)ReflectionPool::getInstance($className) |
|
32 | 32 | ->isInstance($object); |
33 | 33 | } |
34 | 34 | |
35 | - public static function assertClassOrInterfaceExists($className){ |
|
36 | - return (boolean) class_exists($className) || interface_exists($className); |
|
35 | + public static function assertClassOrInterfaceExists($className) { |
|
36 | + return (boolean)class_exists($className) || interface_exists($className); |
|
37 | 37 | } |
38 | 38 | |
39 | - public static function assertImplements($className, $interfaceName){ |
|
39 | + public static function assertImplements($className, $interfaceName) { |
|
40 | 40 | $className = is_object($className) ? get_class($className) : $className; |
41 | - $res = false;//throw new \Exception(); |
|
41 | + $res = false; //throw new \Exception(); |
|
42 | 42 | try { |
43 | 43 | class_exists($className); |
44 | - $res = ReflectionPool::getInstance($className) |
|
44 | + $res = ReflectionPool::getInstance($className) |
|
45 | 45 | ->implementsInterface($interfaceName); |
46 | - } catch (\Exception $e){ |
|
46 | + } catch (\Exception $e) { |
|
47 | 47 | $res = false; |
48 | 48 | } |
49 | - return $res;; |
|
49 | + return $res; ; |
|
50 | 50 | } |
51 | 51 | |
52 | - public static function assertMessage($message){ |
|
52 | + public static function assertMessage($message) { |
|
53 | 53 | return self::assertImplements($message, '\PEIP\INF\Message\Message'); |
54 | 54 | } |
55 | 55 | |
56 | - public static function assertEvent($event){ |
|
56 | + public static function assertEvent($event) { |
|
57 | 57 | return self::assertImplements($event, '\PEIP\INF\Event\Event'); |
58 | 58 | } |
59 | 59 | |
60 | - public static function assertEventSubject($event){ |
|
60 | + public static function assertEventSubject($event) { |
|
61 | 61 | return self::assertImplements($event, '\PEIP\INF\Event\Event') |
62 | 62 | && $event->getSubject(); |
63 | 63 | } |
64 | 64 | |
65 | - public static function assertEventObjectSubject($event){ |
|
65 | + public static function assertEventObjectSubject($event) { |
|
66 | 66 | return self::assertEventSubject($event) |
67 | 67 | && is_object($event->getSubject()); |
68 | 68 | } |
69 | - public static function assertArrayAccess($var){ |
|
70 | - return (boolean) is_array($var) || $var instanceof \ArrayAccess; |
|
69 | + public static function assertArrayAccess($var) { |
|
70 | + return (boolean)is_array($var) || $var instanceof \ArrayAccess; |
|
71 | 71 | } |
72 | 72 | |
73 | - public static function assertHandler($var){ |
|
74 | - return (boolean) is_callable($var) || $var instanceof \PEIP\INF\Handler\Handler; |
|
73 | + public static function assertHandler($var) { |
|
74 | + return (boolean)is_callable($var) || $var instanceof \PEIP\INF\Handler\Handler; |
|
75 | 75 | } |
76 | 76 | |
77 | - public static function castType($var, $type){ |
|
78 | - switch($type){ |
|
77 | + public static function castType($var, $type) { |
|
78 | + switch ($type) { |
|
79 | 79 | case 'string': |
80 | 80 | $var = (string)$var; |
81 | 81 | break; |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | return $var; |
100 | 100 | } |
101 | 101 | |
102 | - public static function ensureArrayAccess($var){ |
|
103 | - if(!Test::assertArrayAccess($var)){ |
|
102 | + public static function ensureArrayAccess($var) { |
|
103 | + if (!Test::assertArrayAccess($var)) { |
|
104 | 104 | throw new \InvalidArgumentException( |
105 | 105 | 'Value is not an array nor an instance of ArrayAccess' |
106 | 106 | ); |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | } |
110 | 110 | |
111 | 111 | |
112 | - public static function ensureHandler($var){ |
|
113 | - if(!Test::assertHandler($var)){ |
|
112 | + public static function ensureHandler($var) { |
|
113 | + if (!Test::assertHandler($var)) { |
|
114 | 114 | throw new \InvalidArgumentException( |
115 | 115 | 'Value is not an callable nor an instance of \PEIP\INF\Handler\Handler' |
116 | 116 | ); |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | return $var; |
119 | 119 | } |
120 | 120 | |
121 | - public static function ensureImplements($className, $interfaceName){ |
|
122 | - if(!Test::assertImplements($className, $interfaceName)){ |
|
121 | + public static function ensureImplements($className, $interfaceName) { |
|
122 | + if (!Test::assertImplements($className, $interfaceName)) { |
|
123 | 123 | throw new \InvalidArgumentException( |
124 | 124 | 'Class "'.$className.'" is not an instanceof "'.$interfaceName.'"' |
125 | 125 | ); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | return $className; |
128 | 128 | } |
129 | 129 | |
130 | - public static function assertMethod($className, $methodname){ |
|
130 | + public static function assertMethod($className, $methodname) { |
|
131 | 131 | return ReflectionPool::getInstance($className)->hasMethod($methodname); |
132 | 132 | } |
133 | 133 |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param $discardChannel |
34 | 34 | * @return |
35 | 35 | */ |
36 | - public function setDiscardChannel(\PEIP\INF\Channel\Channel $discardChannel){ |
|
36 | + public function setDiscardChannel(\PEIP\INF\Channel\Channel $discardChannel) { |
|
37 | 37 | $this->discardChannel = $discardChannel; |
38 | 38 | } |
39 | 39 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @access public |
43 | 43 | * @return |
44 | 44 | */ |
45 | - public function getDiscardChannel(){ |
|
45 | + public function getDiscardChannel() { |
|
46 | 46 | return $this->discardChannel; |
47 | 47 | } |
48 | 48 | |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | * @param $message |
53 | 53 | * @return |
54 | 54 | */ |
55 | - protected function discardMessage(\PEIP\INF\Message\Message $message){ |
|
56 | - if(isset($this->discardChannel)){ |
|
55 | + protected function discardMessage(\PEIP\INF\Message\Message $message) { |
|
56 | + if (isset($this->discardChannel)) { |
|
57 | 57 | $this->discardChannel->send($message); |
58 | 58 | } |
59 | 59 | } |
@@ -22,6 +22,6 @@ |
||
22 | 22 | |
23 | 23 | interface Singleton { |
24 | 24 | |
25 | - public static function getInstance (); |
|
25 | + public static function getInstance(); |
|
26 | 26 | |
27 | 27 | } |
@@ -38,7 +38,7 @@ |
||
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @access public |
41 | - * @param $name |
|
41 | + * @param string $name |
|
42 | 42 | * @param Callable|PEIP\INF\Handler\Handler $listener |
43 | 43 | * @return |
44 | 44 | */ |
@@ -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 | } |
@@ -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 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * Connects the handler to the output-channel. |
52 | 52 | * |
53 | 53 | * @access protected |
54 | - * @param \PEIP\INF\Channel\Channel $inputChannel the output-channel to connect the handler to |
|
54 | + * @param \PEIP\INF\Channel\Channel $outputChannel the output-channel to connect the handler to |
|
55 | 55 | * @return |
56 | 56 | */ |
57 | 57 | protected function doSetOutputChannel(\PEIP\INF\Channel\Channel $outputChannel){ |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * |
161 | 161 | * @access public |
162 | 162 | * @param string $messageClass name of the message-class to create reply-messages from. |
163 | - * @return PEIP\ABS\Handler\ReplyProducingMessageHandler $this |
|
163 | + * @return ReplyProducingMessageHandler $this |
|
164 | 164 | */ |
165 | 165 | public function setMessageClass($messageClass){ |
166 | 166 | $this->messageClass = $messageClass; |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | * |
194 | 194 | * @access public |
195 | 195 | * @param array $headerNames array of message-header names to look for a reply-channel |
196 | - * @return PEIP\ABS\Handler\ReplyProducingMessageHandler $this |
|
196 | + * @return ReplyProducingMessageHandler $this |
|
197 | 197 | */ |
198 | 198 | public function setReplyChannelHeaders(array $headerNames){ |
199 | 199 | $this->replyChannelHeaders = $headerNames; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param \PEIP\INF\Channel\Channel $outputChannel the output-channel |
43 | 43 | * @return \PEIP\ABS\Handler\MessageHandler $this; |
44 | 44 | */ |
45 | - public function setOutputChannel(\PEIP\INF\Channel\Channel $outputChannel){ |
|
45 | + public function setOutputChannel(\PEIP\INF\Channel\Channel $outputChannel) { |
|
46 | 46 | $this->doSetOutputChannel($outputChannel); |
47 | 47 | return $this; |
48 | 48 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param \PEIP\INF\Channel\Channel $inputChannel the output-channel to connect the handler to |
55 | 55 | * @return |
56 | 56 | */ |
57 | - protected function doSetOutputChannel(\PEIP\INF\Channel\Channel $outputChannel){ |
|
57 | + protected function doSetOutputChannel(\PEIP\INF\Channel\Channel $outputChannel) { |
|
58 | 58 | $this->outputChannel = $outputChannel; |
59 | 59 | } |
60 | 60 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @access public |
65 | 65 | * @return \PEIP\INF\Channel\Channel output-channel for this handler |
66 | 66 | */ |
67 | - public function getOutputChannel(){ |
|
67 | + public function getOutputChannel() { |
|
68 | 68 | return $this->outputChannel; |
69 | 69 | } |
70 | 70 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @param \PEIP\INF\Message\Message $message the message to resolve output-channel for |
79 | 79 | * @return \PEIP\INF\Channel\Channel the output-channel for the message |
80 | 80 | */ |
81 | - protected function doGetOutputChannel(\PEIP\INF\Message\Message $message){ |
|
81 | + protected function doGetOutputChannel(\PEIP\INF\Message\Message $message) { |
|
82 | 82 | $replyChannel = $this->resolveReplyChannel($message); |
83 | 83 | return $replyChannel ? $replyChannel : $this->getOutputChannel(); |
84 | 84 | } |
@@ -92,9 +92,9 @@ discard block |
||
92 | 92 | * @param \PEIP\INF\Message\Message $message |
93 | 93 | * @return \PEIP\INF\Channel\Channel the reply-channel if found |
94 | 94 | */ |
95 | - protected function resolveReplyChannel(\PEIP\INF\Message\Message $message){ |
|
96 | - foreach($this->replyChannelHeaders as $header){ |
|
97 | - if($message->hasHeader($header)){ |
|
95 | + protected function resolveReplyChannel(\PEIP\INF\Message\Message $message) { |
|
96 | + foreach ($this->replyChannelHeaders as $header) { |
|
97 | + if ($message->hasHeader($header)) { |
|
98 | 98 | return $message->getHeader($header); |
99 | 99 | } |
100 | 100 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @access protected |
112 | 112 | * @param mixed $content \PEIP\INF\Message\Message or content/payload for new message |
113 | 113 | */ |
114 | - protected function replyMessage($content){ |
|
114 | + protected function replyMessage($content) { |
|
115 | 115 | $message = $this->ensureMessage($content); |
116 | 116 | $this->doGetOutputChannel($message)->send($message); |
117 | 117 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @param mixed $message \PEIP\INF\Message\Message or content/payload for new message |
126 | 126 | * @return \PEIP\INF\Message\Message |
127 | 127 | */ |
128 | - protected function ensureMessage($message){ |
|
128 | + protected function ensureMessage($message) { |
|
129 | 129 | return ($message instanceof \PEIP\INF\Message\Message) ? $message : $this->buildMessage($message); |
130 | 130 | } |
131 | 131 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @return \PEIP\INF\Message\Message |
139 | 139 | * @see MessageBuilder |
140 | 140 | */ |
141 | - protected function buildMessage($content){ |
|
141 | + protected function buildMessage($content) { |
|
142 | 142 | return $this->getMessageBuilder()->setContent($content)->build(); |
143 | 143 | } |
144 | 144 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @access protected |
150 | 150 | * @return MessageBuilder builder for the registered message class |
151 | 151 | */ |
152 | - protected function getMessageBuilder(){ |
|
152 | + protected function getMessageBuilder() { |
|
153 | 153 | return isset($this->messageBuilder) && ($this->messageBuilder->getMessageClass() == $this->getMessageClass()) |
154 | 154 | ? $this->messageBuilder |
155 | 155 | : $this->messageBuilder = MessageBuilder::getInstance($this->messageClass); |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * @param string $messageClass name of the message-class to create reply-messages from. |
163 | 163 | * @return PEIP\ABS\Handler\ReplyProducingMessageHandler $this |
164 | 164 | */ |
165 | - public function setMessageClass($messageClass){ |
|
165 | + public function setMessageClass($messageClass) { |
|
166 | 166 | $this->messageClass = $messageClass; |
167 | 167 | return $this; |
168 | 168 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @access public |
174 | 174 | * @return string name of the message-class to create reply-messages from. |
175 | 175 | */ |
176 | - public function getMessageClass(){ |
|
176 | + public function getMessageClass() { |
|
177 | 177 | return $this->messageClass; |
178 | 178 | } |
179 | 179 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | * @param string $headerName name of a message-header to look for a reply-channel |
185 | 185 | * @return void |
186 | 186 | */ |
187 | - public function addReplyChannelHeader($headerName){ |
|
187 | + public function addReplyChannelHeader($headerName) { |
|
188 | 188 | $this->replyChannelHeaders[] = $headerName; |
189 | 189 | } |
190 | 190 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @param array $headerNames array of message-header names to look for a reply-channel |
196 | 196 | * @return PEIP\ABS\Handler\ReplyProducingMessageHandler $this |
197 | 197 | */ |
198 | - public function setReplyChannelHeaders(array $headerNames){ |
|
198 | + public function setReplyChannelHeaders(array $headerNames) { |
|
199 | 199 | $this->replyChannelHeaders = $headerNames; |
200 | 200 | return $this; |
201 | 201 | } |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | * @access public |
207 | 207 | * @return array array of message-header names to look for a reply-channel |
208 | 208 | */ |
209 | - public function getReplyChannelHeaders(){ |
|
209 | + public function getReplyChannelHeaders() { |
|
210 | 210 | return $this->replyChannelHeaders; |
211 | 211 | } |
212 | 212 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @param \PEIP\INF\Message\Message $message |
221 | 221 | * @return |
222 | 222 | */ |
223 | - protected function doHandle(\PEIP\INF\Message\Message $message){ |
|
223 | + protected function doHandle(\PEIP\INF\Message\Message $message) { |
|
224 | 224 | return $this->doReply($message); |
225 | 225 | } |
226 | 226 |