ContactController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 8

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 22
rs 10
wmc 2
lcom 0
cbo 8

2 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 6 1
A handleResponse() 0 12 1
1
<?php
2
3
namespace App\Http\Controllers\Front;
4
5
use Mail;
6
use App\Models\FormResponse;
7
use App\Mail\ContactFormSubmitted;
8
use App\Http\Controllers\Controller;
9
use App\Models\Enums\SpecialArticle;
10
use App\Http\Requests\Front\FormResponseRequest;
11
12
class ContactController extends Controller
13
{
14
    public function index()
15
    {
16
        $article = article(SpecialArticle::CONTACT);
17
18
        return view('front.contact.index', compact('article'));
19
    }
20
21
    public function handleResponse(FormResponseRequest $request)
22
    {
23
        $formResponse = FormResponse::create($request->except(['g-recaptcha-response']));
24
25
        Mail::send(new ContactFormSubmitted($formResponse));
0 ignored issues
show
Documentation introduced by
new \App\Mail\ContactFormSubmitted($formResponse) is of type object<App\Mail\ContactFormSubmitted>, but the function expects a string|array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
26
27
        activity()->log("{$formResponse->email} vulde het contactformulier in");
0 ignored issues
show
Documentation introduced by
The property email does not exist on object<App\Models\FormResponse>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
28
29
        flash()->success(fragment('contact.response'));
30
31
        return redirect()->action('Front\ContactController@index');
32
    }
33
}
34