ThemeDetailViewModel::setAction()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
dl 6
loc 6
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
namespace App\ViewModels;
4
5 View Code Duplication
class ThemeDetailViewModel extends FormViewModel
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
6
{
7
    protected function setTitle()
8
    {
9
        $this->title = $this->model->exists
10
            ? "Edit Theme: {$this->model->name}"
11
            : 'Create Theme';
12
    }
13
14
    protected function setAction()
15
    {
16
        $this->action = $this->model->exists
17
            ? route('backend.themes.update', $this->model)
0 ignored issues
show
Documentation introduced by
$this->model is of type object<Illuminate\Database\Eloquent\Model>, but the function expects a 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...
18
            : route('backend.themes.store');
19
    }
20
21
    protected function setMethod()
22
    {
23
        $this->method = $this->model->exists
24
            ? 'PUT'
25
            : 'POST';
26
    }
27
}
28