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 ( 625c67...02ef72 )
by Freek
02:12
created

EnableMonitor::enableMonitor()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 17
Code Lines 9

Duplication

Lines 17
Ratio 100 %

Importance

Changes 0
Metric Value
dl 17
loc 17
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 9
nc 3
nop 1
1
<?php
2
3
namespace Spatie\UptimeMonitor\Commands;
4
5
use Spatie\UptimeMonitor\Models\Monitor;
6
use Spatie\UptimeMonitor\MonitorRepository;
7
use Spatie\Url\Url;
8
9 View Code Duplication
class EnableMonitor extends BaseCommand
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in 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...
10
{
11
    protected $signature = 'monitor:enable {url}';
12
13
    protected $description = 'Enable a monitors';
14
15
    public function handle()
16
    {
17
        foreach (explode(',', $this->argument('url')) as $url) {
18
            $this->enableMonitor(trim($url));
19
        }
20
    }
21
22
    protected function enableMonitor(string $url)
0 ignored issues
show
Coding Style Best Practice introduced by
Please use __construct() instead of a PHP4-style constructor that is named after the class.
Loading history...
23
    {
24
        if (! $monitor = MonitorRepository::findByUrl($url)) {
25
            $this->error("There is no monitor configured for url `{$url}`.");
26
27
            return;
28
        }
29
30
        if ($monitor->enabled) {
31
            $this->warn("The monitor for url `{$url}` was already enabled.");
32
33
            return;
34
        }
35
36
        $monitor->enable();
37
        $this->info("The monitor for url `{$url}` is now enabled");
38
    }
39
}
40