| Conditions | 15 | 
| Paths | 20 | 
| Total Lines | 101 | 
| Code Lines | 66 | 
| 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 | ||
| 265 | function getPosts($jodelAccount) | ||
| 266 | 	{ | ||
| 267 | if($this->hashtag != '#all' && $this->hashtag != '' && $this->hashtag != NULL) | ||
| 268 |         { | ||
| 269 | $accountCreator = new GetChannel(); | ||
| 270 | $accountCreator->view = $this->view; | ||
| 271 | $accountCreator->setAccessToken($jodelAccount->accessToken); | ||
| 272 | $accountCreator->channel = $this->hashtag; | ||
| 273 | $accountCreator->lastPostId = $this->lastPostId; | ||
| 274 | $data = $accountCreator->execute(); | ||
| 275 | } | ||
| 276 | else | ||
| 277 |         { | ||
| 278 | if($this->lastPostId == '' && $this->view == 'combo') | ||
| 279 |             { | ||
| 280 | $url = "/v3/posts/location/combo"; | ||
| 281 | } | ||
| 282 | else | ||
| 283 |             { | ||
| 284 | if($this->view == 'discussed') | ||
| 285 |                 { | ||
| 286 | $url = "/v2/posts/location/discussed/"; | ||
| 287 | } | ||
| 288 | else | ||
| 289 |                 { | ||
| 290 | if($this->view == 'popular') | ||
| 291 |                     { | ||
| 292 | $url = "/v2/posts/location/popular/"; | ||
| 293 | } | ||
| 294 | else | ||
| 295 |                     { | ||
| 296 | $url = "/v2/posts/location/"; | ||
| 297 | } | ||
| 298 | } | ||
| 299 | } | ||
| 300 | |||
| 301 | $accountCreator = new GetPosts(); | ||
| 302 | $accountCreator->setLastPostId($this->lastPostId); | ||
| 303 | $accountCreator->setAccessToken($jodelAccount->accessToken); | ||
| 304 | $accountCreator->setUrl($url); | ||
| 305 | $accountCreator->version = 'v3'; | ||
| 306 | |||
| 307 |             $config = parse_ini_file('config/config.ini.php'); | ||
| 308 | $location = new Location(); | ||
| 309 | $location->setLat($config['default_lat']); | ||
| 310 | $location->setLng($config['default_lng']); | ||
| 311 | $location->setCityName($config['default_location']); | ||
| 312 | $accountCreator->location = $location; | ||
| 313 | $data = $accountCreator->execute(); | ||
| 314 | } | ||
| 315 |     	if(is_array($data) && array_key_exists('recent', $data) && array_key_exists(0, $data['recent'])) | ||
| 316 |         { | ||
| 317 | return $data['recent']; | ||
| 318 | } | ||
| 319 |         else if(is_array($data) && array_key_exists('posts', $data)&& array_key_exists(0, $data['posts'])) | ||
| 320 |         { | ||
| 321 | return $data['posts']; | ||
| 322 | } | ||
| 323 | else | ||
| 324 |         { | ||
| 325 | if($this->lastPostId == '') | ||
| 326 |             { | ||
| 327 |                 error_log('Could not find Posts in: ' . $this->city . ' Error: ' . print_r($data, true)); | ||
| 328 | //error_log(print_r($data, true)); | ||
| 329 | |||
| 330 | $notFound[0] = array( | ||
| 331 | "post_id" => "0", | ||
| 332 | "discovered_by" => 0, | ||
| 333 | "message" => "No more Posts found", | ||
| 334 | "created_at" => "2017-02-11T16:44:50.385Z", | ||
| 335 | "updated_at" => "2017-02-11T16:44:50.385Z", | ||
| 336 | "pin_count" => 0, | ||
| 337 | "color" => "5682a3", | ||
| 338 | "got_thanks" => FALSE, | ||
| 339 | "post_own" => "friend", | ||
| 340 | "discovered" => 0, | ||
| 341 | "distance" => 9, | ||
| 342 | "vote_count" => 0, | ||
| 343 | "location" => | ||
| 344 |                     array("name" => "Berlin", | ||
| 345 | "loc_coordinates" => | ||
| 346 | array( | ||
| 347 | "lat" => 0, | ||
| 348 | "lng" => 0 | ||
| 349 | ), | ||
| 350 | "loc_accuracy" => 0, | ||
| 351 | "country" => "", | ||
| 352 | "city" => "", | ||
| 353 | ), | ||
| 354 | "tags" => | ||
| 355 | array(), | ||
| 356 | "user_handle" => "0" | ||
| 357 | ); | ||
| 358 | return $notFound; | ||
| 359 | } | ||
| 360 | else | ||
| 361 |             { | ||
| 362 | return FALSE; | ||
| 363 | } | ||
| 364 | } | ||
| 365 | } | ||
| 366 | } | ||
| 367 | 
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.