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 ( 900862...fe0e92 )
by James Ekow Abaka
21:10 queued 18:55
created

Resolver::getJunctionClassName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2.0438

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 7
cts 9
cp 0.7778
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 11
nc 2
nop 2
crap 2.0438
1
<?php
2
3
namespace ntentan\nibii;
4
5
use ntentan\nibii\interfaces\ModelClassResolverInterface;
6
use ntentan\nibii\interfaces\ModelJoinerInterface;
7
use ntentan\nibii\interfaces\TableNameResolverInterface;
8
use ntentan\config\Config;
9
use ntentan\utils\Text;
10
11
/**
12
 * Description of DefaultClassResolver
13
 *
14
 * @author ekow
15
 */
16
class Resolver implements ModelClassResolverInterface, ModelJoinerInterface, TableNameResolverInterface 
17
{
18 14
    public function getModelClassName($className, $context) {
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
19 14
        return $className;
20
    }
21
22 4
    private function getClassFileDetails($className) {
23 4
        $arrayed = explode('\\', $className);
24 4
        $class = array_pop($arrayed);
25 4
        if ($arrayed[0] == '') {
26 4
            array_shift($arrayed);
27
        }
28 4
        return ['class' => $class, 'namespace' => implode('\\', $arrayed)];
29
    }
30
31 4
    public function getJunctionClassName($classA, $classB) {
32 4
        $classA = $this->getClassFileDetails($classA);
33 4
        $classB = $this->getClassFileDetails($classB);
34 4
        if ($classA['namespace'] != $classB['namespace']) {
35
            throw new NibiiException(
36
            "Cannot automatically join two classes of different "
37
            . "namespaces. Please provide a model joiner or "
38
            . "explicitly specify your joint model."
39
            );
40
        }
41 4
        $classes = [$classA['class'], $classB['class']];
42 4
        sort($classes);
43 4
        return "{$classA['namespace']}\\" . implode('', $classes);
44
    }
45
46 36
    public function getTableName($instance) {
47 36
        $class = new \ReflectionClass($instance);
48 36
        $nameParts = explode("\\", $class->getName());
49 36
        return \ntentan\utils\Text::deCamelize(end($nameParts));
50
    }
51
52 37
    public static function getDriverAdapterClassName($driver = false) {
53 37
        if ($driver) {
54 37
            return __NAMESPACE__ . '\adapters\\' . Text::ucamelize($driver) . 'Adapter';
0 ignored issues
show
Documentation introduced by
$driver is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
55
        }
56
        throw new NibiiException("Please specify a driver");
57
    }
58
59
}
60