Conditions | 3 |
Paths | 2 |
Total Lines | 36 |
Lines | 20 |
Ratio | 55.56 % |
Changes | 0 |
1 | <?php |
||
11 | public static function display() |
||
12 | { |
||
13 | $healthyMonitor = MonitorRepository::getHealthy(); |
||
14 | |||
15 | if (! $healthyMonitor->count()) { |
||
16 | return; |
||
17 | } |
||
18 | |||
19 | ConsoleOutput::info('Healthy monitors'); |
||
20 | ConsoleOutput::info('================'); |
||
21 | |||
22 | View Code Duplication | $rows = $healthyMonitor->map(function (Monitor $monitor) { |
|
|
|||
23 | $certificateFound = ''; |
||
24 | $certificateExpirationDate = ''; |
||
25 | $certificateIssuer = ''; |
||
26 | |||
27 | $url = $monitor->url; |
||
28 | |||
29 | $reachable = $monitor->uptimeStatusAsEmoji; |
||
30 | |||
31 | $onlineSince = $monitor->formattedLastUpdatedStatusChangeDate('forHumans'); |
||
32 | |||
33 | if ($monitor->certificate_check_enabled) { |
||
34 | $certificateFound = $monitor->certificateStatusAsEmoji; |
||
35 | $certificateExpirationDate = $monitor->formattedCertificateExpirationDate('forHumans'); |
||
36 | $certificateIssuer = $monitor->certificate_issuer; |
||
37 | } |
||
38 | |||
39 | return compact('url', 'reachable', 'onlineSince', 'certificateFound', 'certificateExpirationDate', 'certificateIssuer'); |
||
40 | }); |
||
41 | |||
42 | $titles = ['URL', 'Uptime check', 'Online since', 'Certificate check', 'Certificate Expiration date', 'Certificate Issuer']; |
||
43 | |||
44 | ConsoleOutput::table($titles, $rows); |
||
45 | ConsoleOutput::line(''); |
||
46 | } |
||
47 | } |
||
48 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.