CommentService   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 24
ccs 7
cts 7
cp 1
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A createComment() 0 12 1
1
<?php
2
3
namespace App\Services;
4
5
use App\Http\Requests\CommentStoreRequest;
6
use App\Models\Comment;
7
8
class CommentService
9
{
10
11
    /**
12
     * Create a comment
13
     *
14
     * @param \App\Http\Requests\CommentStoreRequest $data
15
     *
16
     * @param mixed $entity
17
     *
18
     * @return \App\Models\Comment
19
     */
20
    public function createComment(CommentStoreRequest $data, object $entity): Comment
21 1
    {
22
        $comment = new Comment();
23 1
        $comment->body = $data['body'];
24 1
        $comment->name = $data['name'];
25 1
        $comment->email = $data['email'];
26 1
27
        $entity->comments()->save($comment);
28 1
29
        //then publish comment
30 1
31
        return $comment;
32
    }
33
}