ElementalGridFieldDeleteAction   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 6
dl 0
loc 14
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getColumnContent() 0 11 3
1
<?php
2
3
namespace DNADesign\ElementalVirtual\Forms;
4
5
use SilverStripe\Forms\GridField\GridFieldDeleteAction;
6
use SilverStripe\Forms\GridField\GridField_FormAction;
7
8
/**
9
 * @package elemental
10
 */
11
class ElementalGridFieldDeleteAction extends GridFieldDeleteAction
12
{
13
14
    public function getColumnContent($gridField, $record, $columnName)
15
    {
16
        if (!$record->canDelete()) {
17
            return;
18
        }
19
20
        if ($record->VirtualClones()->count() > 0) {
21
            return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the return type mandated by SilverStripe\Forms\GridF...der::getColumnContent() of string.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
22
        }
23
24
        return parent::getColumnContent($gridField, $record, $columnName);
25
    }
26
}
27