PageItemDisplay   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
c 0
b 0
f 0
dl 0
loc 37
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getModalIdString() 0 7 2
A render() 0 8 1
A __construct() 0 4 1
1
<?php
2
3
namespace App\View\Components;
4
5
use Illuminate\View\Component;
6
use Cohensive\OEmbed\Facades\OEmbed;
7
8
9
class PageItemDisplay extends Component
10
{
11
    public $link;
12
    public $id = '';
13
    /**
14
     * Create a new component instance.
15
     *
16
     * @return void
17
     */
18
    public function __construct($link)
19
    {
20
        // $this->title = $title;
21
         $this->link = $link;
22
    }
23
24
    /**
25
     * Get the view / contents that represent the component.
26
     *
27
     * @return \Illuminate\Contracts\View\View|\Closure|string
28
     */
29
    public function render()
30
    {
31
32
        $params = json_decode($this->link->type_params);
33
34
35
36
        return view('components.pageitems.'.$this->link->typename.'-display', ['link' => $this->link, 'params' => $params]);
37
    }
38
39
    public function getModalIdString(): string
40
    {
41
        if ($this->id != '') {
42
            return $this->id;
43
        }
44
45
        return "model" . rand(1111, 9999);
46
    }
47
}
48