Completed
Push — master ( dfa2fa...646fe1 )
by Jason
11s
created

OptionItem::getIsAvailable()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 4
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
crap 6
1
<?php
2
3
/**
4
 * Class OptionItem
5
 */
6
class OptionItem extends DataObject
7
{
8
    /**
9
     * @var array
10
     */
11
    private static $db = array(
12
        'Title' => 'Text',
13
        'WeightModifier' => 'Int',
14
        'CodeModifier' => 'Text',
15
        'PriceModifier' => 'Currency',
16
        'WeightModifierAction' => "Enum('Add,Subtract,Set','Add')",
17
        'CodeModifierAction' => "Enum('Add,Subtract,Set','Add')",
18
        'PriceModifierAction' => "Enum('Add,Subtract,Set','Add')",
19
        'Available' => 'Boolean',
20
        'SortOrder' => 'Int'
21
    );
22
23
    /**
24
     * @var array
25
     */
26
    private static $has_one = array(
27
        'Product' => 'ProductPage',
28
        'ProductOptionGroup' => 'OptionGroup',
29
    );
30
31
    /**
32
     * @var array
33
     */
34
    private static $belongs_many_many = array(
35
        'OrderDetails' => 'OrderDetail'
36
    );
37
38
    /**
39
     * @var array
40
     */
41
    private static $defaults = array(
42
        'Available' => true
43
    );
44
45
    /**
46
     * @var array
47
     */
48
    private static $summary_fields = array(
49
        'Title' => 'Title',
50
        'ProductOptionGroup.Title' => 'Group',
51
        'IsAvailable' => 'Available'
52
    );
53
54
    /**
55
     * @var array
56
     */
57
    private static $searchable_fields = [
58
        'Title' => [
59
            'title' => 'Title',
60
        ],
61
        'ProductOptionGroup.Title' => [
62
            'title' => 'Group'
63
        ],
64
    ];
65
66
    /**
67
     * @var string
68
     */
69
    private static $default_sort = 'SortOrder';
0 ignored issues
show
Unused Code introduced by
The property $default_sort 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...
70
71
    /**
72
     * @return FieldList
73
     */
74
    public function getCMSFields()
75
    {
76
        $fields = parent::getCMSFields();
77
78
        $fields->removeByName([
79
            'OrderDetails',
80
            'SortOrder',
81
            'ProductID',
82
        ]);
83
84
        // set variables from Product
85
        $productID = ($this->ProductID != 0) ? $this->ProductID : Session::get('CMSMain.currentPage');
0 ignored issues
show
Documentation introduced by
The property ProductID does not exist on object<OptionItem>. 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...
86
        $product = ProductPage::get()->byID($productID);
87
88
        $parentPrice = $product->obj('Price')->Nice();
89
        $parentWeight = $product->Weight;
90
        $parentCode = $product->Code;
91
92
        // ProductOptionGroup Dropdown field w/ add new
93
        $groups = function () {
94
            return OptionGroup::get()->map()->toArray();
95
        };
96
        $groupFields = singleton('OptionGroup')->getCMSFields();
97
        $groupField = DropdownField::create('ProductOptionGroupID', _t("OptionItem.Group", "Group"), $groups())
98
            ->setEmptyString('')
99
            ->setDescription(_t('OptionItem.GroupDescription', 'Name of this group of options. Managed in <a href="admin/settings">Settings > FoxyStripe > Option Groups</a>'));
100
        if (class_exists('QuickAddNewExtension')) {
101
            $groupField->useAddNew('OptionGroup', $groups, $groupFields);
102
        }
103
104
        $fields->addFieldsToTab('Root.Main', array(
105
            Textfield::create('Title')
106
                ->setTitle(_t("OptionItem.Title", "Product Option Name")),
107
            CheckboxField::create('Available')
108
                ->setTitle(_t("OptionItem.Available", "Available for purchase"))
109
                ->setDescription(_t('OptionItem.AvailableDescription', "If unchecked, will disable this option in the drop down menu")),
110
            $groupField
111
        ));
112
113
        $fields->addFieldsToTab('Root.Modifiers', array(
114
            HeaderField::create('ModifyHD', _t('OptionItem.ModifyHD', 'Product Option Modifiers'), 2),
115
116
            // Weight Modifier Fields
117
            HeaderField::create('WeightHD', _t('OptionItem.WeightHD', 'Modify Weight'), 3),
118
            NumericField::create('WeightModifier')
119
                ->setTitle(_t('OptionItem.WeightModifier', 'Weight')),
120
            DropdownField::create('WeightModifierAction', _t('OptionItem.WeightModifierAction', 'Weight Modification'),
121
                array(
122
                    'Add' => _t(
123
                        'OptionItem.WeightAdd',
124
                        "Add to Base Weight ({weight})",
125
                        'Add to weight',
126
                        array('weight' => $parentWeight)
0 ignored issues
show
Documentation introduced by
array('weight' => $parentWeight) is of type array<string,?,{"weight":"?"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
127
                    ),
128
                    'Subtract' => _t(
129
                        'OptionItem.WeightSubtract',
130
                        "Subtract from Base Weight ({weight})",
131
                        'Subtract from weight',
132
                        array('weight' => $parentWeight)
0 ignored issues
show
Documentation introduced by
array('weight' => $parentWeight) is of type array<string,?,{"weight":"?"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
133
                    ),
134
                    'Set' => _t('OptionItem.WeightSet', 'Set as a new Weight')
135
                )
136
            )->setEmptyString('')
137
            ->setDescription(_t('OptionItem.WeightDescription', 'Does weight modify or replace base weight?')),
138
139
            // Price Modifier FIelds
140
            HeaderField::create('PriceHD', _t('OptionItem.PriceHD', 'Modify Price'), 3),
141
            CurrencyField::create('PriceModifier')
142
                ->setTitle(_t('OptionItem.PriceModifier', 'Price')),
143
            DropdownField::create('PriceModifierAction', _t('OptionItem.PriceModifierAction', 'Price Modification'),
144
                array(
145
                    'Add' => _t(
146
                        'OptionItem.PriceAdd',
147
                        "Add to Base Price ({price})",
148
                        'Add to price',
149
                        array('price' => $parentPrice)
0 ignored issues
show
Documentation introduced by
array('price' => $parentPrice) is of type array<string,?,{"price":"?"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
150
                    ),
151
                    'Subtract' => _t(
152
                        'OptionItem.PriceSubtract',
153
                        "Subtract from Base Price ({price})",
154
                        'Subtract from price',
155
                        array('price' => $parentPrice)
0 ignored issues
show
Documentation introduced by
array('price' => $parentPrice) is of type array<string,?,{"price":"?"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
156
                    ),
157
                    'Set' => _t('OptionItem.PriceSet', 'Set as a new Price')
158
                )
159
            )->setEmptyString('')
160
            ->setDescription(_t('OptionItem.PriceDescription', 'Does price modify or replace base price?')),
161
162
            // Code Modifier Fields
163
            HeaderField::create('CodeHD', _t('OptionItem.CodeHD', 'Modify Code'), 3),
164
            TextField::create('CodeModifier')
165
                ->setTitle(_t('OptionItem.CodeModifier', 'Code')),
166
            DropdownField::create('CodeModifierAction', _t('OptionItem.CodeModifierAction', 'Code Modification'),
167
                array(
168
                    'Add' => _t(
169
                        'OptionItem.CodeAdd',
170
                        "Add to Base Code ({code})",
171
                        'Add to code',
172
                        array('code' => $parentCode)
0 ignored issues
show
Documentation introduced by
array('code' => $parentCode) is of type array<string,?,{"code":"?"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
173
                    ),
174
                    'Subtract' => _t(
175
                        'OptionItem.CodeSubtract',
176
                        'Subtract from Base Code ({code})',
177
                        'Subtract from code',
178
                        array('code' => $parentCode)
0 ignored issues
show
Documentation introduced by
array('code' => $parentCode) is of type array<string,?,{"code":"?"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
179
                    ),
180
                    'Set' => _t('OptionItem.CodeSet', 'Set as a new Code')
181
                )
182
            )->setEmptyString('')
183
            ->setDescription(_t('OptionItem.CodeDescription', 'Does code modify or replace base code?'))
184
        ));
185
186
        /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
44% 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...
187
        // Cateogry Dropdown field w/ add new
188
        // removed until relevance determined
189
        $categories = function(){
190
            return ProductCategory::get()->map()->toArray();
191
        };
192
193
        // to do - have OptionItem category override set ProductPage category if selected: issue #155
194
        $categoryField = DropdownField::create('CategoryID', 'Category', $categories())
195
            ->setEmptyString('')
196
            ->setDescription('Categories can be managed in <a href="admin/settings">Settings > FoxyStripe > Categories</a>');
197
        if (class_exists('QuickAddNewExtension')) $categoryField->useAddNew('ProductCategory', $categories);
198
199
        $fields->insertAfter($categoryField, 'ProductOptionGroupID');
200
        */
201
202
        // allow CMS fields to be extended
203
        $this->extend('getCMSFields', $fields);
204
205
        return $fields;
206
    }
207
208
    /**
209
     * @return ValidationResult
210
     */
211 2
    public function validate()
212
    {
213 2
        $result = parent::validate();
214
215 2
        if ($this->ProductOptionGroupID == 0) {
0 ignored issues
show
Documentation introduced by
The property ProductOptionGroupID does not exist on object<OptionItem>. 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...
216
            $result->error('Must set a Group prior to saving');
217
        }
218
219 2
        return $result;
220
    }
221
222
    /**
223
     * @param $oma
224
     * @param bool $returnWithOnlyPlusMinus
225
     * @return string
226
     */
227
    public static function getOptionModifierActionSymbol($oma, $returnWithOnlyPlusMinus=false)
228
    {
229
        switch ($oma) {
230
            case 'Subtract':
231
                $symbol = '-';
232
                break;
233
            case 'Set':
234
                $symbol = ($returnWithOnlyPlusMinus) ? '' : ':';
235
                break;
236
            default:
237
                $symbol = '+';
238
        }
239
        return $symbol;
240
    }
241
242
    /**
243
     * @return string
244
     */
245
    public function getWeightModifierWithSymbol()
246
    {
247
        return self::getOptionModifierActionSymbol($this->WeightModifierAction).$this->WeightModifier;
0 ignored issues
show
Documentation introduced by
The property WeightModifierAction does not exist on object<OptionItem>. 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 WeightModifier does not exist on object<OptionItem>. 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...
248
    }
249
250
    /**
251
     * @return string
252
     */
253
    public function getPriceModifierWithSymbol()
254
    {
255
        return self::getOptionModifierActionSymbol($this->PriceModifierAction).$this->PriceModifier;
0 ignored issues
show
Documentation introduced by
The property PriceModifierAction does not exist on object<OptionItem>. 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 PriceModifier does not exist on object<OptionItem>. 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...
256
    }
257
258
    /**
259
     * @return string
260
     */
261
    public function getCodeModifierWithSymbol()
262
    {
263
        return self::getOptionModifierActionSymbol($this->CodeModifierAction).$this->CodeModifier;
0 ignored issues
show
Documentation introduced by
The property CodeModifierAction does not exist on object<OptionItem>. 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 CodeModifier does not exist on object<OptionItem>. 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...
264
    }
265
266
    /**
267
     * @return mixed
268
     */
269
    public function getProductOptionGroupTitle()
270
    {
271
        return $this->ProductOptionGroup()->Title;
0 ignored issues
show
Bug introduced by
The method ProductOptionGroup() does not exist on OptionItem. Did you maybe mean getProductOptionGroupTitle()?

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...
272
    }
273
274
    /**
275
     * @return string
276
     */
277
    public function getGeneratedValue()
278
    {
279
        $modPrice = ($this->PriceModifier) ? (string)$this->PriceModifier : '0';
0 ignored issues
show
Documentation introduced by
The property PriceModifier does not exist on object<OptionItem>. 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...
280
        $modPriceWithSymbol = OptionItem::getOptionModifierActionSymbol($this->PriceModifierAction).$modPrice;
0 ignored issues
show
Documentation introduced by
The property PriceModifierAction does not exist on object<OptionItem>. 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...
281
        $modWeight = ($this->WeightModifier) ? (string)$this->WeightModifier : '0';
0 ignored issues
show
Documentation introduced by
The property WeightModifier does not exist on object<OptionItem>. 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...
282
        $modWeight = OptionItem::getOptionModifierActionSymbol($this->WeightModifierAction).$modWeight;
0 ignored issues
show
Documentation introduced by
The property WeightModifierAction does not exist on object<OptionItem>. 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
        $modCode = OptionItem::getOptionModifierActionSymbol($this->CodeModifierAction).$this->CodeModifier;
0 ignored issues
show
Documentation introduced by
The property CodeModifierAction does not exist on object<OptionItem>. 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 CodeModifier does not exist on object<OptionItem>. 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...
284
        return $this->Title.'{p'.$modPriceWithSymbol.'|w'.$modWeight.'|c'.$modCode.'}';
0 ignored issues
show
Documentation introduced by
The property Title does not exist on object<OptionItem>. 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...
285
    }
286
287
    /**
288
     * @return mixed|string
289
     */
290
    public function getGeneratedTitle()
291
    {
292
        $modPrice = ($this->PriceModifier) ? (string)$this->PriceModifier : '0';
0 ignored issues
show
Documentation introduced by
The property PriceModifier does not exist on object<OptionItem>. 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...
293
        $title = $this->Title;
0 ignored issues
show
Documentation introduced by
The property Title does not exist on object<OptionItem>. 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...
294
        $title .= ($this->PriceModifier != 0) ? ': ('.OptionItem::getOptionModifierActionSymbol($this->PriceModifierAction, $returnWithOnlyPlusMinus=true).'$'.$modPrice.')' : '';
0 ignored issues
show
Documentation introduced by
The property PriceModifier does not exist on object<OptionItem>. 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 PriceModifierAction does not exist on object<OptionItem>. 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...
295
        return $title;
296
    }
297
298
    /**
299
     * @return bool
300
     */
301
    public function getAvailability()
302
    {
303
        $available = ($this->Available == 1) ? true : false ;
0 ignored issues
show
Documentation introduced by
The property Available does not exist on object<OptionItem>. 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...
304
305
        $this->extend('updateOptionAvailability', $available);
306
307
        return $available;
308
    }
309
310
    /**
311
     * @return string
312
     */
313
    public function getIsAvailable()
314
    {
315
        if ($this->getAvailability()) {
316
            return "yes";
317
        }
318
        return "no";
319
    }
320
321
    /**
322
     * @param bool $member
323
     * @return bool
324
     */
325
    public function canView($member = false)
326
    {
327
        return true;
328
    }
329
330
    /**
331
     * @param null $member
332
     * @return bool|int
333
     */
334
    public function canEdit($member = null)
335
    {
336
        return Permission::check('Product_CANCRUD');
337
    }
338
339
    /**
340
     * @param null $member
341
     * @return bool|int
342
     */
343 1
    public function canDelete($member = null)
344
    {
345 1
        return Permission::check('Product_CANCRUD');
346
    }
347
348
    /**
349
     * @param null $member
350
     * @return bool|int
351
     */
352
    public function canCreate($member = null)
353
    {
354
        return Permission::check('Product_CANCRUD');
355
    }
356
}
357