Scheduler   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 6
dl 0
loc 44
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A takeover() 0 6 1
A server() 0 4 1
A jobs() 0 6 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Lookyman\Rundeck\Api\Endpoints\Scheduler;
5
6
use GuzzleHttp\Promise\PromiseInterface;
7
use Lookyman\Rundeck\Api\Client;
8
use GuzzleHttp\Psr7\Request;
9
10
class Scheduler
11
{
12
	/**
13
	 * @var Client
14
	 */
15
	private $client;
16
17
	/**
18
	 * @param Client $client
19
	 */
20
	public function __construct(Client $client)
21
	{
22
		$this->client = $client;
23
	}
24
25
	/**
26
	 * @param array $params
27
	 * @return PromiseInterface
28
	 */
29
	public function takeover(array $params = []): PromiseInterface
30
	{
31
		return $this->client->getConfiguration()->getGuzzle()->sendAsync(
32
			new Request('PUT', $this->client->getConfiguration()->getBaseUri() . '/scheduler/takeover', [], $this->client->getConfiguration()->getFormat()->formatParams($params))
33
		);
34
	}
35
36
	/**
37
	 * @return Server
38
	 */
39
	public function server(): Server
40
	{
41
		return new Server($this->client);
42
	}
43
44
	/**
45
	 * @return PromiseInterface
46
	 */
47
	public function jobs(): PromiseInterface
48
	{
49
		return $this->client->getConfiguration()->getGuzzle()->sendAsync(
50
			new Request('GET', $this->client->getConfiguration()->getBaseUri() . '/scheduler/jobs')
51
		);
52
	}
53
}
54