CommentObserver   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 4
Bugs 1 Features 1
Metric Value
eloc 4
c 4
b 1
f 1
dl 0
loc 21
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A created() 0 3 1
A creating() 0 4 2
1
<?php
2
3
namespace FaithGen\SDK\Observers;
4
5
use FaithGen\SDK\Events\CommentCreated;
6
use FaithGen\SDK\Models\Comment;
7
use FaithGen\SDK\Models\User;
8
use Illuminate\Support\Str;
9
10
class CommentObserver
11
{
12
    /**
13
     * Handle the comment "created" event.
14
     *
15
     * @param  Comment  $comment
16
     *
17
     * @return void
18
     */
19
    public function created(Comment $comment)
20
    {
21
        event(new CommentCreated($comment));
22
    }
23
24
    /**
25
     * @param Comment $comment
26
     */
27
    public function creating(Comment $comment)
28
    {
29
        if (Str::of($comment->creatable_type)->contains('User')) {
30
            $comment->creatable_type = User::class;
31
        }
32
    }
33
}
34