Completed
Push — master ( afc88d...d0e6e6 )
by Mārtiņš
02:23
created

SimpleFactory::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 7
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
crap 6
1
<?php
2
3
namespace Palladium\Component;
4
5
use RuntimeException;
6
7
class SimpleFactory
8
{
9
10
    /**
11
     * Methode for creating new instance of a given class
12
     *
13
     * @param string $name Fully qualified class name
0 ignored issues
show
Bug introduced by
There is no parameter named $name. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
14
     *
15
     * @throws RuntimeException if class can't be found
16
     *
17
     */
18
    public function create(string $className)
19
    {
20
        if (!class_exists($className)) {
21
            throw new RuntimeException("Mapper not found. Attempted to load '{$className}'.");
22
        }
23
24
        return new $className;
25
    }
26
}
27