Completed
Push — master ( 532b1f...89ab0b )
by Mr
04:53 queued 11s
created

GeneratorWrapper::getGenerator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace OpenVPN\Laravel;
4
5
use OpenVPN\Generator;
6
use OpenVPN\Interfaces\ConfigInterface;
7
use OpenVPN\Interfaces\GeneratorInterface;
8
9
class GeneratorWrapper
10
{
11
    /**
12
     * Get object of generator
13
     *
14
     * @param \OpenVPN\Interfaces\ConfigInterface|null $config
15
     *
16
     * @return \OpenVPN\Interfaces\GeneratorInterface
17
     */
18
    public function getGenerator(ConfigInterface $config = null): GeneratorInterface
19
    {
20
        return new Generator($config);
0 ignored issues
show
Bug introduced by
It seems like $config defined by parameter $config on line 18 can be null; however, OpenVPN\Generator::__construct() does not accept null, maybe add an additional type check?

It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.

We recommend to add an additional type check (or disallow null for the parameter):

function notNullable(stdClass $x) { }

// Unsafe
function withoutCheck(stdClass $x = null) {
    notNullable($x);
}

// Safe - Alternative 1: Adding Additional Type-Check
function withCheck(stdClass $x = null) {
    if ($x instanceof stdClass) {
        notNullable($x);
    }
}

// Safe - Alternative 2: Changing Parameter
function withNonNullableParam(stdClass $x) {
    notNullable($x);
}
Loading history...
21
    }
22
}
23