Completed
Push — master ( 6d66c7...e2b06f )
by Timo
02:45
created
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.