GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( e92faa...77b90f )
by Lanre
02:17
created

GbowoFactory   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 52
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0
wmc 8
lcom 1
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 4
A setDefaultAdapters() 0 7 1
A throwException() 0 4 1
A createAdapter() 0 10 2
1
<?php
2
3
4
namespace Gbowo;
5
6
use InvalidArgumentException;
7
use Gbowo\Adapter\Paystack\PaystackAdapter;
8
use Gbowo\Contract\Adapter\AdapterInterface;
9
use Gbowo\Adapter\Amplifypay\AmplifypayAdapter;
10
11
class GbowoFactory
12
{
13
14
    const PAYSTACK = "paystack";
15
16
    const AMPLIFY_PAY = "amplifypay";
17
18
    protected $availableAdapters = [];
19
20 6
    public function __construct(array $types = [])
21
    {
22 6
        $this->setDefaultAdapters();
23
24 6
        if (!empty($types)) {
25 3
            foreach ($types as $type => $value) {
26 3
                if (!$value instanceof AdapterInterface) {
27 3
                    throw $this->throwException("This is not a valid adapter");
28
                }
29
            }
30 2
            $this->availableAdapters = array_merge($this->availableAdapters, $types);
31
        }
32 5
    }
33
34 6
    protected function setDefaultAdapters()
35
    {
36 6
        $this->availableAdapters = [
37 6
            self::PAYSTACK => PaystackAdapter::class,
38 6
            self::AMPLIFY_PAY => AmplifypayAdapter::class
39
        ];
40 6
    }
41
42 2
    protected function throwException(string $message)
43
    {
44 2
        return new InvalidArgumentException($message);
45
    }
46
47
    /**
48
     * @param string $adapterIdentifier
49
     * @return AdapterInterface
50
     * @throws InvalidArgumentException
51
     */
52 5
    public function createAdapter(string $adapterIdentifier)
53
    {
54 5
        if (!array_key_exists($adapterIdentifier, $this->availableAdapters)) {
55 1
            throw $this->throwException(
56 1
                "Unknown adapter. Did you forget to add this adapter on object initialization ?"
57
            );
58
        }
59
60 4
        return new $this->availableAdapters[$adapterIdentifier];
61
    }
62
}
63