Completed
Push — master ( f06500...b00bf4 )
by Timo
03:52
created
src/Tidal/WampWatch/SessionMonitor.php 4 patches
Doc Comments   +11 added lines patch added patch discarded remove patch
@@ -100,8 +100,15 @@  discard block
 block discarded – undo
100 100
     }
101 101
     
102 102
     
103
+    /**
104
+     * @param callable $callback
105
+     */
103 106
     protected function retrieveSessionIds($callback = null) {
104 107
         $this->session->call(self::SESSION_LIST_TOPIC, [])->then(
108
+
109
+            /**
110
+             * @param callable $res
111
+             */
105 112
             function ($res)use($callback){
106 113
                 $this->sessionIds = $res[0];
107 114
                 $this->emit('list', [$this->sessionIds]);
@@ -109,6 +116,10 @@  discard block
 block discarded – undo
109 116
                     $callback($this->sessionIds);
110 117
                 }
111 118
             },
119
+
120
+            /**
121
+             * @param callable $error
122
+             */
112 123
             function ($error) {
113 124
                 $this->emit('error', [$error]);
114 125
             }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@
 block discarded – undo
66 66
     public function getSessionIds(callable $callback) {
67 67
         if(!count($this->sessionIds)){
68 68
             $this->retrieveSessionIds($callback);
69
-        }else{
69
+        } else{
70 70
             $callback($this->sessionIds);
71 71
         }
72 72
     }
Please login to merge, or discard this patch.
Unused Use Statements   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
  * For the full copyright and license information, please view the LICENSE file
8 8
  * that was distributed with this source code.
9 9
  */
10
-use Phaim\Server\Wamp\Util;
10
+use Phaim\Server\Wamp\Util;
11 11
 use Evenement\EventEmitterInterface;
12 12
 
13 13
 /**
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
     
38 38
     public function start() {
39
-        $this->once('list', function(){
39
+        $this->once('list', function() {
40 40
             $this->doStart();
41 41
         });     
42 42
         $this->startSubscriptions();
@@ -51,39 +51,39 @@  discard block
 block discarded – undo
51 51
     
52 52
     public function getSessionInfo($sessionId, callable $callback) {
53 53
         return $this->session->call(self::SESSION_INFO_TOPIC, [$sessionId])->then(
54
-            function ($res)use($callback){
54
+            function($res)use($callback){
55 55
                 $this->emit('info', [$res[0]]);
56 56
                 $callback($res[0]);
57 57
             },
58
-            function ($error) {
58
+            function($error) {
59 59
                 $this->emit('error', [$error]);
60 60
             }
61 61
         );    
62 62
     }
63 63
     
64 64
     public function getSessionIds(callable $callback) {
65
-        if(!count($this->sessionIds)){
65
+        if (!count($this->sessionIds)) {
66 66
             $this->retrieveSessionIds($callback);
67
-        }else{
67
+        }else {
68 68
             $callback($this->sessionIds);
69 69
         }
70 70
     }
71 71
     
72 72
     protected function startSubscriptions() { 
73
-        $this->session->subscribe(self::SESSION_JOIN_TOPIC, function($res){
73
+        $this->session->subscribe(self::SESSION_JOIN_TOPIC, function($res) {
74 74
             $sessionInfo = $res[0];
75 75
             $sessionId = $sessionInfo['session'];
76
-            if((array_search($sessionId, $this->sessionIds)) === false) {
76
+            if ((array_search($sessionId, $this->sessionIds)) === false) {
77 77
                 $this->sessionIds[] = $sessionId;
78 78
                 $this->emit('join', [$sessionInfo]);
79 79
             }
80 80
         });
81
-        $this->session->subscribe(self::SESSION_LEAVE_TOPIC, function($res){
81
+        $this->session->subscribe(self::SESSION_LEAVE_TOPIC, function($res) {
82 82
             // @bug : wamp.session.on_leave is bugged as of crossbar.io 0.11.0
83 83
             // will provide sessionID when Browser closes/reloads,
84 84
             // but not when calling connection.close();
85 85
             $sessionId = $res[0];
86
-            if(($key = array_search($sessionId, $this->sessionIds)) !== false) {
86
+            if (($key = array_search($sessionId, $this->sessionIds)) !== false) {
87 87
                 unset($this->sessionIds[$key]);
88 88
                 $this->emit('leave', [$sessionId]);
89 89
             }
@@ -98,14 +98,14 @@  discard block
 block discarded – undo
98 98
     
99 99
     protected function retrieveSessionIds($callback = null) {
100 100
         $this->session->call(self::SESSION_LIST_TOPIC, [])->then(
101
-            function ($res)use($callback){
101
+            function($res)use($callback){
102 102
                 $this->sessionIds = $res[0];
103 103
                 $this->emit('list', [$this->sessionIds]);
104
-                if($callback){
104
+                if ($callback) {
105 105
                     $callback($this->sessionIds);
106 106
                 }
107 107
             },
108
-            function ($error) {
108
+            function($error) {
109 109
                 $this->emit('error', [$error]);
110 110
             }
111 111
         );  
Please login to merge, or discard this patch.
src/Tidal/WampWatch/MonitorTrait.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
      * @return boolean
63 63
      */ 
64 64
     public function stop() {
65
-        if(!$this->isRunning()){
65
+        if (!$this->isRunning()) {
66 66
             return false;
67 67
         }
68 68
         $this->isRunning = false;
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
         return true;
72 72
     }
73 73
     
74
-    protected function getList(){
74
+    protected function getList() {
75 75
         return [];
76 76
     }
77 77
  
Please login to merge, or discard this patch.
src/Tidal/WampWatch/SubscriptionMonitor.php 3 patches
Doc Comments   +11 added lines patch added patch discarded remove patch
@@ -100,8 +100,15 @@  discard block
 block discarded – undo
100 100
     }
101 101
     
102 102
     
103
+    /**
104
+     * @param callable $callback
105
+     */
103 106
     protected function retrieveSessionIds($callback = null) {
104 107
         $this->session->call(self::SESSION_LIST_TOPIC, [])->then(
108
+
109
+            /**
110
+             * @param callable $res
111
+             */
105 112
             function ($res)use($callback){
106 113
                 $this->sessionIds = $res[0];
107 114
                 $this->emit('list', [$this->sessionIds]);
@@ -109,6 +116,10 @@  discard block
 block discarded – undo
109 116
                     $callback($this->sessionIds);
110 117
                 }
111 118
             },
119
+
120
+            /**
121
+             * @param callable $error
122
+             */
112 123
             function ($error) {
113 124
                 $this->emit('error', [$error]);
114 125
             }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     protected $subscriptionIds = [];
42 42
     
43 43
     public function start() {
44
-        $this->once('list', function(){
44
+        $this->once('list', function() {
45 45
             $this->startSubscriptions();
46 46
             $this->doStart();
47 47
         });
@@ -55,32 +55,32 @@  discard block
 block discarded – undo
55 55
     
56 56
     public function getSessionInfo($sessionId, callable $callback) {
57 57
         return $this->session->call(self::SUBSCRIPTION_INFO_TOPIC, $sessionId)->then(
58
-            function ($res)use($callback){
58
+            function($res)use($callback){
59 59
                 $this->emit('info', $res);
60 60
                 $callback($res[0]);
61 61
             },
62
-            function ($error) {
62
+            function($error) {
63 63
                 $this->emit('error', [$error]);
64 64
             }
65 65
         );    
66 66
     }
67 67
     
68 68
     public function getSessionIds(callable $callback) {
69
-        if(!count($this->subscriptionIds)){
69
+        if (!count($this->subscriptionIds)) {
70 70
             $this->retrieveSubscriptionIds($callback);
71
-        }else{
71
+        }else {
72 72
             $callback($this->subscriptionIds);
73 73
         }
74 74
     }
75 75
     
76 76
     protected function startSubscriptions() {
77
-        $this->session->subscribe(self::SUBSCRIPTION_CREATE_TOPIC, function($res){
77
+        $this->session->subscribe(self::SUBSCRIPTION_CREATE_TOPIC, function($res) {
78 78
             return $this->createHandler($res);
79 79
         });
80
-        $this->session->subscribe(self::SUBSCRIPTION_DELETE_TOPIC, function($res){
80
+        $this->session->subscribe(self::SUBSCRIPTION_DELETE_TOPIC, function($res) {
81 81
             return $this->deleteHandler($res);
82 82
         });
83
-        $this->session->subscribe(self::SUBSCRIPTION_SUB_TOPIC, function($res){
83
+        $this->session->subscribe(self::SUBSCRIPTION_SUB_TOPIC, function($res) {
84 84
             return $this->subHandler($res);
85 85
         });
86 86
     }
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     protected function createHandler($res) {
89 89
         $sessionInfo = $res[0];
90 90
         $sessionId = $sessionInfo['session'];
91
-        if(($key = array_search($sessionId, $this->subscriptionIds)) === false) {
91
+        if (($key = array_search($sessionId, $this->subscriptionIds)) === false) {
92 92
             $this->subscriptionIds[] = $sessionId;
93 93
             $this->emit('create', [$sessionInfo]);
94 94
         }
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
     
97 97
     protected function deleteHandler($res) {
98 98
         $sessionId = $res[0];
99
-        if(($key = array_search($sessionId, $this->subscriptionIds)) !== false) {
99
+        if (($key = array_search($sessionId, $this->subscriptionIds)) !== false) {
100 100
             unset($this->subscriptionIds[$key]);
101 101
             $this->emit('delete', [$sessionId]);
102 102
         }
@@ -106,10 +106,10 @@  discard block
 block discarded – undo
106 106
         $sessionId = $res[0];
107 107
         $subId = $res[1];
108 108
         $this->getSubscriptionDetail($subId)->then(
109
-            function ($res)use($sessionId, $subId){    
109
+            function($res)use($sessionId, $subId){    
110 110
                 $this->emit('sub', [$sessionId, $subId, $res[0]]);            
111 111
             },
112
-            function ($error) {                
112
+            function($error) {                
113 113
                 $this->emit('sub', [$sessionId, $subId, [
114 114
                     'id'        => $subId,
115 115
                     'created'   => null,
@@ -128,10 +128,10 @@  discard block
 block discarded – undo
128 128
     
129 129
     public function getSubscriptionDetail($subId) {
130 130
         return $this->session->call(self::SUBSCRIPTION_GET_TOPIC, [$subId])->then(
131
-            function ($res){
131
+            function($res) {
132 132
                     
133 133
             },
134
-            function ($error) {
134
+            function($error) {
135 135
               
136 136
             }
137 137
         );
@@ -139,14 +139,14 @@  discard block
 block discarded – undo
139 139
     
140 140
     protected function retrieveSubscriptionIds($callback = null) {
141 141
         return $this->session->call(self::SUBSCRIPTION_LIST_TOPIC, [])->then(
142
-            function ($res)use($callback){
142
+            function($res)use($callback){
143 143
                 $this->subscriptionIds = $res[0];
144 144
                 $this->emit('list', [$this->subscriptionIds]);
145
-                if($callback){
145
+                if ($callback) {
146 146
                     $callback($this->subscriptionIds);
147 147
                 }
148 148
             },
149
-            function ($error) {
149
+            function($error) {
150 150
                 $this->emit('error', [$error]);
151 151
             }
152 152
         );  
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@
 block discarded – undo
66 66
     public function getSessionIds(callable $callback) {
67 67
         if(!count($this->sessionIds)){
68 68
             $this->retrieveSessionIds($callback);
69
-        }else{
69
+        } else{
70 70
             $callback($this->sessionIds);
71 71
         }
72 72
     }
Please login to merge, or discard this patch.