Conditions | 4 |
Paths | 1 |
Total Lines | 15 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | 13 | public function comment(Commentable $commentable, string $commentText = '', int $rate = 0): Comment |
|
13 | { |
||
14 | 13 | $commentModel = config('comment.model'); |
|
15 | |||
16 | 13 | $comment = new $commentModel([ |
|
17 | 13 | 'comment' => $commentText, |
|
18 | 13 | 'rate' => $commentable->canBeRated() ? $rate : null, |
|
19 | 13 | 'approved' => $commentable->mustBeApproved() && !$this->canCommentWithoutApprove() ? false : true, |
|
20 | 13 | 'commented_id' => $this->primaryId(), |
|
21 | 13 | 'commented_type' => get_class(), |
|
22 | ]); |
||
23 | |||
24 | 13 | $commentable->comments()->save($comment); |
|
25 | |||
26 | 13 | return $comment; |
|
27 | } |
||
54 |