GSTTaxModifierOptions   A
last analyzed

Complexity

Total Complexity 30

Size/Duplication

Total Lines 277
Duplicated Lines 15.88 %

Coupling/Cohesion

Components 2
Dependencies 11

Importance

Changes 0
Metric Value
wmc 30
lcom 2
cbo 11
dl 44
loc 277
rs 10
c 0
b 0
f 0

16 Methods

Rating   Name   Duplication   Size   Complexity  
A i18n_singular_name() 0 4 1
A i18n_plural_name() 0 4 1
A canCreate() 11 11 3
A canView() 11 11 3
A canEdit() 11 11 3
A canDelete() 11 11 3
A getCMSFields() 0 12 2
A Title() 0 4 1
A getTitle() 0 9 2
A populateDefaults() 0 17 4
A onBeforeWrite() 0 9 2
A EcomConfig() 0 4 1
A CountryName() 0 4 1
A getCountryName() 0 4 1
A PercentageNice() 0 4 1
A getPercentageNice() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/**
4
 *@author nicolaas [at] sunnysideup.co.nz
5
 *
6
 **/
7
8
class GSTTaxModifierOptions extends DataObject
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
9
{
10
11
    /**
12
     * standard SS variable
13
     * @var Array
14
     */
15
    private static $db = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $db is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
16
        "CountryCode" => "Varchar(3)",
17
        "Code" => "Varchar(12)",
18
        "Name" => "Varchar(175)",
19
        "LegalNotice" => "Varchar(255)",
20
        "InclusiveOrExclusive" => "Enum('Inclusive,Exclusive', 'Inclusive')",
21
        "Rate" => "Double",
22
        "DoesNotApplyToAllProducts" => "Boolean",
23
        "AppliesToAllCountries" => "Boolean"
24
    );
25
26
    /**
27
     * standard SS variable
28
     * @var Array
29
     */
30
    private static $defaults = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $defaults is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
31
        "InclusiveOrExclusive" => "Inclusive"
32
    );
33
34
    /**
35
     * standard SS variable
36
     * @var Array
37
     */
38
    private static $casting = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $casting is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
39
        "CountryName" => "Varchar",
40
        "PercentageNice" => "Varchar"
41
    );
42
43
    /**
44
     * standard SS variable
45
     * @var Array
46
     */
47
    private static $indexes = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $indexes is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
48
        "Code" => true
49
    );
50
51
    /**
52
     * standard SS variable
53
     * @var Array
54
     */
55
    private static $searchable_fields = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $searchable_fields is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
56
        "CountryCode" => "PartialMatchFilter",
57
        "Code" => "PartialMatchFilter",
58
        "Name" => "PartialMatchFilter"
59
    );
60
61
    /**
62
     * standard SS variable
63
     * @var Array
64
     */
65
    private static $field_labels = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $field_labels is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
66
        "CountryName" => "Country Name",
67
        "CountryCode" => "Country Code",
68
        "Code" => "Code for tax",
69
        "Name" => "Name for tax",
70
        "InclusiveOrExclusive" => "Inclusive/Exclusive",
71
        "LegalNotice" => "Here you can put your GST number or VAT registration number",
72
        "Rate" => "Rate (e.g. 0.125 = 12.5%)",
73
        "PercentageNice" => "Percentage",
74
        "DoesNotApplyToAllProducts" => "Added to individual products only"
75
    );
76
77
78
    /**
79
     * standard SS variable
80
     * @var Array
81
     */
82
    private static $summary_fields = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $summary_fields is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
83
        "CountryName" => 'Country',
84
        "Code" => 'Code',
85
        "Name" => 'Title',
86
        "InclusiveOrExclusive"  => 'Type',
87
        "PercentageNice" => 'Percentage'
88
    );
89
90
    /**
91
     * standard SS variable
92
     * @var String
93
     */
94
    private static $singular_name = "Tax Option";
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $singular_name is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
95
    public function i18n_singular_name()
96
    {
97
        return _t("GSTTaxModifierOptions.TAXOPTION", "Tax Option");
98
    }
