Row   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 34.38 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

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