This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * @author nicolaas [at] sunnysideup.co.nz |
||
5 | * Precondition : There can only be 1 default option |
||
6 | */ |
||
7 | class PickUpOrDeliveryModifierOptions extends DataObject |
||
0 ignored issues
–
show
|
|||
8 | { |
||
9 | private static $db = array( |
||
0 ignored issues
–
show
|
|||
10 | "IsDefault" => "Boolean", |
||
11 | "Code" => "Varchar(25)", |
||
12 | "Name" => "Varchar(175)", |
||
13 | "Percentage" => "Double", |
||
14 | "FixedCost" => "Currency", |
||
15 | "WeightMultiplier" => "Double", |
||
16 | "WeightUnit" => "Double", |
||
17 | "MinimumDeliveryCharge" => "Currency", |
||
18 | "MaximumDeliveryCharge" => "Currency", |
||
19 | "MinimumOrderAmountForZeroRate" => "Currency", |
||
20 | "FreeShippingUpToThisOrderAmount" => "Currency", |
||
21 | "Sort" => "Int" |
||
22 | ); |
||
23 | |||
24 | private static $has_one = array( |
||
0 ignored issues
–
show
|
|||
25 | "ExplanationPage" => "SiteTree" |
||
26 | ); |
||
27 | |||
28 | private static $many_many = array( |
||
0 ignored issues
–
show
|
|||
29 | "AvailableInCountries" => "EcommerceCountry", |
||
30 | "AvailableInRegions" => "EcommerceRegion", |
||
31 | "WeightBrackets" => "PickUpOrDeliveryModifierOptions_WeightBracket", |
||
32 | "SubtotalBrackets" => "PickUpOrDeliveryModifierOptions_SubTotalBracket", |
||
33 | "ExcludedProducts" => 'Product' |
||
34 | ); |
||
35 | |||
36 | private static $belongs_many_many = array( |
||
0 ignored issues
–
show
|
|||
37 | "ExcludeFromCountries" => "EcommerceCountry", |
||
38 | ); |
||
39 | |||
40 | private static $indexes = array( |
||
0 ignored issues
–
show
|
|||
41 | "IsDefault" => true, |
||
42 | "Code" => true |
||
43 | ); |
||
44 | |||
45 | private static $searchable_fields = array( |
||
0 ignored issues
–
show
|
|||
46 | "Code", |
||
47 | "Name" => "PartialMatchFilter" |
||
48 | ); |
||
49 | |||
50 | private static $field_labels = array( |
||
0 ignored issues
–
show
|
|||
51 | "IsDefaultNice" => "Default option", |
||
52 | "IsDefault" => "Default delivery option?", |
||
53 | "Code" => "Code", |
||
54 | "Name" => "Long Name", |
||
55 | "Percentage" => "Percentage", |
||
56 | "FixedCost" => "Fixed cost", |
||
57 | "WeightMultiplier" => "Cost per kilogram", |
||
58 | "WeightUnit" => "Weight unit in kilograms", |
||
59 | "MinimumDeliveryCharge" => "Minimum delivery charge", |
||
60 | "MaximumDeliveryCharge" => "Maximum delivery charge", |
||
61 | "MinimumOrderAmountForZeroRate" => "Minimum for 0 rate", |
||
62 | "FreeShippingUpToThisOrderAmount" => "Free shipping up to", |
||
63 | "Sort" => "Sort Index", |
||
64 | "ListOfCountries" => "Applicable Countries" |
||
65 | ); |
||
66 | |||
67 | private static $field_labels_right = array( |
||
0 ignored issues
–
show
|
|||
68 | "Percentage" => "number between 0 = 0% and 1 = 100% (e.g. 0.05 would add 5 cents to every dollar ordered).", |
||
69 | "FixedCost" => "e.g. entering 10 will add a fixed 10 dollars (or whatever currency is being used) delivery fee.", |
||
70 | "WeightMultiplier" => "it multiplies the total weight of the total order with this number to work out charge for delivery. NOTE: you can also setup weight brackets (e.g. from 0 - 1kg = $123, from 1kg - 2kg = $456).", |
||
71 | "WeightUnit" => "if you enter 0.1 here, the price will go up with every 100 grams of total order weight.", |
||
72 | "MinimumDeliveryCharge" => "minimum delivery charge.", |
||
73 | "MaximumDeliveryCharge" => "maximum delivery charge.", |
||
74 | "MinimumOrderAmountForZeroRate" => "if this option is selected and the total order is over the amounted entered above then delivery is free.", |
||
75 | "FreeShippingUpToThisOrderAmount" => "if this option is selected and the total order is less than the amount entered above then delivery is free. This is for situations where a small order would have a large delivery cost.", |
||
76 | "Sort" => "lower numbers show first." |
||
77 | ); |
||
78 | |||
79 | private static $defaults = array( |
||
0 ignored issues
–
show
|
|||
80 | "Code" => "homedelivery", |
||
81 | "Name" => "Home Delivery", |
||
82 | "Percentage" => 0, |
||
83 | "FixedCost" => 0, |
||
84 | "WeightMultiplier" => 0, |
||
85 | "WeightUnit" => 1, |
||
86 | "MinimumDeliveryCharge" => 0, |
||
87 | "MaximumDeliveryCharge" => 0, |
||
88 | "MinimumOrderAmountForZeroRate" => 0, |
||
89 | "Sort" => 0 |
||
90 | ); |
||
91 | |||
92 | private static $summary_fields = array( |
||
0 ignored issues
–
show
|
|||
93 | "IsDefaultNice", |
||
94 | "Code", |
||
95 | "Name", |
||
96 | 'ListOfCountries' |
||
97 | ); |
||
98 | |||
99 | private static $casting = array( |
||
0 ignored issues
–
show
|
|||
100 | "IsDefaultNice" => "Varchar", |
||
101 | "ListOfCountries" => "Varchar" |
||
102 | ); |
||
103 | |||
104 | private static $singular_name = "Delivery / Pick-up Option"; |
||
0 ignored issues
–
show
|
|||
105 | public function i18n_singular_name() |
||
106 | { |
||
107 | return _t("PickUpOrDeliveryModifierOptions.DELIVERYOPTION", "Delivery / Pick-up Option"); |
||
108 | } |
||
109 | |||
110 | private static $plural_name = "Delivery / Pick-up Options"; |
||
0 ignored issues
–
show
|
|||
111 | public function i18n_plural_name() |
||
112 | { |
||
113 | return _t("PickUpOrDeliveryModifierOptions.DELIVERYOPTION", "Delivery / Pick-up Options"); |
||
114 | } |
||
115 | |||
116 | private static $default_sort = "\"IsDefault\" DESC, \"Sort\" ASC, \"Name\" ASC"; |
||
0 ignored issues
–
show
|
|||
117 | |||
118 | /** |
||
119 | * returns the default PickUpOrDeliveryModifierOptions object |
||
120 | * if none exists, it creates one. |
||
121 | * @return PickUpOrDeliveryModifierOptions |
||
122 | */ |
||
123 | public static function default_object() |
||
124 | { |
||
125 | if ($obj = PickUpOrDeliveryModifierOptions::get()->filter(array("IsDefault" => "1"))->First()) { |
||
0 ignored issues
–
show
This
if statement is empty and can be removed.
This check looks for the bodies of These 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...
|
|||
126 | //do nothing |
||
127 | } else { |
||
128 | $obj = new PickUpOrDeliveryModifierOptions(); |
||
129 | $obj->IsDefault = 1; |
||
0 ignored issues
–
show
The property
IsDefault does not exist on object<PickUpOrDeliveryModifierOptions> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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...
|
|||
130 | $obj->write(); |
||
131 | } |
||
132 | return $obj; |
||
133 | } |
||
134 | |||
135 | /** |
||
136 | * returns an array of countries available for all options combined. |
||
137 | * like this |
||
138 | * array( |
||
139 | * "NZ" => "NZ" |
||
140 | * ); |
||
141 | * @return Array |
||
142 | */ |
||
143 | public static function get_all_as_country_array() |
||
144 | { |
||
145 | $array = array(); |
||
146 | $options = PickUpOrDeliveryModifierOptions::get(); |
||
147 | if ($options->count()) { |
||
148 | foreach ($options as $option) { |
||
149 | if ($countries = $option->AvailableInCountries()) { |
||
150 | if ($countries->count()) { |
||
151 | foreach ($countries as $country) { |
||
152 | $array[$option->Code][] = $country->Code; |
||
153 | } |
||
154 | } |
||
155 | } |
||
156 | } |
||
157 | } |
||
158 | return $array; |
||
159 | } |
||
160 | |||
161 | /** |
||
162 | * @return String |
||
163 | */ |
||
164 | public function IsDefaultNice() |
||
165 | { |
||
166 | return $this->getIsDefaultNice(); |
||
167 | } |
||
168 | public function getIsDefaultNice() |
||
169 | { |
||
170 | return $this->IsDefault ? "yes" : "no"; |
||
0 ignored issues
–
show
The property
IsDefault does not exist on object<PickUpOrDeliveryModifierOptions> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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...
|
|||
171 | } |
||
172 | |||
173 | |||
174 | /** |
||
175 | * standard SS method |
||
176 | * @param Member | NULL |
||
177 | * @return Boolean |
||
0 ignored issues
–
show
|
|||
178 | */ |
||
179 | View Code Duplication | public function canCreate($member = null) |
|
0 ignored issues
–
show
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...
|
|||
180 | { |
||
181 | if (Permission::checkMember($member, Config::inst()->get("EcommerceRole", "admin_permission_code"))) { |
||
182 | return true; |
||
183 | } |
||
184 | return parent::canCreate($member); |
||
185 | } |
||
186 | |||
187 | /** |
||
188 | * standard SS method |
||
189 | * @param Member | NULL |
||
190 | * @return Boolean |
||
0 ignored issues
–
show
|
|||
191 | */ |
||
192 | View Code Duplication | public function canView($member = null) |
|
0 ignored issues
–
show
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...
|
|||
193 | { |
||
194 | if (Permission::checkMember($member, Config::inst()->get("EcommerceRole", "admin_permission_code"))) { |
||
195 | return true; |
||
196 | } |
||
197 | return parent::canCreate($member); |
||
0 ignored issues
–
show
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
Loading history...
|
|||
198 | } |
||
199 | |||
200 | /** |
||
201 | * standard SS method |
||
202 | * @param Member | NULL |
||
203 | * @return Boolean |
||
0 ignored issues
–
show
|
|||
204 | */ |
||
205 | View Code Duplication | public function canEdit($member = null) |
|
0 ignored issues
–
show
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...
|
|||
206 | { |
||
207 | if (Permission::checkMember($member, Config::inst()->get("EcommerceRole", "admin_permission_code"))) { |
||
208 | return true; |
||
209 | } |
||
210 | return parent::canEdit($member); |
||
211 | } |
||
212 | |||
213 | /** |
||
214 | * standard SS method |
||
215 | * @param Member | NULL |
||
216 | * @return Boolean |
||
0 ignored issues
–
show
|
|||
217 | */ |
||
218 | View Code Duplication | public function canDelete($member = null) |
|
0 ignored issues
–
show
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...
|
|||
219 | { |
||
220 | if (Permission::checkMember($member, Config::inst()->get("EcommerceRole", "admin_permission_code"))) { |
||
221 | return true; |
||
222 | } |
||
223 | return parent::canDelete($member); |
||
224 | } |
||
225 | |||
226 | /** |
||
227 | * standard SS method |
||
228 | */ |
||
229 | public function getCMSFields() |
||
230 | { |
||
231 | $fields = parent::getCMSFields(); |
||
232 | $availableInCountriesField = $this->createGridField("EcommerceCountry", "AvailableInCountries", "Available in"); |
||
233 | if ($availableInCountriesField) { |
||
234 | $fields->replaceField("AvailableInCountries", $availableInCountriesField); |
||
235 | } |
||
236 | $excludeFromCountriesField = $this->createGridField("EcommerceCountry", "ExcludeFromCountries", "Excluded from"); |
||
237 | if ($excludeFromCountriesField) { |
||
238 | $fields->replaceField("ExcludeFromCountries", $excludeFromCountriesField); |
||
239 | } |
||
240 | $regionField = $this->createGridField("EcommerceRegion", "AvailableInRegions", "Regions"); |
||
241 | if ($regionField) { |
||
242 | $fields->replaceField("AvailableInRegions", $regionField); |
||
243 | } |
||
244 | if (class_exists("DataObjectSorterController") && $this->hasExtension("DataObjectSorterController")) { |
||
245 | $fields->addFieldToTab("Root.Sort", new LiteralField("InvitationToSort", $this->dataObjectSorterPopupLink())); |
||
0 ignored issues
–
show
The method
dataObjectSorterPopupLink does not exist on object<PickUpOrDeliveryModifierOptions> ? Since you implemented __call , maybe consider adding a @method annotation.
If you implement This is often the case, when class ParentClass {
private $data = array();
public function __call($method, array $args) {
if (0 === strpos($method, 'get')) {
return $this->data[strtolower(substr($method, 3))];
}
throw new \LogicException(sprintf('Unsupported method: %s', $method));
}
}
/**
* If this class knows which fields exist, you can specify the methods here:
*
* @method string getName()
*/
class SomeClass extends ParentClass { }
Loading history...
|
|||
246 | } |
||
247 | $fields->replaceField("ExplanationPageID", new OptionalTreeDropdownField($name = "ExplanationPageID", $title = "Page", "SiteTree")); |
||
248 | |||
249 | //add headings |
||
250 | $fields->addFieldToTab( |
||
251 | "Root.Main", |
||
252 | new HeaderField( |
||
253 | "Charges", |
||
254 | _t("PickUpOrDeliveryModifierOptions.CHARGES", "Charges (enter zero (0) to ignore)") |
||
255 | ), |
||
256 | "Percentage" |
||
257 | ); |
||
258 | $fields->addFieldToTab( |
||
259 | "Root.Main", |
||
260 | new HeaderField( |
||
261 | "MinimumAndMaximum", |
||
262 | _t("PickUpOrDeliveryModifierOptions.MIN_AND_MAX", "Minimum and Maximum (enter zero (0) to ignore)") |
||
263 | ), |
||
264 | "MinimumDeliveryCharge" |
||
265 | ); |
||
266 | $fields->addFieldToTab( |
||
267 | "Root.Main", |
||
268 | new HeaderField( |
||
269 | "ExplanationHeader", |
||
270 | _t("PickUpOrDeliveryModifierOptions.EXPLANATION_HEADER", "More information about delivery option") |
||
271 | ), |
||
272 | "ExplanationPageID" |
||
273 | ); |
||
274 | $fields->replaceField( |
||
275 | 'ExcludedProducts', |
||
276 | $excludedProdsField = GridField::create( |
||
277 | 'ExcludedProducts', |
||
278 | 'Excluded Products', |
||
279 | $this->ExcludedProducts(), |
||
0 ignored issues
–
show
The method
ExcludedProducts does not exist on object<PickUpOrDeliveryModifierOptions> ? Since you implemented __call , maybe consider adding a @method annotation.
If you implement This is often the case, when class ParentClass {
private $data = array();
public function __call($method, array $args) {
if (0 === strpos($method, 'get')) {
return $this->data[strtolower(substr($method, 3))];
}
throw new \LogicException(sprintf('Unsupported method: %s', $method));
}
}
/**
* If this class knows which fields exist, you can specify the methods here:
*
* @method string getName()
*/
class SomeClass extends ParentClass { }
Loading history...
|
|||
280 | $config = GridFieldBasicPageRelationConfig::create() |
||
281 | ) |
||
282 | ); |
||
283 | $excludedProdsField->setDescription("Products added here will not be charged delivery costs. If a customer's order contains more than one item (and not all items are listed here), then delivery costs will still be calculated."); |
||
284 | if (EcommerceDBConfig::current_ecommerce_db_config()->ProductsHaveWeight) { |
||
285 | $weightBrackets = $this->WeightBrackets(); |
||
0 ignored issues
–
show
The method
WeightBrackets does not exist on object<PickUpOrDeliveryModifierOptions> ? Since you implemented __call , maybe consider adding a @method annotation.
If you implement This is often the case, when class ParentClass {
private $data = array();
public function __call($method, array $args) {
if (0 === strpos($method, 'get')) {
return $this->data[strtolower(substr($method, 3))];
}
throw new \LogicException(sprintf('Unsupported method: %s', $method));
}
}
/**
* If this class knows which fields exist, you can specify the methods here:
*
* @method string getName()
*/
class SomeClass extends ParentClass { }
Loading history...
|
|||
286 | if ($weightBrackets && $weightBrackets->count()) { |
||
287 | $fields->removeByName("WeightMultiplier"); |
||
288 | $fields->removeByName("WeightUnit"); |
||
289 | } else { |
||
290 | $fields->addFieldToTab("Root.Main", new HeaderField("WeightOptions", "Weight Options (also see Weight Brackets tab)"), "WeightMultiplier"); |
||
291 | } |
||
292 | } else { |
||
293 | $fields->removeByName("WeightBrackets"); |
||
294 | $fields->removeByName("WeightMultiplier"); |
||
295 | $fields->removeByName("WeightUnit"); |
||
296 | } |
||
297 | $fields->addFieldToTab("Root.Main", new HeaderField("MoreInformation", "Other Settings"), "Sort"); |
||
298 | foreach ($this->Config()->get("field_labels_right") as $fieldName => $fieldDescription) { |
||
299 | $field = $fields->dataFieldByName($fieldName); |
||
300 | if ($field) { |
||
301 | $field->setRightTitle($fieldDescription); |
||
302 | } |
||
303 | } |
||
304 | return $fields; |
||
305 | } |
||
306 | |||
307 | private function createGridField($dataObjectName = "EcommerceCountry", $fieldName = "AvailableInCountries", $title) |
||
0 ignored issues
–
show
Parameters which have default values should be placed at the end.
If you place a parameter with a default value before a parameter with a default value, the default value of the first parameter will never be used as it will always need to be passed anyway: // $a must always be passed; it's default value is never used.
function someFunction($a = 5, $b) { }
Loading history...
|
|||
308 | { |
||
309 | $field = null; |
||
310 | $dos = $dataObjectName::get(); |
||
311 | if ($dos->count()) { |
||
312 | if (class_exists("MultiSelectField")) { |
||
313 | $array = $dos->map('ID', 'Title')->toArray(); |
||
314 | //$name, $title = "", $source = array(), $value = "", $form = null |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
49% 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...
|
|||
315 | $field = new MultiSelectField( |
||
316 | $fieldName, |
||
317 | 'This option is available in... ', |
||
318 | $array |
||
319 | ); |
||
320 | } else { |
||
321 | // $controller, $name, $sourceClass, [ $fieldList = null], [ $detailFormFields = null], [ $sourceFilter = ""], [ $sourceSort = ""], [ $sourceJoin = ""] |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
52% 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...
|
|||
322 | /** |
||
323 | * @todo: Auto completer may not be functioning correctly: ExactMatchFilter does not accept EcommerceCountryFilters_AllowSales as modifiers |
||
324 | * |
||
325 | */ |
||
326 | |||
327 | $gridFieldConfig = GridFieldConfig::create(); |
||
328 | $gridFieldConfig->addComponent(new GridFieldButtonRow('before')); |
||
329 | $gridFieldConfig->addComponent(new GridFieldAddExistingAutocompleter('buttons-before-left')); |
||
330 | $gridFieldConfig->addComponent(new GridFieldToolbarHeader()); |
||
331 | $gridFieldConfig->addComponent($sort = new GridFieldSortableHeader()); |
||
332 | $gridFieldConfig->addComponent($filter = new GridFieldFilterHeader()); |
||
333 | $gridFieldConfig->addComponent(new GridFieldDataColumns()); |
||
334 | $gridFieldConfig->addComponent(new GridFieldEditButton()); |
||
335 | $gridFieldConfig->addComponent(new GridFieldDeleteAction(true)); |
||
336 | $gridFieldConfig->addComponent(new GridFieldPageCount('toolbar-header-right')); |
||
337 | $gridFieldConfig->addComponent($pagination = new GridFieldPaginator()); |
||
338 | $gridFieldConfig->addComponent(new GridFieldDetailForm()); |
||
339 | |||
340 | $source = $this->$fieldName(); |
||
341 | return new GridField($fieldName, _t("PickUpOrDeliverModifierOptions.AVAILABLEINCOUNTRIES", "".$title), $source, $gridFieldConfig); |
||
342 | } |
||
343 | } |
||
344 | if ($field) { |
||
345 | return $field; |
||
346 | } else { |
||
347 | return new HiddenField($fieldName); |
||
348 | } |
||
349 | } |
||
350 | |||
351 | /** |
||
352 | * make sure there is only exactly one default |
||
353 | */ |
||
354 | public function onAfterWrite() |
||
355 | { |
||
356 | parent::onAfterWrite(); |
||
357 | // no other record but current one is not default |
||
358 | if ((!$this->IsDefault) && (PickUpOrDeliveryModifierOptions::get()->exclude(array("ID" => intval($this->ID)))->count() == 0)) { |
||
0 ignored issues
–
show
The property
IsDefault does not exist on object<PickUpOrDeliveryModifierOptions> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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...
|
|||
359 | DB::query(" |
||
360 | UPDATE \"PickUpOrDeliveryModifierOptions\" |
||
361 | SET \"IsDefault\" = 1 |
||
362 | WHERE \"ID\" <> ".$this->ID.";"); |
||
363 | } |
||
364 | //current default -> reset others |
||
365 | elseif ($this->IsDefault) { |
||
0 ignored issues
–
show
The property
IsDefault does not exist on object<PickUpOrDeliveryModifierOptions> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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...
|
|||
366 | DB::query(" |
||
367 | UPDATE \"PickUpOrDeliveryModifierOptions\" |
||
368 | SET \"IsDefault\" = 0 |
||
369 | WHERE \"ID\" <> ".intval($this->ID).";"); |
||
370 | } |
||
371 | } |
||
372 | |||
373 | /** |
||
374 | * make sure all are unique codes |
||
375 | */ |
||
376 | public function onBeforeWrite() |
||
377 | { |
||
378 | parent::onBeforeWrite(); |
||
379 | $this->Code = trim(preg_replace("/[^a-zA-Z0-9]+/", "", $this->Code)); |
||
0 ignored issues
–
show
The property
Code does not exist on object<PickUpOrDeliveryModifierOptions> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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...
The property
Code does not exist on object<PickUpOrDeliveryModifierOptions> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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...
|
|||
380 | $i = 0; |
||
381 | if (!$this->Code) { |
||
0 ignored issues
–
show
The property
Code does not exist on object<PickUpOrDeliveryModifierOptions> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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...
|
|||
382 | $defaults = $this->Config()->get("Code"); |
||
383 | $this->Code = empty($defaults["Code"]) ? "CODE" : $defaults["Code"]; |
||
0 ignored issues
–
show
The property
Code does not exist on object<PickUpOrDeliveryModifierOptions> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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...
|
|||
384 | } |
||
385 | $baseCode = $this->Code; |
||
0 ignored issues
–
show
The property
Code does not exist on object<PickUpOrDeliveryModifierOptions> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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...
|
|||
386 | while (PickUpOrDeliveryModifierOptions::get()->filter(array("Code" => $this->Code))->exclude(array("ID" => $this->ID))->count() && $i < 100) { |
||
0 ignored issues
–
show
The property
Code does not exist on object<PickUpOrDeliveryModifierOptions> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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...
|
|||
387 | $i++; |
||
388 | $this->Code = $baseCode.'_'.$i; |
||
0 ignored issues
–
show
The property
Code does not exist on object<PickUpOrDeliveryModifierOptions> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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...
|
|||
389 | } |
||
390 | if ($this->MinimumDeliveryCharge && $this->MaximumDeliveryCharge) { |
||
0 ignored issues
–
show
The property
MinimumDeliveryCharge does not exist on object<PickUpOrDeliveryModifierOptions> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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...
The property
MaximumDeliveryCharge does not exist on object<PickUpOrDeliveryModifierOptions> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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...
|
|||
391 | if ($this->MinimumDeliveryCharge > $this->MaximumDeliveryCharge) { |
||
0 ignored issues
–
show
The property
MinimumDeliveryCharge does not exist on object<PickUpOrDeliveryModifierOptions> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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...
The property
MaximumDeliveryCharge does not exist on object<PickUpOrDeliveryModifierOptions> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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...
|
|||
392 | $this->MinimumDeliveryCharge = $this->MaximumDeliveryCharge; |
||
0 ignored issues
–
show
The property
MinimumDeliveryCharge does not exist on object<PickUpOrDeliveryModifierOptions> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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...
The property
MaximumDeliveryCharge does not exist on object<PickUpOrDeliveryModifierOptions> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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...
|
|||
393 | } |
||
394 | } |
||
395 | } |
||
396 | |||
397 | public function getListOfCountries() |
||
398 | { |
||
399 | $in = ''; |
||
400 | $out = ''; |
||
401 | if ($this->AvailableInCountries()->count()) { |
||
0 ignored issues
–
show
The method
AvailableInCountries does not exist on object<PickUpOrDeliveryModifierOptions> ? Since you implemented __call , maybe consider adding a @method annotation.
If you implement This is often the case, when class ParentClass {
private $data = array();
public function __call($method, array $args) {
if (0 === strpos($method, 'get')) {
return $this->data[strtolower(substr($method, 3))];
}
throw new \LogicException(sprintf('Unsupported method: %s', $method));
}
}
/**
* If this class knows which fields exist, you can specify the methods here:
*
* @method string getName()
*/
class SomeClass extends ParentClass { }
Loading history...
|
|||
402 | $in = "".implode(', ', $this->AvailableInCountries()->column("Code")); |
||
0 ignored issues
–
show
The method
AvailableInCountries does not exist on object<PickUpOrDeliveryModifierOptions> ? Since you implemented __call , maybe consider adding a @method annotation.
If you implement This is often the case, when class ParentClass {
private $data = array();
public function __call($method, array $args) {
if (0 === strpos($method, 'get')) {
return $this->data[strtolower(substr($method, 3))];
}
throw new \LogicException(sprintf('Unsupported method: %s', $method));
}
}
/**
* If this class knows which fields exist, you can specify the methods here:
*
* @method string getName()
*/
class SomeClass extends ParentClass { }
Loading history...
|
|||
403 | } |
||
404 | if ($this->ExcludeFromCountries()->count()) { |
||
0 ignored issues
–
show
The method
ExcludeFromCountries does not exist on object<PickUpOrDeliveryModifierOptions> ? Since you implemented __call , maybe consider adding a @method annotation.
If you implement This is often the case, when class ParentClass {
private $data = array();
public function __call($method, array $args) {
if (0 === strpos($method, 'get')) {
return $this->data[strtolower(substr($method, 3))];
}
throw new \LogicException(sprintf('Unsupported method: %s', $method));
}
}
/**
* If this class knows which fields exist, you can specify the methods here:
*
* @method string getName()
*/
class SomeClass extends ParentClass { }
Loading history...
|
|||
405 | $out = " // OUT: ".implode(', ', $this->ExcludeFromCountries()->column("Code")); |
||
0 ignored issues
–
show
The method
ExcludeFromCountries does not exist on object<PickUpOrDeliveryModifierOptions> ? Since you implemented __call , maybe consider adding a @method annotation.
If you implement This is often the case, when class ParentClass {
private $data = array();
public function __call($method, array $args) {
if (0 === strpos($method, 'get')) {
return $this->data[strtolower(substr($method, 3))];
}
throw new \LogicException(sprintf('Unsupported method: %s', $method));
}
}
/**
* If this class knows which fields exist, you can specify the methods here:
*
* @method string getName()
*/
class SomeClass extends ParentClass { }
Loading history...
|
|||
406 | } |
||
407 | return $in.$out; |
||
408 | } |
||
409 | } |
||
410 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.