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 ( 1a4696...c27e6c )
by Freek
02:20
created

CreateUptimeMonitor::handle()   B

Complexity

Conditions 3
Paths 3

Size

Total Lines 26
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 14
c 1
b 0
f 0
nc 3
nop 0
dl 0
loc 26
rs 8.8571
1
<?php
2
3
namespace Spatie\UptimeMonitor\Commands;
4
5
use Illuminate\Console\Command;
6
use Spatie\UptimeMonitor\Models\Site;
7
use Spatie\Url\Url;
8
9
class CreateUptimeMonitor extends Command
10
{
11
    /**
12
     * The name and signature of the console command.
13
     *
14
     * @var string
15
     */
16
    protected $signature = 'uptime-monitor:create';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Create an uptime monitor';
24
25
    public function handle()
26
    {
27
        $this->warn("Let's create your new uptime monitor!");
28
29
        $url = $this->ask("Which url to you want to monitor? Should start with either 'http://' or 'https://'");
30
31
        $url = Url::fromString($url);
32
33
        if (! in_array($url->getScheme(), ['http', 'https'])) {
34
            $this->error("The given url did not start with `http://` or `https://`.");
35
            return;
36
        }
37
38
        if ($this->confirm('Should we look for a specific string on the response?')) {
39
            $lookForString = $this->ask("Which string?");
40
        }
41
42
        $site = Site::create([
43
            'url' => $url,
44
            'look_for_string' => $lookForString ?? '',
45
            'check_ssl_certificate' => $url->getScheme() === 'https'
46
        ]);
47
48
        $this->warn("A new uptime monitor for {$site->url} was created!");
49
50
    }
51
}
52