CommentObserver::created()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 2
b 0
f 1
nc 1
nop 1
dl 0
loc 3
rs 10
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