99
100
101
    /**
102
     * standard SS variable
103
     * @var String
104
     */
105
    private static $plural_name = "Tax Options";
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $plural_name is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
106
    public function i18n_plural_name()
107
    {
108
        return _t("GSTTaxModifierOptions.TAXOPTIONS", "Tax Options");
109
    }
110
111
    /**
112
     * standard SS method
113
     * @param Member | NULL
114
     * @return Boolean
0 ignored issues
show
Documentation introduced by
Should the return type not be boolean|string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
115
     */
116 View Code Duplication
    public function canCreate($member = null)
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...
117
    {
118
        $extended = $this->extendedCan(__FUNCTION__, $member);
119
        if ($extended !== null) {
120
            return $extended;
121
        }
122
        if (Permission::checkMember($member, Config::inst()->get("EcommerceRole", "admin_permission_code"))) {
123
            return true;
124
        }
125
        return parent::canCreate($member);
126
    }
127
128
    /**
129
     * standard SS method
130
     * @param Member | NULL
131
     * @return Boolean
0 ignored issues
show
Documentation introduced by
Should the return type not be boolean|string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
132
     */
133 View Code Duplication
    public function canView($member = null)
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...
134
    {
135
        $extended = $this->extendedCan(__FUNCTION__, $member);
136
        if ($extended !== null) {
137
            return $extended;
138
        }
139
        if (Permission::checkMember($member, Config::inst()->get("EcommerceRole", "admin_permission_code"))) {
140
            return true;
141
        }
142
        return parent::canCreate($member);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (canCreate() instead of canView()). Are you sure this is correct? If so, you might want to change this to $this->canCreate().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
143
    }
144
145
    /**
146
     * standard SS method
147
     * @param Member | NULL
148
     * @return Boolean
0 ignored issues
show
Documentation introduced by
Should the return type not be boolean|string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
149
     */
150 View Code Duplication
    public function canEdit($member = null)
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...
151
    {
152
        $extended = $this->extendedCan(__FUNCTION__, $member);
153
        if ($extended !== null) {
154
            return $extended;
155
        }
156
        if (Permission::checkMember($member, Config::inst()->get("EcommerceRole", "admin_permission_code"))) {
157
            return true;
158
        }
159
        return parent::canEdit($member);
160
    }
161
162
    /**
163
     * standard SS method
164
     * @param Member | NULL
165
     * @return Boolean
0 ignored issues
show
Documentation introduced by
Should the return type not be boolean|string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
166
     */
167 View Code Duplication
    public function canDelete($member = null)
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...
168
    {
169
        $extended = $this->extendedCan(__FUNCTION__, $member);
170
        if ($extended !== null) {
171
            return $extended;
172
        }
173
        if (Permission::checkMember($member, Config::inst()->get("EcommerceRole", "admin_permission_code"))) {
174
            return true;
175
        }
176
        return parent::canDelete($member);
177
    }
178
179
    /**
180
     * standard SS method
181
     * @return FieldList
182
     */
183
    public function getCMSFields()
184
    {
185
        $fields = parent::getCMSFields();
186
        $fieldLabels = $this->Config()->get("field_labels");
187
        $fields->replaceField("CountryCode", new DropDownField("CountryCode", $fieldLabels["CountryCode"], EcommerceCountry::get_country_dropdown()));
188
        $InclusiveOrExclusive = "Inclusive";
0 ignored issues
show
Unused Code introduced by
$InclusiveOrExclusive 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...
189
        if ($this->EcomConfig()->ShopPricesAreTaxExclusive) {
190
            $InclusiveOrExclusive = "Exclusive";
0 ignored issues
show
Unused Code introduced by
$InclusiveOrExclusive 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...
191
        }
192
        $fields->replaceField("InclusiveOrExclusive", new ReadonlyField("InclusiveOrExclusive", "This tax is: ..., you can change this setting in the e-commerce configuration."));
193
        return $fields;
194
    }
195
196
    public function Title()
