CountryPrice_ProductGroup::updateCMSFields()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
class CountryPrice_ProductGroup extends DataExtension
4
{
5
    private static $db = array(
6
        'NoProductsInYourCountry' => 'HTMLText'
7
    );
8
    
9
    private static $casting = array(
10
        'NoProductsInYourCountryMessage' => 'HTMLText'
11
    );
12
13
    /**
14
     * Update Fields
15
     * @return FieldList
16
     */
17 View Code Duplication
    public function updateCMSFields(FieldList $fields)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
18
    {
19
        $fields->addFieldsToTab(
20
            'Root.Countries',
21
            array(
22
                $field = HTMLEditorField::create('NoProductsInYourCountry', 'No product message')
23
            )
24
        );
25
        $field->setRows(7)->setDescription('Shown when there are no products for sale in the customer\'s country.');
26
        return $fields;
27
    }
28
29
    public function getNoProductsInYourCountryMessage()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
30
    {
31
        if ($this->owner->NoProductsInYourCountry) {
32
            $message = $this->owner->NoProductsInYourCountry;
0 ignored issues
show
Bug introduced by
The property NoProductsInYourCountry does not seem to exist in SS_Object.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
33
        } else {
34
            $message = $this->owner->EcomConfig()->NoProductsInYourCountry;
0 ignored issues
show
Bug introduced by
The method EcomConfig() does not exist on SS_Object. Did you maybe mean config()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
35
        }
36
        return $message;
37
    }
38
}
39