Completed
Push — master ( e2547a...b91078 )
by Tyler
04:34
created

DriverFactory::twilio()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace LeadThread\Sms\Factories;
4
5
use Exception;
6
use LeadThread\Sms\Drivers\Plivo;
7
use LeadThread\Sms\Drivers\Twilio;
8
use LeadThread\Sms\Drivers\Bandwidth;
9
10
class DriverFactory
11
{
12
13
    /**
14
     * Creates a driver instance
15
     * @param  string $driver The driver instance to create
16
     * @return \LeadThread\Sms\Drivers\SendsSms
17
     */
18 15
    public function get($driver)
19
    {
20 15
        $config = config("sms.{$driver}");
21 15
        if (is_array($config)) {
22 15
            return $this->{$driver}($config);
23
        } else {
24
            throw new Exception("config must be an array! You may have chosen an unsupported SMS driver.");
25 3
        }
26 3
    }
27
28
    /**
29
     * Plivo
30
     * @param  array $config An array of config values for setting up the driver
31
     * @return \LeadThread\Sms\Drivers\Plivo\Request
32
     */
33 9
    protected function plivo(array $config)
34
    {
35 9
        return new Plivo($config['user'], $config['token']);
36
    }
37
38
    /**
39
     * Twilio
40
     * @param  array $config An array of config values for setting up the driver
41
     * @return \LeadThread\Sms\Drivers\Twilio
42
     */
43 3
    protected function twilio(array $config)
44
    {
45 3
        return new Twilio($config['user'], $config['token']);
46
    }
47
48
    /**
49
     * Bandwidth
50
     * @param  array $config An array of config values for setting up the driver
51
     * @return \LeadThread\Sms\Drivers\Bandwidth
52
     */
53 3
    protected function bandwidth(array $config)
54
    {
55 3
        return new Bandwidth($config['secret'], $config['token'], $config['user_id']);
56
    }
57
}