Passed
Push — master ( 37fbce...eb9638 )
by Mihail
09:07
created

CommentAnswer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 100 %

Coupling/Cohesion

Components 2
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getUser() 4 4 1
A getCommentPost() 4 4 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 Apps\ActiveRecord;
4
5
use Ffcms\Core\Arch\ActiveModel;
6
7
/**
8
 * Class CommentAnswer. Active record model for comments answers list
9
 * @package Apps\ActiveRecord
10
 * @property int $id
11
 * @property int $comment_id
12
 * @property int $user_id
13
 * @property string $guest_name
14
 * @property string $message
15
 * @property string $created_at
16
 * @property string $updated_at
17
 */
18 View Code Duplication
class CommentAnswer extends ActiveModel
0 ignored issues
show
Duplication introduced by
This class 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...
19
{
20
21
    /**
22
     * Get user identity
23
     * @return User|null
24
     */
25
    public function getUser()
26
    {
27
        return User::identity($this->user_id);
28
    }
29
30
    /**
31
     * Get comment post object
32
     * @return WallPost|null
33
     */
34
    public function getCommentPost()
35
    {
36
        return CommentPost::where('id', '=', $this->comment_id)->first();
37
    }
38
}