AssetFormFactoryExtension   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 6
dl 0
loc 12
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A updateFormFields() 0 7 5
1
<?php
2
3
namespace Dynamic\Salsify\ORM;
4
5
use SilverStripe\Assets\Image;
6
use SilverStripe\Core\Extension;
7
use SilverStripe\Forms\FieldList;
8
use SilverStripe\Forms\ReadonlyField;
9
10
/**
11
 * Class AssetFormFactoryExtension
12
 * @package Dynamic\Salsify\ORM
13
 *
14
 * @property-read \SilverStripe\AssetAdmin\Forms\FileFormFactory $owner
15
 */
16
class AssetFormFactoryExtension extends Extension
17
{
18
    /**
19
     * @param \SilverStripe\Forms\FieldList $fields
20
     */
21
    public function updateFormFields(FieldList $fields, $controller, $formName, $context)
0 ignored issues
show
Unused Code introduced by
The parameter $formName is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

21
    public function updateFormFields(FieldList $fields, $controller, /** @scrutinizer ignore-unused */ $formName, $context)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $controller is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

21
    public function updateFormFields(FieldList $fields, /** @scrutinizer ignore-unused */ $controller, $formName, $context)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
22
    {
23
        $record = isset($context['Record']) ? $context['Record'] : null;
24
        if ($record && $record->SalsifyID) {
25
            $fields->insertAfter('LastEdited', ReadonlyField::create('SalsifyID', 'Salsify ID'));
26
            if ($record instanceof Image) {
27
                $fields->insertAfter('SalsifyID', ReadonlyField::create('Transformation', 'Salsify Transformation'));
28
            }
29
        }
30
    }
31
}
32