HasImagesPresentable   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A cover() 0 8 3
1
<?php
2
3
namespace App\Traits;
4
5
trait HasImagesPresentable
6
{
7
    /**
8
     * Get image where type is cover.
9
     *
10
     * @param $size
11
     * @param $default
12
     * @return string
13
     */
14
    public function cover($size = null, $default = null, $order = 'asc')
15
    {
16
        $image = $this->model->images()->ranked($order)->cover()->first();
0 ignored issues
show
Bug introduced by
The property model does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
17
18
        $default = !is_null($default) ? $default : '';
19
20
        return $image ? $image->present()->image($size) : $default;
21
    }
22
}