Completed
Branch master (a6481d)
by Fèvre
02:09
created

CommentRepository   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 8 1
1
<?php
2
namespace Xetaravel\Models\Repositories;
3
4
use Illuminate\Support\Collection;
5
use Xetaravel\Models\Comment;
6
7
class CommentRepository
8
{
9
    /**
10
     * Create a new comment instance after a valid validation.
11
     *
12
     * @param array $data The data used to create the comment.
13
     * @param \Xetaravel\Models\User $user The current user.
14
     *
15
     * @return \Xetaravel\Models\Comment
16
     */
17
    public static function create(array $data, $user): Comment
18
    {
19
        return Comment::create([
20
            'article_id' => $data['article_id'],
21
            'user_id' => $user->id,
22
            'content' => $data['content']
23
        ]);
24
    }
25
}
26