Passed
Push — master ( 68443e...939347 )
by Mihail
04:31
created

FormAnswerAdd   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 85.71 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A make() 18 18 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\Model\Admin\Feedback;
4
5
use Apps\ActiveRecord\FeedbackAnswer;
6
use Apps\Model\Front\Feedback\FormAnswerAdd as FrontAnswer;
7
use Ffcms\Core\App;
8
9
/**
10
 * Class FormAnswerAdd. Extend front model add answer
11
 * @package Apps\Model\Admin\Feedback
12
 */
13
class FormAnswerAdd extends FrontAnswer
14
{
15 View Code Duplication
    public function make()
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...
16
    {
17
        // update readed marker
18
        $this->_post->readed = 1;
19
        $this->_post->save();
20
21
        // add new answer row in database
22
        $record = new FeedbackAnswer();
23
        $record->feedback_id = $this->_post->id;
24
        $record->name = App::$Security->strip_tags($this->name);
25
        $record->email = App::$Security->strip_tags($this->email);
26
        $record->message = App::$Security->strip_tags($this->message);
27
        $record->user_id = $this->_userId;
28
        $record->is_admin = 1;
29
30
        $record->ip = $this->_ip;
31
        $record->save();
32
    }
33
}