| Conditions | 2 |
| Paths | 2 |
| Total Lines | 164 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 45 | public function can_send_larg_payload() |
||
| 46 | { |
||
| 47 | $recvMsg = '{ |
||
| 48 | "squadName": "Super hero squad", |
||
| 49 | "homeTown": "Metro City", |
||
| 50 | "formed": 2016, |
||
| 51 | "secretBase": "Super tower", |
||
| 52 | "active": true, |
||
| 53 | "members": [ |
||
| 54 | { |
||
| 55 | "name": "Molecule Man", |
||
| 56 | "age": 29, |
||
| 57 | "secretIdentity": "Dan Jukes", |
||
| 58 | "powers": [ |
||
| 59 | "Radiation resistance", |
||
| 60 | "Turning tiny", |
||
| 61 | "Radiation blast" |
||
| 62 | ] |
||
| 63 | }, |
||
| 64 | { |
||
| 65 | "name": "Madame Uppercut", |
||
| 66 | "age": 39, |
||
| 67 | "secretIdentity": "Jane Wilson", |
||
| 68 | "powers": [ |
||
| 69 | "Million tonne punch", |
||
| 70 | "Damage resistance", |
||
| 71 | "Superhuman reflexes" |
||
| 72 | ] |
||
| 73 | }, |
||
| 74 | { |
||
| 75 | "name": "Eternal Flame", |
||
| 76 | "age": 1000000, |
||
| 77 | "secretIdentity": "Unknown", |
||
| 78 | "powers": [ |
||
| 79 | "Immortality", |
||
| 80 | "Heat Immunity", |
||
| 81 | "Inferno", |
||
| 82 | "Teleportation", |
||
| 83 | "Interdimensional travel" |
||
| 84 | ] |
||
| 85 | }, |
||
| 86 | { |
||
| 87 | "name": "Madame Uppercut", |
||
| 88 | "age": 39, |
||
| 89 | "secretIdentity": "Jane Wilson", |
||
| 90 | "powers": [ |
||
| 91 | "Million tonne punch", |
||
| 92 | "Damage resistance", |
||
| 93 | "Superhuman reflexes" |
||
| 94 | ] |
||
| 95 | }, |
||
| 96 | { |
||
| 97 | "name": "Eternal Flame", |
||
| 98 | "age": 1000000, |
||
| 99 | "secretIdentity": "Unknown", |
||
| 100 | "powers": [ |
||
| 101 | "Immortality", |
||
| 102 | "Heat Immunity", |
||
| 103 | "Inferno", |
||
| 104 | "Teleportation", |
||
| 105 | "Interdimensional travel" |
||
| 106 | ] |
||
| 107 | }, |
||
| 108 | { |
||
| 109 | "name": "Madame Uppercut", |
||
| 110 | "age": 39, |
||
| 111 | "secretIdentity": "Jane Wilson", |
||
| 112 | "powers": [ |
||
| 113 | "Million tonne punch", |
||
| 114 | "Damage resistance", |
||
| 115 | "Superhuman reflexes" |
||
| 116 | ] |
||
| 117 | }, |
||
| 118 | { |
||
| 119 | "name": "Eternal Flame", |
||
| 120 | "age": 1000000, |
||
| 121 | "secretIdentity": "Unknown", |
||
| 122 | "powers": [ |
||
| 123 | "Immortality", |
||
| 124 | "Heat Immunity", |
||
| 125 | "Inferno", |
||
| 126 | "Teleportation", |
||
| 127 | "Interdimensional travel" |
||
| 128 | ] |
||
| 129 | }, |
||
| 130 | { |
||
| 131 | "name": "Madame Uppercut", |
||
| 132 | "age": 39, |
||
| 133 | "secretIdentity": "Jane Wilson", |
||
| 134 | "powers": [ |
||
| 135 | "Million tonne punch", |
||
| 136 | "Damage resistance", |
||
| 137 | "Superhuman reflexes" |
||
| 138 | ] |
||
| 139 | }, |
||
| 140 | { |
||
| 141 | "name": "Eternal Flame", |
||
| 142 | "age": 1000000, |
||
| 143 | "secretIdentity": "Unknown", |
||
| 144 | "powers": [ |
||
| 145 | "Immortality", |
||
| 146 | "Heat Immunity", |
||
| 147 | "Inferno", |
||
| 148 | "Teleportation", |
||
| 149 | "Interdimensional travel" |
||
| 150 | ] |
||
| 151 | }, |
||
| 152 | { |
||
| 153 | "name": "Madame Uppercut", |
||
| 154 | "age": 39, |
||
| 155 | "secretIdentity": "Jane Wilson", |
||
| 156 | "powers": [ |
||
| 157 | "Million tonne punch", |
||
| 158 | "Damage resistance", |
||
| 159 | "Superhuman reflexes" |
||
| 160 | ] |
||
| 161 | }, |
||
| 162 | { |
||
| 163 | "name": "Eternal Flame", |
||
| 164 | "age": 1000000, |
||
| 165 | "secretIdentity": "Unknown", |
||
| 166 | "powers": [ |
||
| 167 | "Immortality", |
||
| 168 | "Heat Immunity", |
||
| 169 | "Inferno", |
||
| 170 | "Teleportation", |
||
| 171 | "Interdimensional travel" |
||
| 172 | ] |
||
| 173 | }, |
||
| 174 | { |
||
| 175 | "name": "Madame Uppercut", |
||
| 176 | "age": 39, |
||
| 177 | "secretIdentity": "Jane Wilson", |
||
| 178 | "powers": [ |
||
| 179 | "Million tonne punch", |
||
| 180 | "Damage resistance", |
||
| 181 | "Superhuman reflexes" |
||
| 182 | ] |
||
| 183 | }, |
||
| 184 | { |
||
| 185 | "name": "Eternal Flame", |
||
| 186 | "age": 1000000, |
||
| 187 | "secretIdentity": "Unknown", |
||
| 188 | "powers": [ |
||
| 189 | "Immortality", |
||
| 190 | "Heat Immunity", |
||
| 191 | "Inferno", |
||
| 192 | "Teleportation", |
||
| 193 | "Interdimensional travel" |
||
| 194 | ] |
||
| 195 | } |
||
| 196 | ] |
||
| 197 | }'; |
||
| 198 | |||
| 199 | $client = new WebSocketClient($this->url, new ClientConfig()); |
||
| 200 | try { |
||
| 201 | $client->send($recvMsg); |
||
| 202 | } catch (BadOpcodeException $e) { |
||
| 203 | echo 'Couldn`t sent: ' . $e->getMessage(); |
||
| 204 | } |
||
| 205 | |||
| 206 | $recv = $client->receive(); |
||
| 207 | $this->assertEquals($recv, $recvMsg); |
||
| 208 | } |
||
| 209 | |||
| 249 |