VirtualCollection::createConstructor()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 13

Duplication

Lines 16
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 16
loc 16
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 13
nc 1
nop 1
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