@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | * @return array array with interface/class info for the class |
31 | 31 | */ |
32 | 32 | |
33 | - public static function getImplementedClassesAndInterfaces($class, $store = true){ |
|
33 | + public static function getImplementedClassesAndInterfaces($class, $store = true) { |
|
34 | 34 | $class = is_object($class) ? get_class($class) : (string)$class; |
35 | - if(isset(self::$classInfo[$class])){ |
|
35 | + if (isset(self::$classInfo[$class])) { |
|
36 | 36 | return self::$classInfo[$class]; |
37 | 37 | } |
38 | 38 | $cls = ReflectionPool::getInstance($class); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $classInfo = (array)$cls->getInterfaceNames(); |
41 | 41 | $classInfo[] = $cls->getName(); |
42 | 42 | // get names of parent-classes |
43 | - while($cls = $cls->getParentClass()){ |
|
43 | + while ($cls = $cls->getParentClass()) { |
|
44 | 44 | $classInfo[] = $cls->getName(); |
45 | 45 | } |
46 | 46 |
@@ -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 | 41 | $res = false; |
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 |
@@ -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;; |
@@ -22,11 +22,11 @@ |
||
22 | 22 | * @param $argument |
23 | 23 | * @return ReflectionClass |
24 | 24 | */ |
25 | - public static function getInstance($argument){ |
|
25 | + public static function getInstance($argument) { |
|
26 | 26 | |
27 | 27 | $className = is_object($argument) |
28 | 28 | ? get_class($argument) |
29 | - : (string) $argument; |
|
29 | + : (string)$argument; |
|
30 | 30 | return isset(self::$instances[$className]) |
31 | 31 | ? self::$instances[$className] |
32 | 32 | : self::$instances[$className] = new \ReflectionClass($className); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param $observedObject |
37 | 37 | * @return |
38 | 38 | */ |
39 | - public function __construct(object $observedObject){ |
|
39 | + public function __construct(object $observedObject) { |
|
40 | 40 | $this->observedObject = $observedObject; |
41 | 41 | } |
42 | 42 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param $observer |
47 | 47 | * @return |
48 | 48 | */ |
49 | - public function addObserver(\PEIP\INF\Event\Observer $observer){ |
|
49 | + public function addObserver(\PEIP\INF\Event\Observer $observer) { |
|
50 | 50 | $this->observers[] = $observer; |
51 | 51 | } |
52 | 52 | |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | * @param $observer |
57 | 57 | * @return |
58 | 58 | */ |
59 | - public function deleteObserver(\PEIP\INF\Event\Observer $observer){ |
|
60 | - foreach($this->observers as $key=>$obs){ |
|
61 | - if($obs == $observer){ |
|
59 | + public function deleteObserver(\PEIP\INF\Event\Observer $observer) { |
|
60 | + foreach ($this->observers as $key=>$obs) { |
|
61 | + if ($obs == $observer) { |
|
62 | 62 | unset($this->observers[$key]); |
63 | 63 | return true; |
64 | 64 | } |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | * @param $arguments |
72 | 72 | * @return |
73 | 73 | */ |
74 | - public function notifyObservers(array $arguments = array()){ |
|
75 | - if($this->hasChanged()){ |
|
76 | - foreach($this->observers as $observer){ |
|
74 | + public function notifyObservers(array $arguments = array()) { |
|
75 | + if ($this->hasChanged()) { |
|
76 | + foreach ($this->observers as $observer) { |
|
77 | 77 | $observer->update($this->observedObject); |
78 | 78 | } |
79 | 79 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @access public |
85 | 85 | * @return |
86 | 86 | */ |
87 | - public function countObservers(){ |
|
87 | + public function countObservers() { |
|
88 | 88 | return count($this->obeservers); |
89 | 89 | } |
90 | 90 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @access public |
94 | 94 | * @return |
95 | 95 | */ |
96 | - public function hasChanged(){ |
|
96 | + public function hasChanged() { |
|
97 | 97 | return $this->hasChanged(); |
98 | 98 | } |
99 | 99 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @access public |
103 | 103 | * @return |
104 | 104 | */ |
105 | - public function setChanged(){ |
|
105 | + public function setChanged() { |
|
106 | 106 | $this->hasChanged = true; |
107 | 107 | } |
108 | 108 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @access public |
112 | 112 | * @return |
113 | 113 | */ |
114 | - public function clearChanged(){ |
|
114 | + public function clearChanged() { |
|
115 | 115 | $this->hasChanged = true; |
116 | 116 | } |
117 | 117 |
@@ -60,9 +60,9 @@ |
||
60 | 60 | */ |
61 | 61 | protected static function doNotifyUntil(array $listeners, $subject){ |
62 | 62 | foreach ($listeners as $listener){ |
63 | - if (self::doNotifyOne($listener, $subject)){ |
|
63 | + if (self::doNotifyOne($listener, $subject)){ |
|
64 | 64 | return $listener; |
65 | - } |
|
65 | + } |
|
66 | 66 | } |
67 | 67 | return NULL; |
68 | 68 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 |