| Conditions | 13 | 
| Paths | 10 | 
| Total Lines | 36 | 
| 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  | 
            ||
| 32 | public function canView($member)  | 
            ||
| 33 |     { | 
            ||
| 34 |         switch ($this->owner->CanViewType) { | 
            ||
| 35 | case 'Anyone':  | 
            ||
| 36 | return true;  | 
            ||
| 37 | |||
| 38 | case 'Inherit':  | 
            ||
| 39 |                 if ($this->owner->ParentID) { | 
            ||
| 40 | return $this->owner->Parent()->canView($member);  | 
            ||
| 41 | }  | 
            ||
| 42 | return $this->owner->getSiteConfig()->canViewPages($member);  | 
            ||
| 43 | |||
| 44 | case 'LoggedInUsers':  | 
            ||
| 45 | // check for any logged-in RealMe Sessions  | 
            ||
| 46 | $data = $this->service->getUserData();  | 
            ||
| 47 |                 if (!is_null($data)) { | 
            ||
| 48 | return true;  | 
            ||
| 49 | }  | 
            ||
| 50 | |||
| 51 |                 if ($member && is_numeric($member)) { | 
            ||
| 52 | return true;  | 
            ||
| 53 | }  | 
            ||
| 54 | |||
| 55 | return false;  | 
            ||
| 56 | |||
| 57 | case 'OnlyTheseUsers':  | 
            ||
| 58 |                 if ($member && is_numeric($member)) { | 
            ||
| 59 | $member = DataObject::get_by_id(Member::class, $member);  | 
            ||
| 60 | |||
| 61 | /** @var Member $member */  | 
            ||
| 62 |                     if ($member && $member->inGroups($this->owner->ViewerGroups())) { | 
            ||
| 63 | return true;  | 
            ||
| 64 | }  | 
            ||
| 65 | }  | 
            ||
| 66 | }  | 
            ||
| 67 | return false;  | 
            ||
| 68 | }  | 
            ||
| 70 |