Test Setup Failed
Push — dev6 ( 81193f...01d104 )
by Ron
22:34
created

DownloadContactController::__invoke()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 24
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 24
rs 9.8333
cc 4
nc 3
nop 1
1
<?php
2
3
namespace App\Http\Controllers\Customers;
4
5
use JeroenDesloovere\VCard\VCard;
6
7
use App\Models\Customer;
8
use App\Models\CustomerContact;
9
use App\Http\Controllers\Controller;
10
11
class DownloadContactController extends Controller
12
{
13
    /**
14
     *  Download the contact as a VCard
15
     */
16
    public function __invoke($contID)
17
    {
18
        $contact  = CustomerContact::findOrFail($contID);
19
        $customer = Customer::find($contact->cust_id);
20
        $name     = explode(' ', $contact->name);
21
22
        //  Build the VCard
23
        $vcard = new VCard();
24
        $vcard->addName(isset($name[1]) ? $name[1] : null, $name[0]);
25
        $vcard->addCompany($customer->name);
26
        $vcard->addAddress(null, null, $customer->address, $customer->city, $customer->state, $customer->zip, null);
27
28
        //  Add phone numbers to the VCard
29
        foreach($contact->CustomerContactPhone as $phone)
30
        {
31
            $number = $phone->readable;
32
            if($phone->extension)
33
            {
34
                $number .= ', '.$phone->extension;
35
            }
36
            $vcard->addPhoneNumber($number, $phone->type_name);
37
        }
38
39
        return $vcard->download();
0 ignored issues
show
Bug introduced by
Are you sure the usage of $vcard->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...
40
    }
41
}
42