Repository::setGateway()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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