| Conditions | 28 | 
| Paths | 1536 | 
| Total Lines | 70 | 
| Lines | 5 | 
| Ratio | 7.14 % | 
| 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  | 
            ||
| 44 | function checkProfileStrength(){ | 
            ||
| 45 | $user_guid = elgg_get_page_owner_guid();  | 
            ||
| 46 | $userEnt = get_user ( $user_guid );  | 
            ||
| 47 | |||
| 48 | //avatar  | 
            ||
| 49 |     if($userEnt->getIconURL() !=  elgg_get_site_url() . '_graphics/icons/user/defaultmedium.gif'){ | 
            ||
| 50 | |||
| 51 | $avTotal = 100;  | 
            ||
| 52 |     }else{ | 
            ||
| 53 | |||
| 54 | $avTotal = 0;  | 
            ||
| 55 | }  | 
            ||
| 56 | |||
| 57 | //About me  | 
            ||
| 58 |     if($userEnt->description){ | 
            ||
| 59 | |||
| 60 | $aboutTotal = 100;  | 
            ||
| 61 |     }else{ | 
            ||
| 62 | |||
| 63 | $aboutTotal = 0;  | 
            ||
| 64 | }  | 
            ||
| 65 | |||
| 66 | //basic profile  | 
            ||
| 67 | $basicCount = 0;  | 
            ||
| 68 | |||
| 69 |     if( strpos(elgg_get_site_entity()->name, 'collab') !== false && ($userEnt->university || $userEnt->college || $userEnt->highschool || $userEnt->federal || $userEnt->ministry || $userEnt->municipal || $userEnt->international || $userEnt->ngo || $userEnt->community || $userEnt->business || $userEnt->media || $userEnt->retired || $userEnt->other) ){ | 
            ||
| 70 | $basicCount += 20;  | 
            ||
| 71 |     } else if($userEnt->department){ | 
            ||
| 72 | $basicCount += 20;  | 
            ||
| 73 | }  | 
            ||
| 74 |     if($userEnt->job){ | 
            ||
| 75 | $basicCount += 20;  | 
            ||
| 76 | }  | 
            ||
| 77 |     if($userEnt->location || $userEnt->addressString || $userEnt->addressStringFr){ | 
            ||
| 78 | $basicCount += 20;  | 
            ||
| 79 | }  | 
            ||
| 80 |     if($userEnt->email){ | 
            ||
| 81 | $basicCount += 20;  | 
            ||
| 82 | }  | 
            ||
| 83 |     if($userEnt->phone || $userEnt->mobile){ | 
            ||
| 84 | $basicCount += 20;  | 
            ||
| 85 | }  | 
            ||
| 86 | |||
| 87 | //education  | 
            ||
| 88 |     if(count($userEnt->education) >= 1){ | 
            ||
| 89 | $eduCount = 100;  | 
            ||
| 90 |     } else { | 
            ||
| 91 | $eduCount = 0;  | 
            ||
| 92 | }  | 
            ||
| 93 | |||
| 94 | //work experience  | 
            ||
| 95 |     if(count($userEnt->work) >= 1){ | 
            ||
| 96 | $workCount = 100;  | 
            ||
| 97 |     } else { | 
            ||
| 98 | $workCount = 0;  | 
            ||
| 99 | }  | 
            ||
| 100 | |||
| 101 | //skills  | 
            ||
| 102 | View Code Duplication |     if(count($userEnt->gc_skills) >= 3){ | 
            |
| 103 | $skillCount = 100;  | 
            ||
| 104 |     } else { | 
            ||
| 105 | $skillCount = round(count($userEnt->gc_skills)/3*100);  | 
            ||
| 106 | }  | 
            ||
| 107 | |||
| 108 | //overall total  | 
            ||
| 109 | $complete = round(($skillCount + $workCount + $eduCount + $basicCount + $aboutTotal + $avTotal)/6);  | 
            ||
| 110 | |||
| 111 | //set up profile strength metadata  | 
            ||
| 112 | $userEnt->profilestrength = $complete;  | 
            ||
| 113 | }  | 
            ||
| 114 |