Completed
Push — master ( 991aa3...ce6ba6 )
by
unknown
22s
created

ColorPickerField::getSourceValues()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace CWP\AgencyExtensions\Forms;
4
5
use SilverStripe\Forms\SingleSelectField;
6
7
class ColorPickerField extends SingleSelectField
8
{
9
    public function __construct($name, $title = null, $source = array(), $value = null)
10
    {
11
        parent::__construct($name, $title, $source, $value);
12
13
        $this->addExtraClass('color-picker-field');
14
    }
15
16
    public function getSchemaDataDefaults()
17
    {
18
        $schemaData = parent::getSchemaDataDefaults();
19
20
        $schemaData['source'] = $this->getSource();
21
        $schemaData['name'] = $this->getName();
22
        $schemaData['value'] = $this->Value();
23
24
        return $schemaData;
25
    }
26
27
    public function getSourceValues()
28
    {
29
        return array_merge([''], array_map(function ($color) {
30
            return $color['CSSClass'];
31
        }, $this->getSource()));
0 ignored issues
show
Bug introduced by
It seems like $this->getSource() can also be of type ArrayAccess; however, parameter $arr1 of array_map() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

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

31
        }, /** @scrutinizer ignore-type */ $this->getSource()));
Loading history...
32
    }
33
}
34