GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Healthy   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 51.28 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 20
loc 39
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A display() 20 36 3

How to fix   Duplicated Code   

Duplicated Code

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
2
3
namespace Spatie\UptimeMonitor\Commands\MonitorLists;
4
5
use Spatie\UptimeMonitor\Helpers\ConsoleOutput;
6
use Spatie\UptimeMonitor\Models\Monitor;
7
use Spatie\UptimeMonitor\MonitorRepository;
8
9
class Healthy
10
{
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) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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.

Loading history...
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