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.
Completed
Push — master ( b905f6...efedee )
by Freek
01:58
created

HealthySites   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 38.1 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 16
loc 42
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B display() 16 32 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\UptimeMonitorLists;
4
5
use Illuminate\Console\Command;
6
use Spatie\UptimeMonitor\Helpers\Emoji;
7
use Spatie\UptimeMonitor\Models\Site;
8
use Spatie\UptimeMonitor\SiteRepository;
9
10
class HealthySites
11
{
12
    protected $output;
13
14
    public function __construct(Command $output)
15
    {
16
        $this->output = $output;
17
    }
18
19
    public function display()
20
    {
21
        $healthySites = SiteRepository::healthySites();
22
23
        if (! $healthySites->count()) {
24
            return;
25
        }
26
27
        $this->output->info('Healthy sites');
28
        $this->output->info('============');
29
30 View Code Duplication
        $rows = $healthySites->map(function (Site $site) {
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...
31
            $url = $site->url;
32
33
            $reachable = $site->reachableAsEmoji;
34
35
            $onlineSince = $site->formattedLastUpdatedStatusChangeDate;
36
37
            if ($site->check_ssl_certificate) {
38
                $sslCertificateFound = Emoji::ok();
39
                $sslCertificateExpirationDate = $site->formattedSslCertificateExpirationDate;
40
                $sslCertificateIssuer = $site->ssl_certificate_issuer;
41
            }
42
43
44
            return compact('url', 'reachable', 'onlineSince', 'sslCertificateFound', 'sslCertificateExpirationDate', 'sslCertificateIssuer');
45
        });
46
47
        $titles = ['URL', 'Reachable', 'Online since', 'SSL Certifcate', 'SSL Expiration date', 'SSL Issuer'];
48
49
        $this->output->table($titles, $rows);
50
    }
51
}