197
    {
198
        return $this->getTitle();
199
    }
200
    public function getTitle()
201
    {
202
        if ($this->AppliesToAllCountries) {
0 ignored issues
show
Documentation introduced by
The property AppliesToAllCountries does not exist on object<GSTTaxModifierOptions>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
203
            $country = _t("GSTTExModifierOption.WORLDWIDE", "world-wide");
204
        } else {
205
            $country = $this->CountryCode;
0 ignored issues
show
Documentation introduced by
The property CountryCode does not exist on object<GSTTaxModifierOptions>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
206
        }
207
        return $this->Name." ($country, ".number_format($this->Rate * 100, 2) . '%)';
0 ignored issues
show
Documentation introduced by
The property Name does not exist on object<GSTTaxModifierOptions>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Documentation introduced by
The property Rate does not exist on object<GSTTaxModifierOptions>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
208
    }
209
210
    /**
211
     * standard SS method
212
     */
213
    public function populateDefaults()
214
    {
215
        parent::populateDefaults();
216
        //can only run after first dev/build
217
        if (Security::database_is_ready()) {
218
            $controller = Controller::curr();
219
            if ($controller instanceof DatabaseAdmin) {
0 ignored issues
show
Unused Code introduced by
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
220
                //cant do this now.
221
            } else {
222
                if ($this->EcomConfig()->ShopPricesAreTaxExclusive) {
223
                    $this->InclusiveOrExclusive = "Exclusive";
0 ignored issues
show
Documentation introduced by
The property InclusiveOrExclusive does not exist on object<GSTTaxModifierOptions>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
224
                } else {
225
                    $this->InclusiveOrExclusive = "Inclusive";
0 ignored issues
show
Documentation introduced by
The property InclusiveOrExclusive does not exist on object<GSTTaxModifierOptions>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
226
                }
227
            }
228
        }
229
    }
230
231
    /**
232
     * standard SS method
233
     */
234
    public function onBeforeWrite()
235
    {
236
        parent::onBeforeWrite();
237
        if ($this->EcomConfig()->ShopPricesAreTaxExclusive) {
238
            $this->InclusiveOrExclusive = "Exclusive";
0 ignored issues
show
Documentation introduced by
The property InclusiveOrExclusive does not exist on object<GSTTaxModifierOptions>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
239
        } else {
240
            $this->InclusiveOrExclusive = "Inclusive";
0 ignored issues
show
Documentation introduced by
The property InclusiveOrExclusive does not exist on object<GSTTaxModifierOptions>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
241
        }
242
    }
243
244
    // /**
245
    //  * standard SS method
246
    //  */
247
    // public function requireDefaultRecords()
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
248
    // {
249
    //     parent::requireDefaultRecords();
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
250
    //     DB::query("
251
    //         UPDATE \"GSTTaxModifierOptions\"
252
    //         SET \"InclusiveOrExclusive\" = 'Inclusive'
253
    //         WHERE \"InclusiveOrExclusive\" <> 'Exclusive'"
254
    //     );
255
    // }
256
257
    /**
258
     * returns the instance of EcommerceDBConfig
259
     *
260
     * @return EcommerceDBConfig
261
     **/
262
    public function EcomConfig()
263
    {
264
        return EcommerceDBConfig::current_ecommerce_db_config();
265
    }
266
267
    public function CountryName()
268
    {
269
        return $this->getCountryName();
270
    }
271
    public function getCountryName()
272
    {
273
        return EcommerceCountry::find_title($this->CountryCode);
0 ignored issues
show
Documentation introduced by
The property CountryCode does not exist on object<GSTTaxModifierOptions>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
274
    }
275
276
    public function PercentageNice()
277
    {
278
        return $this->getPercentageNice();
279
    }
280
    public function getPercentageNice()
281
    {
282
        return DBField::create_field("Text", ($this->Rate * 100)."%");
0 ignored issues
show
Documentation introduced by
The property Rate does not exist on object<GSTTaxModifierOptions>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
283
    }
284
}
285