| Conditions | 28 |
| Paths | 26 |
| Total Lines | 97 |
| Code Lines | 60 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 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 |
||
| 34 | public function __get($propName) |
||
| 35 | { |
||
| 36 | switch($propName) |
||
| 37 | { |
||
| 38 | case 'modTime': |
||
| 39 | if($this->mod === null) |
||
| 40 | { |
||
| 41 | $this->mod = new \DateInterval('PT'.strval($this->role->down_time).'H'); |
||
|
|
|||
| 42 | } |
||
| 43 | return $this->mod; |
||
| 44 | case 'startTime': |
||
| 45 | if($this->myStart === null) |
||
| 46 | { |
||
| 47 | $this->myStart = new \DateTime($this->dbData['startTime']); |
||
| 48 | } |
||
| 49 | return $this->myStart; |
||
| 50 | case 'startTimeWithMod': |
||
| 51 | if($this->modStart === null) |
||
| 52 | { |
||
| 53 | $this->modStart = clone $this->startTime; |
||
| 54 | $this->modStart->sub($this->modTime); |
||
| 55 | } |
||
| 56 | return $this->modStart; |
||
| 57 | case 'endTime': |
||
| 58 | if($this->myEnd === null) |
||
| 59 | { |
||
| 60 | $this->myEnd = new \DateTime($this->dbData['endTime']); |
||
| 61 | } |
||
| 62 | return $this->myEnd; |
||
| 63 | case 'endTimeWithMod': |
||
| 64 | if($this->modEnd === null) |
||
| 65 | { |
||
| 66 | $this->modEnd = clone $this->endTime; |
||
| 67 | $this->modEnd->add($this->modTime); |
||
| 68 | } |
||
| 69 | return $this->modEnd; |
||
| 70 | case 'department': |
||
| 71 | if(!isset(self::$deptCache[$this->dbData['departmentID']])) |
||
| 72 | { |
||
| 73 | self::$deptCache[$this->dbData['departmentID']] = new \VolunteerDepartment($this->dbData['departmentID']); |
||
| 74 | } |
||
| 75 | return self::$deptCache[$this->dbData['departmentID']]; |
||
| 76 | case 'role': |
||
| 77 | if(!isset(self::$roleCache[$this->dbData['roleID']])) |
||
| 78 | { |
||
| 79 | self::$roleCache[$this->dbData['roleID']] = new \VolunteerRole($this->dbData['roleID']); |
||
| 80 | } |
||
| 81 | return self::$roleCache[$this->dbData['roleID']]; |
||
| 82 | case 'event': |
||
| 83 | if(!isset(self::$eventCache[$this->dbData['eventID']])) |
||
| 84 | { |
||
| 85 | self::$eventCache[$this->dbData['eventID']] = new \VolunteerEvent($this->dbData['eventID']); |
||
| 86 | } |
||
| 87 | return self::$eventCache[$this->dbData['eventID']]; |
||
| 88 | case 'participantObj': |
||
| 89 | if($this->participantObj === null) |
||
| 90 | { |
||
| 91 | if(isset($this->dbData['participant']) && $this->dbData['participant'] !== '' && $this->dbData['participant'] !== '/dev/null') |
||
| 92 | { |
||
| 93 | $this->participantObj = new \VolunteerProfile($this->dbData['participant']); |
||
| 94 | } |
||
| 95 | else |
||
| 96 | { |
||
| 97 | $this->participantObj = false; |
||
| 98 | } |
||
| 99 | } |
||
| 100 | return $this->participantObj; |
||
| 101 | case 'webParticipantName': |
||
| 102 | if($this->webParticipantName === null) |
||
| 103 | { |
||
| 104 | if(isset($this->dbData['participant'])) |
||
| 105 | { |
||
| 106 | $tmp = new \VolunteerProfile($this->dbData['participant']); |
||
| 107 | $this->webParticipantName = $tmp->getDisplayName(); |
||
| 108 | } |
||
| 109 | else |
||
| 110 | { |
||
| 111 | $this->webParticipantName = ""; |
||
| 112 | } |
||
| 113 | } |
||
| 114 | return $this->webParticipantName; |
||
| 115 | case 'scheduleParticipantName': |
||
| 116 | if($this->scheduleParticipantName === null) |
||
| 117 | { |
||
| 118 | if(isset($this->dbData['participant'])) |
||
| 119 | { |
||
| 120 | $tmp = new \VolunteerProfile($this->dbData['participant']); |
||
| 121 | $this->scheduleParticipantName = $tmp->getDisplayName('paperName'); |
||
| 122 | } |
||
| 123 | else |
||
| 124 | { |
||
| 125 | $this->scheduleParticipantName = ""; |
||
| 126 | } |
||
| 127 | } |
||
| 128 | return $this->scheduleParticipantName; |
||
| 129 | default: |
||
| 130 | return $this->dbData[$propName]; |
||
| 131 | } |
||
| 203 |