Application::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace HelePartnerSyncApi;
4
5
use Closure;
6
use HelePartnerSyncApi\Method\CancelReservation;
7
use HelePartnerSyncApi\Method\CheckHealth;
8
use HelePartnerSyncApi\Method\CheckSlots;
9
use HelePartnerSyncApi\Method\CreateReservation;
10
use HelePartnerSyncApi\Request\DefaultRequestFactory;
11
12
class Application
13
{
14
15
	/**
16
	 * @var Client
17
	 */
18
	private $client;
19
20
	/**
21
	 * @param string $secret
22
	 */
23
	public function __construct($secret)
24
	{
25
		$this->client = new Client($secret, new DefaultRequestFactory($secret));
26
		$this->client->registerMethod(new CheckHealth());
27
	}
28
29
	/**
30
	 * @param Closure $callback function (DateTime $date, array $parameters)
31
	 */
32
	public function onCheckSlots(Closure $callback)
33
	{
34
		$this->client->registerMethod(new CheckSlots($callback));
35
	}
36
37
	/**
38
	 * @param Closure $callback function (DateTime $startDateTime, DateTime $endDateTime, int $quantity, array $parameters)
39
	 */
40
	public function onCreateReservation(Closure $callback)
41
	{
42
		$this->client->registerMethod(new CreateReservation($callback));
43
	}
44
45
	/**
46
	 * @param Closure $callback function (DateTime $startDateTime, DateTime $endDateTime, int $quantity, array $parameters)
47
	 */
48
	public function onCancelReservation(Closure $callback)
49
	{
50
		$this->client->registerMethod(new CancelReservation($callback));
51
	}
52
53
	public function run()
54
	{
55
		$this->client->run()->render();
56
	}
57
58
}
59