Conditions | 3 |
Paths | 3 |
Total Lines | 26 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
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 |