Passed
Push — dev5a ( a81ef3...276986 )
by Ron
07:39
created

CustomerContactsController::show()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 2
b 0
f 0
1
<?php
2
3
namespace App\Http\Controllers\Customers;
4
5
use App\Domains\Customers\GetCustomerContacts;
6
use App\Domains\Customers\SetCustomerContacts;
7
use App\Domains\PhoneNumbers\GetPhoneNumberTypes;
8
use App\Http\Controllers\Controller;
9
use App\Http\Requests\Customers\CustomerContactRequest;
10
use Illuminate\Http\Request;
11
use Illuminate\Support\Facades\Auth;
12
use Illuminate\Support\Facades\Log;
13
14
class CustomerContactsController extends Controller
15
{
16
    //  Get the types of phone numbers that can be assigned to a contact
17 2
    public function index()
18
    {
19 2
        return (new GetPhoneNumberTypes)->execute();
20
    }
21
22
    //  Store a new customer contact
23 2
    public function store(CustomerContactRequest $request)
24
    {
25
26 2
        (new SetCustomerContacts)->createNewContact($request, $request->cust_id);
27
28 2
        return response()->json(['success' => true]);
29
    }
30
31
    //  Pull all contacts for the customer
32 2
    public function show($id)
33
    {
34 2
        return (new GetCustomerContacts)->execute($id);
35
    }
36
37
    //  Downlod a specific contact as a V-Card
38
    public function download($id)
39
    {
40
        $contact = (new GetCustomerContacts)->getOneContact($id);
41
        return $contact->download();
1 ignored issue
show
Bug introduced by
Are you sure the usage of $contact->download() targeting JeroenDesloovere\VCard\VCard::download() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
42
    }
43
44
    //  Update an existing contact
45 2
    public function update(CustomerContactRequest $request, $id)
46
    {
47 2
        (new SetCustomerContacts)->updateExistingContact($request, $id);
48 2
        return response()->json(['success' => true]);
49
    }
50
51
    //  Delete a contact
52 2
    public function destroy($id)
53
    {
54 2
        (new SetCustomerContacts)->deleteContact($id);
55 2
        Log::notice('Customer Contact ID '.$id.' deleted by '.Auth::user()->full_name);
56 2
        return response()->json(['success' => true]);
57
    }
58
}
59