Completed
Pull Request — master (#306)
by Will
01:42
created

FileHistoryFormFactory::getFormActions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 1
eloc 5
nc 1
nop 3
1
<?php
2
3
namespace SilverStripe\AssetAdmin\Forms;
4
5
use SilverStripe\Assets\File;
6
use SilverStripe\Control\Controller;
7
use SilverStripe\Forms\FieldList;
8
use SilverStripe\Forms\LiteralField;
9
use SilverStripe\Forms\ReadonlyField;
10
11
class FileHistoryFormFactory extends FileFormFactory
12
{
13
14
    protected function getFormFields(Controller $controller, $name, $context = [])
15
    {
16
        $record = $context['Record'];
17
18
        $fields = new FieldList(
19
            LiteralField::create('Thumbnail', $this->getIconMarkup($record)),
20
            LiteralField::create('FileSpecs', $this->getSpecsMarkup($record)),
21
            ReadonlyField::create("Title", File::singleton()->fieldLabel('Title')),
22
            ReadonlyField::create('Name', File::singleton()->fieldLabel('Filename')),
23
            ReadonlyField::create("Path", _t('AssetTableField.PATH', 'Path'), $this->getPath($record))
24
        );
25
26
        $this->invokeWithExtensions('updateFormFields', $fields, $controller, $name, $context);
27
28
        return $fields;
29
    }
30
31
32
    protected function getFormActions(Controller $controller, $name, $context = [])
33
    {
34
        $record = $context['Record'];
0 ignored issues
show
Unused Code introduced by
$record is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
35
36
        $actions = new FieldList();
37
38
        // Update
39
        $this->invokeWithExtensions('updateFormActions', $actions, $controller, $name, $context);
40
41
        return $actions;
42
    }
43
}
44