for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Http\Controllers\Customers;
use JeroenDesloovere\VCard\VCard;
use App\Models\Customer;
use App\Models\CustomerContact;
use App\Http\Controllers\Controller;
use App\Events\Customers\CustomerContactDownloadedEvent;
class DownloadContactController extends Controller
{
/**
* Download a customer contact in v-card format
*/
public function __invoke($contID)
$contact = CustomerContact::findOrFail($contID);
$customer = Customer::find($contact->cust_id);
$name = explode(' ', $contact->name);
// Build the VCard
$vcard = new VCard();
$vcard->addName(isset($name[1]) ? $name[1] : null, $name[0]);
$vcard->addCompany($customer->name);
$vcard->addAddress(null, null, $customer->address, $customer->city, $customer->state, $customer->zip, null);
// Add phone numbers to the VCard
foreach($contact->CustomerContactPhone as $phone)
$number = $phone->readable;
if($phone->extension)
$number .= ', '.$phone->extension;
}
$vcard->addPhoneNumber($number, $phone->type_name);
event(new CustomerContactDownloadedEvent($customer, $contact));
return $vcard->download();
$vcard->download()
JeroenDesloovere\VCard\VCard::download()
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.
getObject()
The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.
This check looks for function or method calls that always return null and whose return value is used.
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.