SMSFactorFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 57
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A make() 0 5 1
A createAdapter() 0 4 1
A getAdapter() 0 4 1
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
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

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.

Loading history...
38
     */
39
    public function __construct(AdapterFactory $adapter)
40
    {
41
        $this->adapter = $adapter;
0 ignored issues
show
Documentation Bug introduced by
It seems like $adapter of type object<IlGala\SMSFactor\...tors\ConnectionFactory> is incompatible with the declared type object<IlGala\SMSFactor\...ters\ConnectionFactory> of property $adapter.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
42
    }
43
44
    /**
45
     * Make a new smsfactor 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