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

GetTechTipComments::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 1
rs 10
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