Repository   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 8
c 2
b 0
f 0
dl 0
loc 31
ccs 11
cts 11
cp 1
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getGateway() 0 7 2
A setGateway() 0 3 1
A __construct() 0 4 2
1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of FlexPHP.
4
 *
5
 * (c) Freddie Gar <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace FlexPHP\Repositories;
11
12
use FlexPHP\Repositories\Exception\UndefinedGatewayRepositoryException;
13
14
abstract class Repository implements RepositoryInterface
15
{
16
    /**
17
     * @var mixed
18
     */
19
    private $gateway;
20
21 5
    public function __construct($gateway = null)
22
    {
23 5
        if (!\is_null($gateway)) {
24 1
            $this->setGateway($gateway);
25
        }
26 5
    }
27
28 3
    public function setGateway($gateway): void
29
    {
30 3
        $this->gateway = $gateway;
31 3
    }
32
33
    /**
34
     * @throws UndefinedGatewayRepositoryException
35
     *
36
     * @return mixed
37
     */
38 4
    public function getGateway()
39
    {
40 4
        if (\is_null($this->gateway)) {
41 1
            throw new UndefinedGatewayRepositoryException();
42
        }
43
44 3
        return $this->gateway;
45
    }
46
}
47