NewInstanceBuilder   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 9 9 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * @author stev leibelt <[email protected]>
4
 * @since 2014-06-13 
5
 */
6
7
namespace Net\Bazzline\Component\Locator\MethodBodyBuilder;
8
9
use Net\Bazzline\Component\CodeGenerator\BlockGenerator;
10
11
/**
12
 * Class NewInstanceBuilder
13
 * @package Net\Bazzline\Component\Locator\MethodBodyBuilder
14
 */
15 View Code Duplication
class NewInstanceBuilder extends AbstractMethodBodyBuilder
16
{
17
    /**
18
     * @param BlockGenerator $body
19
     * @return BlockGenerator
20
     * @throws RuntimeException
21
     */
22
    public function build(BlockGenerator $body)
23
    {
24
        $this->assertMandatoryProperties();
25
26
        $body
27
            ->add('return new ' . $this->instance->getClassName() . '();');
28
29
        return $body;
30
    }
31
}