| Conditions | 12 |
| Paths | 96 |
| Total Lines | 105 |
| Code Lines | 72 |
| Lines | 75 |
| Ratio | 71.43 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 41 | public function handle() |
||
| 42 | { |
||
| 43 | |||
| 44 | $infos = \Thujohn\Twitter\Facades\Twitter::getUsersLookup(['screen_name' => 'Symfomany','format' => 'php']); |
||
| 45 | |||
| 46 | View Code Duplication | if(!empty($infos)){ |
|
| 47 | DB::connection('mongodb')->collection('stats') |
||
| 48 | ->where(['origin' => 'Twitter', 'type' => 'infos'])->delete(); |
||
| 49 | |||
| 50 | $stat = new Stats(); |
||
| 51 | $stat->origin = "Twitter"; |
||
| 52 | $stat->type = "infos"; |
||
| 53 | $stat->data = $infos; |
||
| 54 | $stat->save(); |
||
| 55 | } |
||
| 56 | |||
| 57 | |||
| 58 | $tweets = \Thujohn\Twitter\Facades\Twitter::getDmsOut(['format' => 'php']); |
||
| 59 | View Code Duplication | if(!empty($tweets)){ |
|
| 60 | |||
| 61 | DB::connection('mongodb')->collection('tweets') |
||
| 62 | ->where(['origin' => 'Twitter', 'type' => 'dmsout']) |
||
| 63 | ->delete(); |
||
| 64 | foreach($tweets as $tweet){ |
||
| 65 | $vi = new Tweets(); |
||
| 66 | $vi->origin = "Twitter"; |
||
| 67 | $vi->type = "dmsout"; |
||
| 68 | $vi->data = $tweet; |
||
| 69 | $vi->save(); |
||
| 70 | } |
||
| 71 | } |
||
| 72 | |||
| 73 | $tweets = \Thujohn\Twitter\Facades\Twitter::getFavorites(['format' => 'php']); |
||
| 74 | View Code Duplication | if(!empty($tweets)){ |
|
| 75 | |||
| 76 | DB::connection('mongodb')->collection('tweets') |
||
| 77 | ->where(['origin' => 'Twitter', 'type' => 'favorites']) |
||
| 78 | ->delete(); |
||
| 79 | foreach($tweets as $tweet){ |
||
| 80 | $vi = new Tweets(); |
||
| 81 | $vi->origin = "Twitter"; |
||
| 82 | $vi->type = "favorites"; |
||
| 83 | $vi->data = $tweet; |
||
| 84 | $vi->save(); |
||
| 85 | } |
||
| 86 | } |
||
| 87 | |||
| 88 | $tweets = \Thujohn\Twitter\Facades\Twitter::getMentionsTimeline( |
||
| 89 | [ |
||
| 90 | 'count' => 15, |
||
| 91 | 'format' => 'php']); |
||
| 92 | |||
| 93 | View Code Duplication | if(!empty($tweets)){ |
|
| 94 | |||
| 95 | DB::connection('mongodb')->collection('tweets') |
||
| 96 | ->where(['origin' => 'Twitter', 'type' => 'mentionstimeline']) |
||
| 97 | ->delete(); |
||
| 98 | foreach($tweets as $tweet){ |
||
| 99 | $vi = new Tweets(); |
||
| 100 | $vi->origin = "Twitter"; |
||
| 101 | $vi->type = "mentionstimeline"; |
||
| 102 | $vi->data = $tweet; |
||
| 103 | $vi->save(); |
||
| 104 | } |
||
| 105 | } |
||
| 106 | |||
| 107 | $tweets = \Thujohn\Twitter\Facades\Twitter::getHomeTimeline( |
||
| 108 | [ |
||
| 109 | 'count' => 15, |
||
| 110 | 'format' => 'php']); |
||
| 111 | |||
| 112 | View Code Duplication | if(!empty($tweets)){ |
|
| 113 | |||
| 114 | DB::connection('mongodb')->collection('tweets') |
||
| 115 | ->where(['origin' => 'Twitter', 'type' => 'hometimeline']) |
||
| 116 | ->delete(); |
||
| 117 | foreach($tweets as $tweet){ |
||
| 118 | $vi = new Tweets(); |
||
| 119 | $vi->data = $tweet; |
||
| 120 | $vi->origin = "Twitter"; |
||
| 121 | $vi->type = "hometimeline"; |
||
| 122 | $vi->save(); |
||
| 123 | } |
||
| 124 | } |
||
| 125 | |||
| 126 | $tweets = \Thujohn\Twitter\Facades\Twitter::getUserTimeline( |
||
| 127 | [ |
||
| 128 | 'screen_name' => 'allocine', |
||
| 129 | 'count' => 15, |
||
| 130 | 'format' => 'php']); |
||
| 131 | |||
| 132 | View Code Duplication | if(!empty($tweets)){ |
|
| 133 | |||
| 134 | DB::connection('mongodb')->collection('tweets') |
||
| 135 | ->where(['origin' => 'Twitter', 'type' => 'usertimeline']) |
||
| 136 | ->delete(); |
||
| 137 | foreach($tweets as $tweet){ |
||
| 138 | $vi = new Tweets(); |
||
| 139 | $vi->data = $tweet; |
||
| 140 | $vi->origin = "Twitter"; |
||
| 141 | $vi->type = "usertimeline"; |
||
| 142 | $vi->save(); |
||
| 143 | } |
||
| 144 | } |
||
| 145 | } |
||
| 146 | } |
||
| 147 |
Adding a
@returnannotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.