Completed
Push — master ( d4c7f5...603b58 )
by Roman
06:55
created

BaseSender   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 40
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setDebugMode() 0 5 1
A getHttpClient() 0 7 2
1
<?php
2
3
namespace RM\SMSender;
4
5
use GuzzleHttp;
6
use Nette\SmartObject;
7
use Nette\Utils\Strings;
8
9
/**
10
 * Base Sender
11
 */
12 1
abstract class BaseSender implements ISender
13
{
14 1
	use SmartObject;
15
16
	/** @var callable[] function (IMessage $message); Occurs before send SMS. */
17
	public $onBeforeSend;
18
19
	/** @var callable[] function (IMessage $message, $response); Occurs after success send SMS. */
20
	public $onSuccess;
21
22
	/** @var callable[] function (IMessage $message, $response); Occurs after failed send SMS. */
23
	public $onError;
24
25
	/** @var bool */
26
	protected $debug = FALSE;
27
28
	/** @var GuzzleHttp\Client */
29
	protected $httpClient;
30
31
	/**
32
	 * @param  bool $value
33
	 * @return self
34
	 */
35
	public function setDebugMode($value)
36
	{
37 1
		$this->debug = (bool) $value;
38 1
		return $this;
39
	}
40
41
	/**
42
	 * @return Guzzle\Client
43
	 */
44
	public function getHttpClient()
45
	{
46 1
		if ($this->httpClient)
47 1
			return $this->httpClient;
48 1
		$this->httpClient = new GuzzleHttp\Client;
49 1
		return $this->httpClient;
50
	}
51
}
52