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

GeneratorWrapper   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 14
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getGenerator() 0 4 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