Passed
Pull Request — master (#8)
by Kevin
17:44
created

PingTask::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 4
c 1
b 0
f 1
dl 0
loc 7
rs 10
cc 1
nc 1
nop 3
1
<?php
2
3
namespace Zenstruck\ScheduleBundle\Schedule\Task;
4
5
use Zenstruck\ScheduleBundle\Schedule\Task;
6
7
/**
8
 * @author Kevin Bond <[email protected]>
9
 */
10
final class PingTask extends Task
11
{
12
    private $url;
13
    private $method;
14
    private $options;
15
16
    /**
17
     * @param array $options See HttpClientInterface::OPTIONS_DEFAULTS
18
     */
19
    public function __construct(string $url, string $method = 'GET', array $options = [])
20
    {
21
        $this->url = $url;
22
        $this->method = $method;
23
        $this->options = $options;
24
25
        parent::__construct("Ping {$url}");
26
    }
27
28
    public function getContext(): array
29
    {
30
        return [
31
            'Url' => $this->url,
32
            'Method' => $this->method,
33
            'Options' => \json_encode($this->options),
34
        ];
35
    }
36
37
    public function getUrl(): string
38
    {
39
        return $this->url;
40
    }
41
42
    public function getMethod(): string
43
    {
44
        return $this->method;
45
    }
46
47
    public function getOptions(): array
48
    {
49
        return $this->options;
50
    }
51
}
52