Completed
Push — master ( 7d7ae9...72b1fb )
by Vitaly
04:15 queued 01:38
created

Row   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 32.26 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A createDefinition() 10 10 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
 * Created by PhpStorm.
4
 * User: nazarenko
5
 * Date: 29.03.2016
6
 * Time: 12:38
7
 */
8
9
namespace samsoncms\api\generator;
10
11
use samsoncms\api\generator\metadata\Virtual;
12
use samsonphp\generator\Generator;
13
14
/**
15
 * Row class generator.
16
 *
17
 * @package samsoncms\api\generator
18
 */
19
class Row extends Entity
20
{
21
    /**
22
     * Query constructor.
23
     *
24
     * @param Generator $generator
25
     * @param           $metadata
26
     */
27
    public function __construct(Generator $generator, $metadata)
28
    {
29
        parent::__construct($generator, $metadata);
30
31
        $this->className = rtrim($this->className, 'Table').'TableRow';
32
    }
33
34
    /**
35
     * Class definition generation part.
36
     *
37
     * @param Virtual $metadata Entity metadata
38
     */
39 View Code Duplication
    protected function createDefinition($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...
40
    {
41
        $this->generator
42
            ->multiComment(array(
43
                'Class for rendering "' . $metadata->entityRealName . '" row',
44
            ))
45
            ->defClass($this->className, '\\'.\samsoncms\api\field\Row::class)
46
            ->newLine('use \\'.\samsoncms\api\Renderable::class.';')
47
            ->newLine();
48
    }
49
}
50