Link   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 38
ccs 0
cts 25
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getUrl() 0 8 2
A setUrl() 0 6 1
A getEditUrl() 0 7 1
A getValue() 0 7 1
1
<?php
2
3
namespace Sco\Admin\Display\Columns;
4
5
use Sco\Admin\Facades\Admin;
6
7
class Link extends Column
8
{
9
    protected $type = 'link';
10
11
    protected $url;
12
13
    public function getUrl()
14
    {
15
        if ($this->url) {
16
            return $this->url;
17
        }
18
19
        return $this->getEditUrl();
20
    }
21
22
    public function setUrl($value)
23
    {
24
        $this->url = $value;
25
26
        return $this;
27
    }
28
29
    protected function getEditUrl()
30
    {
31
        $model = Admin::component()->getName();
32
        $id = $this->getModel()->getKey();
33
34
        return route('admin.model.edit', [$model, $id], false);
35
    }
36
37
    public function getValue()
38
    {
39
        return [
40
            'url'   => $this->getUrl(),
41
            'title' => parent::getValue(),
42
        ];
43
    }
44
}
45