Completed
Push — master ( fc9b06...645bdc )
by Vitaly
07:44
created

Field   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 50 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A byID() 8 8 2
A byName() 8 8 2

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
namespace samsoncms\api;
3
4
/**
5
 * SamsonCMS field table class
6
 * @package samson\cms
7
 */
8
class Field extends \samson\activerecord\field
9
{
10
  /**
11
     * Find field database record by identifier
12
     * @param string $identifier Field identifier
13
     * @param self $return Return self instance
14
     * @return bool|null
15
     */
16 View Code Duplication
    public static function byID($identifier, self & $return = null )
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...
Coding Style introduced by
Expected 0 spaces between argument "$return" and closing bracket; 1 found
Loading history...
17
    {
18
        // Get field record by identiifer column
19
        $return = static::oneByColumn(new dbQuery(), self::$_primary, $identifier);
20
21
        // If only one argument is passed - return null, otherwise bool
22
        return func_num_args() > 1 ? $return == null : $return;
23
    }
24
25
    /**
26
     * Find field database record by name
27
     * @param string $identifier Field identifier
28
     * @param self $return Return self instance
29
     * @return bool|null
30
     */
31 View Code Duplication
    public static function byName($identifier, self & $return = null )
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...
Coding Style introduced by
Expected 0 spaces between argument "$return" and closing bracket; 1 found
Loading history...
32
    {
33
        // Get field record by identiifer column
34
        $return = static::oneByColumn(new dbQuery(), self::$_primary, 'Name');
35
36
        // If only one argument is passed - return null, otherwise bool
37
        return func_num_args() > 1 ? $return == null : $return;
38
    }
39
}
40