ApiAuth_UserKeyModel   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 36.36 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getTableName() 0 4 1
A defineAttributes() 8 8 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
namespace Craft;
4
5
/**
6
 * Class ApiAuth_UserKeyModel.
7
 *
8
 * @author    Nerds & Company
9
 * @copyright Copyright (c) 2015, Nerds & Company
10
 * @license   MIT
11
 *
12
 * @link      http://www.nerds.company
13
 *
14
 * @property int $id
15
 * @property int $userId
16
 * @property string $key
17
 * @property DateTime $expires
18
 */
19
class ApiAuth_UserKeyModel extends BaseRecord
20
{
21
    /**
22
     * @inheritdoc
23
     */
24
    public function getTableName()
25
    {
26
        return 'apiauth_userkeys';
27
    }
28
29
    /**
30
     * @inheritdoc
31
     */
32 View Code Duplication
    protected function defineAttributes()
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...
33
    {
34
        return array(
35
            'userId' => array(AttributeType::Number, 'required' => true),
36
            'key' => array(AttributeType::String, 'required' => true, 'unique' => true),
37
            'expires' => array(AttributeType::DateTime, 'required' => true),
38
        );
39
    }
40
}
41