Passed
Push — master ( 1d6d9a...2a90e7 )
by Ron
02:47 queued 12s
created

GetTechTipComments   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 88.89%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 22
ccs 8
cts 9
cp 0.8889
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 6 1
A canIEdit() 0 11 3
1
<?php
2
3
namespace App\Domains\TechTips;
4
5
use Illuminate\Support\Facades\Log;
6
use Illuminate\Support\Facades\Auth;
7
8
use App\TechTipComments;
9
10
class GetTechTipComments
11
{
12 2
    public function execute($tipID)
13
    {
14 2
        $comments = TechTipComments::where('tip_id', $tipID)->with('user')->get();
15
16 2
        Log::debug('Tech Tip Comments for Tip ID '.$tipID.' retrieved.  Data Gathered - ', array($comments));
17 2
        return $this->canIEdit($comments);
18
    }
19
20
    //  Determine if the authorized user can edit or delete the comments gathered
21 2
    protected function canIEdit($commentList)
22
    {
23 2
        foreach($commentList as $comment)
24
        {
25 2
            if(Auth::user()->user_id == $comment->user->user_id)
26
            {
27
                $comment->edit = true;
28
            }
29
        }
30
31 2
        return $commentList;
32
    }
33
}
34