Completed
Push — master ( 9b4a2a...13582b )
by Jared
01:58
created

JCMapper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 3
c 1
b 1
f 0
lcom 1
cbo 1
dl 0
loc 17
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createInstance() 0 13 3
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: jaredchu
5
 * Date: 10/08/2017
6
 * Time: 11:50
7
 */
8
9
namespace JC;
10
11
use JsonMapper;
12
13
class JCMapper extends JsonMapper
14
{
15
    public function createInstance(
16
        $class, $useParameter = false, $parameter = null
17
    )
18
    {
19
        if (isset($this->classMap[$class])) {
20
            $class = $this->classMap[$class];
21
        }
22
        if ($useParameter) {
23
            return new $class($parameter);
24
        } else {
25
            return (new \ReflectionClass($class))->newInstanceWithoutConstructor();
26
        }
27
    }
28
29
}