Complex classes like Meeting often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Meeting, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 35 | class Meeting extends Model |
||
| 36 | { |
||
| 37 | protected $table = 'meetings'; |
||
| 38 | protected $dates = ["date"]; |
||
| 39 | |||
| 40 | public function __construct(array $attributes = []) |
||
| 46 | |||
| 47 | /** |
||
| 48 | * List of members who attended the meeting |
||
| 49 | * |
||
| 50 | * @var Member[] $attendants |
||
| 51 | */ |
||
| 52 | protected $attendants = []; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @var Attachment[] $attachments |
||
| 56 | */ |
||
| 57 | protected $attachments = []; |
||
| 58 | |||
| 59 | public function getId() |
||
| 63 | |||
| 64 | public function getTitle() |
||
| 68 | |||
| 69 | public function setTitle($title) |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @return \DateTime |
||
| 76 | */ |
||
| 77 | public function getDate() |
||
| 81 | |||
| 82 | public function setDate(\DateTime $date) |
||
| 86 | |||
| 87 | public function getTime() |
||
| 91 | |||
| 92 | public function hasPassed() |
||
| 96 | |||
| 97 | public function getLocation() |
||
| 101 | |||
| 102 | public function setLocation($location) |
||
| 106 | |||
| 107 | public function getInfo() |
||
| 111 | |||
| 112 | public function setInfo($info) |
||
| 116 | |||
| 117 | /** |
||
| 118 | * @return \DateTime |
||
| 119 | */ |
||
| 120 | public function getCreatedAt() |
||
| 124 | |||
| 125 | /** |
||
| 126 | * @return \DateTime |
||
| 127 | */ |
||
| 128 | public function getUpdatedAt() |
||
| 132 | |||
| 133 | /** |
||
| 134 | * @return Member[] |
||
| 135 | */ |
||
| 136 | public function getAttendants() |
||
| 140 | |||
| 141 | /** |
||
| 142 | * @param Member[] $attendants |
||
| 143 | */ |
||
| 144 | public function addAttendants(array $attendants) |
||
| 148 | |||
| 149 | /** |
||
| 150 | * @param Member[] $attendants |
||
| 151 | */ |
||
| 152 | public function syncAttendants(array $attendants) |
||
| 164 | |||
| 165 | public function hasAttendants() |
||
| 169 | |||
| 170 | public function wasAttendedBy(Member $member) |
||
| 180 | |||
| 181 | public function setCreator(Member $creator) |
||
| 185 | |||
| 186 | /** |
||
| 187 | * @return Member |
||
| 188 | */ |
||
| 189 | public function getCreator() |
||
| 193 | |||
| 194 | public function attendants() |
||
| 198 | |||
| 199 | public function creator() |
||
| 203 | |||
| 204 | public function attachments() |
||
| 208 | |||
| 209 | public function hasAttachments() |
||
| 213 | |||
| 214 | /** |
||
| 215 | * @param Attachment[] $attachments |
||
| 216 | */ |
||
| 217 | public function addAttachments(array $attachments) |
||
| 221 | |||
| 222 | /** |
||
| 223 | * @return Attachment[] |
||
| 224 | */ |
||
| 225 | public function getAttachments() |
||
| 229 | |||
| 230 | public function hasReport() |
||
| 234 | |||
| 235 | public function needsReport() |
||
| 239 | |||
| 240 | public function reportAuthor() |
||
| 244 | |||
| 245 | /** |
||
| 246 | * @return Member |
||
| 247 | */ |
||
| 248 | public function getReportAuthor() |
||
| 252 | |||
| 253 | public function setReportAuthor(Member $member) |
||
| 257 | |||
| 258 | public function getMinutes() |
||
| 262 | |||
| 263 | public function setMinutes($minutes) |
||
| 267 | |||
| 268 | public function save(array $options = []) |
||
| 280 | } |
||
| 281 |
Since your code implements the magic getter
_get, this function will be called for any read access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.