Passed
Pull Request — master (#57)
by Matthew
02:46
created

LocationExtension::MarkerIcon()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 9
ccs 0
cts 6
cp 0
crap 6
rs 10
1
<?php
2
3
namespace Dynamic\Locator\React\Extensions;
4
5
use Dynamic\Locator\Location;
6
use SilverStripe\AssetAdmin\Forms\UploadField;
7
use SilverStripe\Assets\Image;
8
use SilverStripe\Forms\FieldList;
9
use SilverStripe\ORM\DataExtension;
10
11
/**
12
 * Class LocationExtension
13
 * @package Dynamic\Locator\React\Extensions
14
 *
15
 * @property int MarkerIconImageID
16
 * @method Image MarkerIconImage()
17
 *
18
 * @property-read Location|LocationExtension $owner
19
 */
20
class LocationExtension extends DataExtension
21
{
22
23
    /**
24
     * @var array
25
     */
26
    private static $has_one = [
0 ignored issues
show
introduced by
The private property $has_one is not used, and could be removed.
Loading history...
27
        'MarkerIconImage' => Image::class,
28
    ];
29
30
    /**
31
     * @var array
32
     */
33
    private static $owns = [
0 ignored issues
show
introduced by
The private property $owns is not used, and could be removed.
Loading history...
34
        'MarkerIconImage',
35
    ];
36
37
    public function updateCMSFields(FieldList $fields)
38
    {
39
        parent::updateCMSFields($fields);
40
41
        $fields->insertAfter(
42
            'Fax',
43
            UploadField::create('MarkerIconImage', 'MarkerIcon')
44
        );
45
    }
46
47
    /**
48
     * @return Image|string
49
     */
50
    public function MarkerIcon()
51
    {
52
        if ($this->owner->MarkerIconImageID) {
53
            return $this->owner->MarkerIconImage()->getURL();
54
        }
55
56
        $imageURL = '';
57
        $this->owner->extend('updateMarkerIconURL', $imageURL);
0 ignored issues
show
Bug introduced by
The method extend() does not exist on Dynamic\Locator\React\Extensions\LocationExtension. ( Ignorable by Annotation )

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

57
        $this->owner->/** @scrutinizer ignore-call */ 
58
                      extend('updateMarkerIconURL', $imageURL);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
58
        return $imageURL;
59
    }
60
}
61