PingTask   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
eloc 16
c 1
b 0
f 1
dl 0
loc 50
ccs 12
cts 18
cp 0.6667
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getMethod() 0 3 1
A getOptions() 0 3 1
A __construct() 0 7 1
A getContext() 0 6 1
A getMissingDependencyMessage() 0 3 1
A getUrl() 0 3 1
1
<?php
2
3
namespace Zenstruck\ScheduleBundle\Schedule\Task;
4
5
use Zenstruck\ScheduleBundle\Schedule\HasMissingDependencyMessage;
6
use Zenstruck\ScheduleBundle\Schedule\Task;
7
8
/**
9
 * @author Kevin Bond <[email protected]>
10
 */
11
final class PingTask extends Task implements HasMissingDependencyMessage
12
{
13
    /** @var string */
14
    private $url;
15
16
    /** @var string */
17
    private $method;
18
19
    /** @var array */
20 7
    private $options;
21
22 7
    /**
23 7
     * @param array $options See HttpClientInterface::OPTIONS_DEFAULTS
24 7
     */
25
    public function __construct(string $url, string $method = 'GET', array $options = [])
26 7
    {
27 7
        $this->url = $url;
28
        $this->method = $method;
29
        $this->options = $options;
30
31
        parent::__construct("Ping {$url}");
32
    }
33
34
    public function getContext(): array
35
    {
36
        return [
37
            'Url' => $this->url,
38 5
            'Method' => $this->method,
39
            'Options' => \json_encode($this->options),
40 5
        ];
41
    }
42
43 5
    public function getUrl(): string
44
    {
45 5
        return $this->url;
46
    }
47
48 5
    public function getMethod(): string
49
    {
50 5
        return $this->method;
51
    }
52
53
    public function getOptions(): array
54
    {
55
        return $this->options;
56
    }
57
58
    public static function getMissingDependencyMessage(): string
59
    {
60
        return \sprintf('Symfony HttpClient is required to use "%s". Install with "composer require symfony/http-client".', self::class);
61
    }
62
}
63