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

BaseSender::getHttpClient()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 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