Completed
Push — master ( 194cbe...2ee496 )
by Yaro
05:39 queued 19s
created

DeleteAction   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 26.67%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 34
rs 10
c 0
b 0
f 0
ccs 4
cts 15
cp 0.2667

3 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 10 2
A isAllowed() 0 9 3
A shouldRender() 0 8 2
1
<?php
2
3
namespace Yaro\Jarboe\Table\Actions;
4
5
class DeleteAction extends AbstractAction
6
{
7
    protected $ident = 'delete';
8
9
    public function render($model = null)
10
    {
11
        $crud = $this->crud();
12
        $isVisible = parent::shouldRender($model);
1 ignored issue
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (shouldRender() instead of render()). Are you sure this is correct? If so, you might want to change this to $this->shouldRender().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
13
        if ($crud->isSoftDeleteEnabled()) {
14
            $isVisible = !$model->trashed();
15
        }
16
17
        return view('jarboe::crud.actions.delete', compact('crud', 'model', 'isVisible'));
18
    }
19
20 1
    public function isAllowed($model = null)
21
    {
22 1
        $isAllowed = parent::isAllowed($model);
23 1
        if ($this->crud()->isSoftDeleteEnabled()) {
24 1
            return $isAllowed && !$model->trashed();
25
        }
26
27
        return $isAllowed;
28
    }
29
30
    public function shouldRender($model = null)
31
    {
32
        if ($this->crud()->isSoftDeleteEnabled()) {
33
            return true;
34
        }
35
36
        return parent::shouldRender($model);
37
    }
38
}
39