VirtualCollection   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 66.67 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
lcom 1
cbo 2
dl 16
loc 24
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A createConstructor() 16 16 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
//[PHPCOMPRESSOR(remove,start)]
3
/**
4
 * Created by Vitaly Iegorov <[email protected]>.
5
 * on 22.03.16 at 15:46
6
 */
7
namespace samsoncms\api\generator;
8
9
/**
10
 * Virtual entity collection class generator.
11
 *
12
 * @package samsoncms\api\generator
13
 */
14
class VirtualCollection extends RealCollection
15
{
16
    /**
17
     * Class constructor generation part.
18
     *
19
     * @param \samsoncms\api\generator\metadata\VirtualMetadata $metadata Entity metadata
20
     */
21 View Code Duplication
    protected function createConstructor($metadata)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
    {
23
        $class = "\n\t" . '/**';
24
        $class .= "\n\t" . ' * @param ViewInterface $renderer Rendering instance';
25
        $class .= "\n\t" . ' * @param QueryInterface $query Database query instance';
26
        $class .= "\n\t" . ' * @param string $locale Localization identifier';
27
        $class .= "\n\t" . ' */';
28
        $class .= "\n\t" . 'public function __construct(ViewInterface $renderer, QueryInterface $query = null, $locale = null)';
29
        $class .= "\n\t" . '{';
30
        $class .= "\n\t\t" . '$this->renderer = $renderer;';
31
        $class .= "\n\t\t" . '$container = $GLOBALS[\'__core\']->getContainer();';
32
        $class .= "\n\t\t" . 'parent::__construct($locale, $query ?? $container->get("query"));';
33
        $class .= "\n\t" . '}';
34
35
        $this->generator->text($class);
36
    }
37
}
38
//[PHPCOMPRESSOR(remove,end)]
39