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::setDefaultAdapters()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
ccs 5
cts 5
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
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