1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of Laravel SMSFactor. |
5
|
|
|
* |
6
|
|
|
* (c) Filippo Galante <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace IlGala\SMSFactor; |
13
|
|
|
|
14
|
|
|
use IlGala\SMSFactor\SMSFactor; |
15
|
|
|
use IlGala\SMSFactor\Connectors\ConnectionFactory as AdapterFactory; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* This is the SMSFactor factory class. |
19
|
|
|
* |
20
|
|
|
* @author Filippo Galante <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
class SMSFactorFactory |
23
|
|
|
{ |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* The adapter factory instance. |
27
|
|
|
* |
28
|
|
|
* @var \IlGala\SMSFactor\Adapters\ConnectionFactory |
29
|
|
|
*/ |
30
|
|
|
protected $adapter; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Create a new filesystem factory instance. |
34
|
|
|
* |
35
|
|
|
* @param \IlGala\SMSFactor\Adapters\ConnectionFactory $adapter |
36
|
|
|
* |
37
|
|
|
* @return void |
|
|
|
|
38
|
|
|
*/ |
39
|
|
|
public function __construct(AdapterFactory $adapter) |
40
|
|
|
{ |
41
|
|
|
$this->adapter = $adapter; |
|
|
|
|
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Make a new digitalocean client. |
46
|
|
|
* |
47
|
|
|
* @param string[] $config |
48
|
|
|
* |
49
|
|
|
* @return \IlGala\SMSFactor\SMSFactor |
50
|
|
|
*/ |
51
|
|
|
public function make(array $config) |
52
|
|
|
{ |
53
|
|
|
$adapter = $this->createAdapter($config); |
54
|
|
|
return new SMSFactor($adapter, $config['accept']); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Establish an adapter connection. |
59
|
|
|
* |
60
|
|
|
* @param array $config |
61
|
|
|
* |
62
|
|
|
* @return \IlGala\SMSFactor\Adapters\AdapterInterface |
63
|
|
|
*/ |
64
|
|
|
public function createAdapter(array $config) |
65
|
|
|
{ |
66
|
|
|
return $this->adapter->make($config); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Get the adapter factory instance. |
71
|
|
|
* |
72
|
|
|
* @return \IlGala\SMSFactor\Adapters\ConnectionFactory |
73
|
|
|
*/ |
74
|
|
|
public function getAdapter() |
75
|
|
|
{ |
76
|
|
|
return $this->adapter; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
} |
80
|
|
|
|
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.