Completed
Push — master ( bd46f2...d4c7f5 )
by Roman
08:20
created

BaseSender   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 14.29%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 38
ccs 1
cts 7
cp 0.1429
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\Object;
7
use Nette\Utils\Strings;
8
9
/**
10
 * Base Sender
11
 */
12 1
abstract class BaseSender extends Object implements ISender
13
{
14
	/** @var callable[] function (IMessage $message); Occurs before send SMS. */
15
	public $onBeforeSend;
16
17
	/** @var callable[] function (IMessage $message, $response); Occurs after success send SMS. */
18
	public $onSuccess;
19
20
	/** @var callable[] function (IMessage $message, $response); Occurs after failed send SMS. */
21
	public $onError;
22
23
	/** @var bool */
24
	protected $debug = FALSE;
25
26
	/** @var GuzzleHttp\Client */
27
	protected $httpClient;
28
29
	/**
30
	 * @param  bool $value
31
	 * @return self
32
	 */
33
	public function setDebugMode($value)
34
	{
35
		$this->debug = (bool) $value;
36
		return $this;
37
	}
38
39
	/**
40
	 * @return Guzzle\Client
41
	 */
42
	public function getHttpClient()
43
	{
44
		if ($this->httpClient)
45
			return $this->httpClient;
46
		$this->httpClient = new GuzzleHttp\Client;
47
		return $this->httpClient;
48
	}
49
}
50