@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * @param $name |
| 64 | 64 | * @return |
| 65 | 65 | */ |
| 66 | - public function setName($name){
|
|
| 66 | + public function setName($name) {
|
|
| 67 | 67 | $this->name = $name; |
| 68 | 68 | } |
| 69 | 69 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * @access public |
| 73 | 73 | * @return |
| 74 | 74 | */ |
| 75 | - public function getName(){
|
|
| 75 | + public function getName() {
|
|
| 76 | 76 | return $this->name; |
| 77 | 77 | } |
| 78 | 78 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @param $timeout |
| 84 | 84 | * @return |
| 85 | 85 | */ |
| 86 | - public function send(\PEIP\INF\Message\Message $message, $timeout = -1){
|
|
| 86 | + public function send(\PEIP\INF\Message\Message $message, $timeout = -1) {
|
|
| 87 | 87 | return $this->handle($message); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * @param $message |
| 94 | 94 | * @return |
| 95 | 95 | */ |
| 96 | - protected function doSend(\PEIP\INF\Message\Message $message){
|
|
| 96 | + protected function doSend(\PEIP\INF\Message\Message $message) {
|
|
| 97 | 97 | $this->doFireEvent(self::EVENT_PRE_PUBLISH, array(self::HEADER_MESSAGE=>$message)); |
| 98 | 98 | $this->getMessageDispatcher()->notify($message); |
| 99 | 99 | $this->doFireEvent(self::EVENT_POST_PUBLISH, array(self::HEADER_MESSAGE=>$message)); |
@@ -106,11 +106,11 @@ discard block |
||
| 106 | 106 | * @param $content |
| 107 | 107 | * @return |
| 108 | 108 | */ |
| 109 | - protected function replyMessage($message){
|
|
| 110 | - if(\PEIP\Util\Test::assertMessage($message)){
|
|
| 111 | - if($this->getOutputChannel()){
|
|
| 109 | + protected function replyMessage($message) {
|
|
| 110 | + if (\PEIP\Util\Test::assertMessage($message)) {
|
|
| 111 | + if ($this->getOutputChannel()) {
|
|
| 112 | 112 | $this->getOutputChannel()->send($message); |
| 113 | - }else{
|
|
| 113 | + }else {
|
|
| 114 | 114 | $this->doSend($message); |
| 115 | 115 | } |
| 116 | 116 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | * @param $message |
| 123 | 123 | * @return |
| 124 | 124 | */ |
| 125 | - protected function doReply(\PEIP\INF\Message\Message $message){
|
|
| 125 | + protected function doReply(\PEIP\INF\Message\Message $message) {
|
|
| 126 | 126 | $this->replyMessage($message); |
| 127 | 127 | } |
| 128 | 128 | |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | * @param $handler |
| 133 | 133 | * @return |
| 134 | 134 | */ |
| 135 | - public function subscribe($handler){
|
|
| 135 | + public function subscribe($handler) {
|
|
| 136 | 136 | Test::ensureHandler($handler); |
| 137 | 137 | $this->getMessageDispatcher()->connect($handler); |
| 138 | 138 | $this->doFireEvent(self::EVENT_SUBSCRIBE, array(self::HEADER_SUBSCRIBER=>$handler)); |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * @param $handler e |
| 145 | 145 | * @return |
| 146 | 146 | */ |
| 147 | - public function unsubscribe($handler){
|
|
| 147 | + public function unsubscribe($handler) {
|
|
| 148 | 148 | Test::ensureHandler($handler); |
| 149 | 149 | $this->getMessageDispatcher()->disconnect($handler); |
| 150 | 150 | $this->doFireEvent( |
@@ -162,9 +162,9 @@ discard block |
||
| 162 | 162 | * @param $transferListeners |
| 163 | 163 | * @return |
| 164 | 164 | */ |
| 165 | - public function setMessageDispatcher(\PEIP\INF\Dispatcher\Dispatcher $dispatcher, $transferListeners = true){
|
|
| 166 | - if(isset($this->dispatcher) && $transferListeners){
|
|
| 167 | - foreach($this->dispatcher->getListeners() as $listener){
|
|
| 165 | + public function setMessageDispatcher(\PEIP\INF\Dispatcher\Dispatcher $dispatcher, $transferListeners = true) {
|
|
| 166 | + if (isset($this->dispatcher) && $transferListeners) {
|
|
| 167 | + foreach ($this->dispatcher->getListeners() as $listener) {
|
|
| 168 | 168 | $dispatcher->connect($listener); |
| 169 | 169 | $this->dispatcher->disconnect($listener); |
| 170 | 170 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | * @access public |
| 179 | 179 | * @return |
| 180 | 180 | */ |
| 181 | - public function getMessageDispatcher(){
|
|
| 181 | + public function getMessageDispatcher() {
|
|
| 182 | 182 | $defaultDispatcher = self::DEFAULT_CLASS_MESSAGE_DISPATCHER; |
| 183 | 183 | return isset($this->dispatcher) ? $this->dispatcher : $this->dispatcher = new $defaultDispatcher; |
| 184 | 184 | } |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | * @param $callable |
| 191 | 191 | * @return |
| 192 | 192 | */ |
| 193 | - protected function registerCommand($commandName, $callable){
|
|
| 193 | + protected function registerCommand($commandName, $callable) {
|
|
| 194 | 194 | $this->commands[$commandName] = $callable; |
| 195 | 195 | } |
| 196 | 196 | |
@@ -200,10 +200,10 @@ discard block |
||
| 200 | 200 | * @param $cmdMessage |
| 201 | 201 | * @return |
| 202 | 202 | */ |
| 203 | - public function command(\PEIP\INF\Message\Message $cmdMessage){
|
|
| 203 | + public function command(\PEIP\INF\Message\Message $cmdMessage) {
|
|
| 204 | 204 | $this->doFireEvent(self::EVENT_PRE_COMMAND, array(self::HEADER_MESSAGE=>$cmdMessage)); |
| 205 | 205 | $commandName = trim((string)$cmdMessage->getHeader('COMMAND'));
|
| 206 | - if($commandName != '' && array_key_exists($commandName, $this->commands)){
|
|
| 206 | + if ($commandName != '' && array_key_exists($commandName, $this->commands)) {
|
|
| 207 | 207 | call_user_func($this->commands[$commandName], $cmdMessage->getContent()); |
| 208 | 208 | } |
| 209 | 209 | $this->doFireEvent(self::EVENT_POST_COMMAND, array(self::HEADER_MESSAGE=>$cmdMessage)); |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | protected |
| 30 | 30 | $eventName; |
| 31 | 31 | |
| 32 | - public function connectChannel(\PEIP\INF\Channel\Channel $inputChannel){
|
|
| 32 | + public function connectChannel(\PEIP\INF\Channel\Channel $inputChannel) {
|
|
| 33 | 33 | $this->inputChannel = $inputChannel; |
| 34 | 34 | |
| 35 | 35 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | * @param \PEIP\INF\Channel\Channel $inputChannel the input-channel to listen for events. |
| 45 | 45 | * @return |
| 46 | 46 | */ |
| 47 | - public function setInputChannel(\PEIP\INF\Channel\Channel $inputChannel){
|
|
| 47 | + public function setInputChannel(\PEIP\INF\Channel\Channel $inputChannel) {
|
|
| 48 | 48 | $this->connectChannel($inputChannel); |
| 49 | 49 | } |
| 50 | 50 | |
@@ -60,9 +60,9 @@ discard block |
||
| 60 | 60 | * @access protected |
| 61 | 61 | * @param \PEIP\INF\Message\Message $message the message to reply with |
| 62 | 62 | */ |
| 63 | - protected function doReply(\PEIP\INF\Message\Message $message){
|
|
| 63 | + protected function doReply(\PEIP\INF\Message\Message $message) {
|
|
| 64 | 64 | $headerMessage = $message->getHeader('MESSAGE');
|
| 65 | - if($headerMessage instanceof \PEIP\INF\Message\Message){
|
|
| 65 | + if ($headerMessage instanceof \PEIP\INF\Message\Message) {
|
|
| 66 | 66 | return $this->replyMessage($headerMessage); |
| 67 | 67 | } |
| 68 | 68 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * @param \PEIP\INF\Event\Connectable $connectable the connectable to listen to |
| 76 | 76 | * @return |
| 77 | 77 | */ |
| 78 | - public function listen(\PEIP\INF\Event\Connectable $connectable){
|
|
| 78 | + public function listen(\PEIP\INF\Event\Connectable $connectable) {
|
|
| 79 | 79 | return $this->doListen($this->eventName, $connectable); |
| 80 | 80 | } |
| 81 | 81 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | * @param \PEIP\INF\Event\Connectable $connectable the connectable to unlisten |
| 88 | 88 | * @return |
| 89 | 89 | */ |
| 90 | - public function unlisten(\PEIP\INF\Event\Connectable $connectable){
|
|
| 90 | + public function unlisten(\PEIP\INF\Event\Connectable $connectable) {
|
|
| 91 | 91 | return $this->doUnlisten($this->eventName, $connectable); |
| 92 | 92 | } |
| 93 | 93 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * @access public |
| 98 | 98 | * @return array array of \PEIP\INF\Event\Connectable instances |
| 99 | 99 | */ |
| 100 | - public function getConnected(){
|
|
| 100 | + public function getConnected() {
|
|
| 101 | 101 | return $this->doGetConnected(); |
| 102 | 102 | } |
| 103 | 103 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * @param \PEIP\INF\Channel\Channel $channel \PEIP\INF\Channel\Channel instance to disconnect from |
| 109 | 109 | * @return |
| 110 | 110 | */ |
| 111 | - public function disconnectChannel(\PEIP\INF\Channel\Channel $channel){
|
|
| 111 | + public function disconnectChannel(\PEIP\INF\Channel\Channel $channel) {
|
|
| 112 | 112 | $this->disconnectInputChannel(); |
| 113 | 113 | $this->inputChannel = $channel; |
| 114 | 114 | $this->connectInputChannel(); |
@@ -121,8 +121,8 @@ discard block |
||
| 121 | 121 | * @access protected |
| 122 | 122 | * @return |
| 123 | 123 | */ |
| 124 | - protected function connectInputChannel(){
|
|
| 125 | - if($this->inputChannel && $this->eventName){
|
|
| 124 | + protected function connectInputChannel() {
|
|
| 125 | + if ($this->inputChannel && $this->eventName) {
|
|
| 126 | 126 | $this->inputChannel->connect($this->eventName, $this); |
| 127 | 127 | } |
| 128 | 128 | } |
@@ -134,8 +134,8 @@ discard block |
||
| 134 | 134 | * @access protected |
| 135 | 135 | * @return |
| 136 | 136 | */ |
| 137 | - protected function disconnectInputChannel(){
|
|
| 138 | - if($this->inputChannel && $this->eventName){
|
|
| 137 | + protected function disconnectInputChannel() {
|
|
| 138 | + if ($this->inputChannel && $this->eventName) {
|
|
| 139 | 139 | $this->inputChannel->disconnect($this->eventName, $this); |
| 140 | 140 | } |
| 141 | 141 | } |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | * @param $eventName |
| 148 | 148 | * @return |
| 149 | 149 | */ |
| 150 | - public function setEventName($eventName){
|
|
| 150 | + public function setEventName($eventName) {
|
|
| 151 | 151 | $this->disconnectInputChannel(); |
| 152 | 152 | $this->eventName = $eventName; |
| 153 | 153 | $this->connectInputChannel(); |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | * @param $outputChannel |
| 34 | 34 | * @return |
| 35 | 35 | */ |
| 36 | - public function __construct($eventName, \PEIP\INF\Channel\Channel $inputChannel, \PEIP\INF\Channel\Channel $outputChannel){
|
|
| 36 | + public function __construct($eventName, \PEIP\INF\Channel\Channel $inputChannel, \PEIP\INF\Channel\Channel $outputChannel) {
|
|
| 37 | 37 | $this->setEventName($eventName); |
| 38 | 38 | $this->setInputChannel($inputChannel); |
| 39 | 39 | $this->setOutputChannel($outputChannel); |
@@ -31,10 +31,10 @@ discard block |
||
| 31 | 31 | * @param $inputChannel |
| 32 | 32 | * @return |
| 33 | 33 | */ |
| 34 | - public function setInputChannel(\PEIP\INF\Channel\Channel $inputChannel){
|
|
| 35 | - if(isset($this->eventName)){
|
|
| 34 | + public function setInputChannel(\PEIP\INF\Channel\Channel $inputChannel) {
|
|
| 35 | + if (isset($this->eventName)) {
|
|
| 36 | 36 | $this->connectChannel($inputChannel); |
| 37 | - }else{
|
|
| 37 | + }else {
|
|
| 38 | 38 | $this->inputChannel = $inputChannel; |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -45,10 +45,10 @@ discard block |
||
| 45 | 45 | * @param $eventName |
| 46 | 46 | * @return |
| 47 | 47 | */ |
| 48 | - public function setEventName($eventName){
|
|
| 49 | - if(!isset($this->eventName)){
|
|
| 48 | + public function setEventName($eventName) {
|
|
| 49 | + if (!isset($this->eventName)) {
|
|
| 50 | 50 | $this->eventName = $eventName; |
| 51 | - if($this->inputChannel){
|
|
| 51 | + if ($this->inputChannel) {
|
|
| 52 | 52 | $this->inputChannel->connect($this->eventName, $this); |
| 53 | 53 | } |
| 54 | 54 | } |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | * @param $content |
| 35 | 35 | * @return |
| 36 | 36 | */ |
| 37 | - protected function replyMessage($content){
|
|
| 37 | + protected function replyMessage($content) {
|
|
| 38 | 38 | $message = $this->ensureMessage($content); |
| 39 | 39 | $this->getOutputChannel()->command($message); |
| 40 | 40 | } |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | * @param \PEIP\INF\Channel\PollableChannel $replyChannel The default channel to receive requests from the gateway |
| 44 | 44 | * @param array $defaultHeaders The default headers to apply to request messages |
| 45 | 45 | */ |
| 46 | - public function __construct(\PEIP\INF\Channel\Channel $requestChannel, \PEIP\INF\Channel\Channel $replyChannel = NULL, array $defaultHeaders = array()){
|
|
| 46 | + public function __construct(\PEIP\INF\Channel\Channel $requestChannel, \PEIP\INF\Channel\Channel $replyChannel = NULL, array $defaultHeaders = array()) {
|
|
| 47 | 47 | $this->setRequestChannel($requestChannel); |
| 48 | - if($replyChannel){
|
|
| 48 | + if ($replyChannel) {
|
|
| 49 | 49 | $this->setReplyChannel($replyChannel); |
| 50 | 50 | } |
| 51 | 51 | $this->defaultHeaders = $defaultHeaders; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * @param \PEIP\INF\Channel\Channel $replyChannel The default channel to receive requests from the gateway |
| 60 | 60 | * @return |
| 61 | 61 | */ |
| 62 | - public function setRequestChannel(\PEIP\INF\Channel\Channel $requestChannel){
|
|
| 62 | + public function setRequestChannel(\PEIP\INF\Channel\Channel $requestChannel) {
|
|
| 63 | 63 | $this->requestChannel = $requestChannel; |
| 64 | 64 | } |
| 65 | 65 | |
@@ -70,8 +70,8 @@ discard block |
||
| 70 | 70 | * @param \PEIP\INF\Channel\PollableChannel $replyChannel The default channel to receive requests from the gateway |
| 71 | 71 | * @return |
| 72 | 72 | */ |
| 73 | - public function setReplyChannel(\PEIP\INF\Channel\Channel $replyChannel){
|
|
| 74 | - if(!($replyChannel instanceof \PEIP\INF\Channel\PollableChannel)){
|
|
| 73 | + public function setReplyChannel(\PEIP\INF\Channel\Channel $replyChannel) {
|
|
| 74 | + if (!($replyChannel instanceof \PEIP\INF\Channel\PollableChannel)) {
|
|
| 75 | 75 | throw new \InvalidArgumentException('reply channel must be instance of \PEIP\INF\Channel\PollableChannel.');
|
| 76 | 76 | } |
| 77 | 77 | $this->replyChannel = $replyChannel; |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * @param mixed $content the content/payload for the message to send |
| 85 | 85 | * @return |
| 86 | 86 | */ |
| 87 | - public function send($content){
|
|
| 87 | + public function send($content) {
|
|
| 88 | 88 | return $this->requestChannel->send($this->buildMessage($content)); |
| 89 | 89 | } |
| 90 | 90 | |
@@ -94,12 +94,12 @@ discard block |
||
| 94 | 94 | * @access public |
| 95 | 95 | * @return mixed content/payload of the received message |
| 96 | 96 | */ |
| 97 | - public function receive(){
|
|
| 98 | - if(!isset($this->replyChannel)){
|
|
| 97 | + public function receive() {
|
|
| 98 | + if (!isset($this->replyChannel)) {
|
|
| 99 | 99 | throw new \LogicException('No replyChannel set.');
|
| 100 | 100 | } |
| 101 | 101 | $message = $this->replyChannel->receive(); |
| 102 | - if($message){
|
|
| 102 | + if ($message) {
|
|
| 103 | 103 | return $message->getContent(); |
| 104 | 104 | } |
| 105 | 105 | return NULL; |
@@ -112,12 +112,12 @@ discard block |
||
| 112 | 112 | * @param mixed $content the content/payload for the message to send |
| 113 | 113 | * @return mixed content/payload of the received message |
| 114 | 114 | */ |
| 115 | - public function sendAndReceive($content){
|
|
| 115 | + public function sendAndReceive($content) {
|
|
| 116 | 116 | $this->send($content); |
| 117 | 117 | try {
|
| 118 | 118 | $res = $this->receive(); |
| 119 | 119 | } |
| 120 | - catch(\Exception $e){
|
|
| 120 | + catch (\Exception $e) {
|
|
| 121 | 121 | return NULL; |
| 122 | 122 | } |
| 123 | 123 | return $res; |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * @param mixed $content the content/payload for the message to send |
| 131 | 131 | * @return \PEIP\INF\Message\Message the built message |
| 132 | 132 | */ |
| 133 | - protected function buildMessage($content){
|
|
| 133 | + protected function buildMessage($content) {
|
|
| 134 | 134 | return $this->getMessageBuilder()->setContent($content)->build(); |
| 135 | 135 | } |
| 136 | 136 | |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | * @access protected |
| 141 | 141 | * @return MessageBuilder message builder instance for the registerd message class |
| 142 | 142 | */ |
| 143 | - protected function getMessageBuilder(){
|
|
| 143 | + protected function getMessageBuilder() {
|
|
| 144 | 144 | return isset($this->messageBuilder) && ($this->messageBuilder->getMessageClass() == $this->getMessageClass()) |
| 145 | 145 | ? $this->messageBuilder |
| 146 | 146 | : $this->messageBuilder = MessageBuilder::getInstance($this->messageClass)->setHeaders($this->defaultHeaders); |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | * @param string $messageClass message class to create instances from |
| 154 | 154 | * @return |
| 155 | 155 | */ |
| 156 | - public function setMessageClass($messageClass){
|
|
| 156 | + public function setMessageClass($messageClass) {
|
|
| 157 | 157 | $this->messageClass = $messageClass; |
| 158 | 158 | } |
| 159 | 159 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | * @access public |
| 164 | 164 | * @return string message class to create instances from |
| 165 | 165 | */ |
| 166 | - public function getMessageClass(){
|
|
| 166 | + public function getMessageClass() {
|
|
| 167 | 167 | return $this->messageClass; |
| 168 | 168 | } |
| 169 | 169 | |
@@ -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 | |
@@ -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); |