Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
13 | class UptimeCheckRecovered extends BaseNotification |
||
14 | { |
||
15 | /** @var \Spatie\UptimeMonitor\Events\UptimeCheckRecovered */ |
||
16 | public $event; |
||
17 | |||
18 | /** |
||
19 | * Get the mail representation of the notification. |
||
20 | * |
||
21 | * @param mixed $notifiable |
||
22 | * @return \Illuminate\Notifications\Messages\MailMessage |
||
23 | */ |
||
24 | View Code Duplication | public function toMail($notifiable) |
|
25 | { |
||
26 | $mailMessage = (new MailMessage) |
||
27 | ->success() |
||
28 | ->subject($this->getMessageText()) |
||
29 | ->line($this->getMessageText()) |
||
30 | ->line($this->getLocationDescription()); |
||
31 | |||
32 | foreach ($this->getMonitorProperties() as $name => $value) { |
||
33 | $mailMessage->line($name.': '.$value); |
||
34 | } |
||
35 | |||
36 | return $mailMessage; |
||
37 | } |
||
38 | |||
39 | View Code Duplication | public function toSlack($notifiable) |
|
51 | |||
52 | public function getMonitorProperties($extraProperties = []): array |
||
60 | |||
61 | public function isStillRelevant(): bool |
||
65 | |||
66 | public function setEvent(MonitorRecoveredEvent $event) |
||
72 | |||
73 | public function getMessageText(): string |
||
77 | } |
||
78 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.