Completed
Pull Request — master (#292)
by Jason
09:05
created

OptionItem   B

Complexity

Total Complexity 25

Size/Duplication

Total Lines 244
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 16

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 25
lcom 1
cbo 16
dl 0
loc 244
ccs 0
cts 140
cp 0
rs 8.4614
c 0
b 0
f 0

14 Methods

Rating   Name   Duplication   Size   Complexity  
B getCMSFields() 0 130 3
A getOptionModifierActionSymbol() 0 13 4
A getWeightModifierWithSymbol() 0 3 1
A getPriceModifierWithSymbol() 0 3 1
A getCodeModifierWithSymbol() 0 3 1
A getProductOptionGroupTitle() 0 3 1
A getGeneratedValue() 0 8 3
A getGeneratedTitle() 0 6 3
A getAvailability() 0 3 2
A canView() 0 3 1
A canEdit() 0 3 1
A canCreate() 0 3 1
A validate() 0 9 2
A canDelete() 0 3 1
1
<?php
2
/**
3
 *
4
 * @package FoxyStripe
5
 *
6
 */
7
8
class OptionItem extends DataObject{
9
10
	private static $db = array(
11
		'Title' => 'Text',
12
		'WeightModifier' => 'Int',
13
		'CodeModifier' => 'Text',
14
		'PriceModifier' => 'Currency',
15
		'WeightModifierAction' => "Enum('Add,Subtract,Set','Add')",
16
		'CodeModifierAction' => "Enum('Add,Subtract,Set','Add')",
17
		'PriceModifierAction' => "Enum('Add,Subtract,Set','Add')",
18
		'Available' => 'Boolean',
19
		'SortOrder' => 'Int'
20
	);
21
22
	private static $has_one = array(
23
		'Product' => 'ProductPage',
24
		'ProductOptionGroup' => 'OptionGroup',
25
		//'Category' => 'ProductCategory'
26
	);
27
28
    private static $belongs_many_many = array(
29
        'OrderDetails' => 'OrderDetail'
30
    );
31
32
    private static $defaults = array(
33
		'Available' => true
34
	);
35
36
	private static $summary_fields = array(
37
		'Title' => 'Title',
38
		'ProductOptionGroup.Title' => 'Group',
39
        'Available.Nice' => 'Available'
40
	);
41
42
	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...
43
44
	public function getCMSFields(){
45
		$fields = FieldList::create(
46
			new Tabset('Root',
47
				new Tab('Main'),
48
				new Tab('Modifiers')
49
			)
50
		);
51
52
		// set variables from Product
53
        $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...
54
        $product = ProductPage::get()->byID($productID);
55
56
		$parentPrice = $product->obj('Price')->Nice();
57
		$parentWeight = $product->Weight;
58
		$parentCode = $product->Code;
59
60
		// ProductOptionGroup Dropdown field w/ add new
61
		$groups = function(){
62
		    return OptionGroup::get()->map()->toArray();
63
		};
64
		$groupFields = singleton('OptionGroup')->getCMSFields();
65
		$groupField = DropdownField::create('ProductOptionGroupID', _t("OptionItem.Group", "Group"), $groups())
66
			->setEmptyString('')
67
            ->setDescription(_t('OptionItem.GroupDescription', 'Name of this group of options. Managed in <a href="admin/settings">Settings > FoxyStripe > Option Groups</a>'));
68
		if (class_exists('QuickAddNewExtension')) $groupField->useAddNew('OptionGroup', $groups, $groupFields);
69
70
        $fields->addFieldsToTab('Root.Main', array(
71
			HeaderField::create('DetailsHD', _t("OptionItem.DetailsHD", "Product Option Details"), 2),
72
			Textfield::create('Title')
73
                ->setTitle(_t("OptionItem.Title", "Product Option Name")),
74
			CheckboxField::create('Available')
75
				->setTitle( _t("OptionItem.Available", "Available for purchase"))
76
                ->setDescription(_t('OptionItem.AvailableDescription', "If unchecked, will disable this option in the drop down menu")),
77
			$groupField
78
		));
79
80
		$fields->addFieldsToTab('Root.Modifiers', array(
81
			HeaderField::create('ModifyHD', _t('OptionItem.ModifyHD', 'Product Option Modifiers'), 2),
82
83
			// Weight Modifier Fields
84
			HeaderField::create('WeightHD', _t('OptionItem.WeightHD', 'Modify Weight'), 3),
85
			NumericField::create('WeightModifier')
86
                ->setTitle(_t('OptionItem.WeightModifier', 'Weight')),
87
			DropdownField::create('WeightModifierAction', _t('OptionItem.WeightModifierAction', 'Weight Modification'),
88
				array(
89
                    'Add' => _t(
90
                        'OptionItem.WeightAdd',
91
                        "Add to Base Weight ({weight})",
92
                        'Add to weight',
93
                        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...
94
                    ),
95
                    'Subtract' => _t(
96
                        'OptionItem.WeightSubtract',
97
                        "Subtract from Base Weight ({weight})",
98
                        'Subtract from weight',
99
                        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...
100
                    ),
101
                    'Set' => _t('OptionItem.WeightSet', 'Set as a new Weight')
102
				)
103
			)->setEmptyString('')
104
			->setDescription(_t('OptionItem.WeightDescription', 'Does weight modify or replace base weight?')),
105
106
			// Price Modifier FIelds
107
			HeaderField::create('PriceHD', _t('OptionItem.PriceHD', 'Modify Price'), 3),
108
			CurrencyField::create('PriceModifier')
109
                ->setTitle(_t('OptionItem.PriceModifier', 'Price')),
110
			DropdownField::create('PriceModifierAction', _t('OptionItem.PriceModifierAction', 'Price Modification'),
111
				array(
112
					'Add' => _t(
113
                        'OptionItem.PriceAdd',
114
                        "Add to Base Price ({price})",
115
                        'Add to price',
116
                        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...
117
                    ),
118
					'Subtract' => _t(
119
                        'OptionItem.PriceSubtract',
120
                        "Subtract from Base Price ({price})",
121
                        'Subtract from price',
122
                        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...
123
                    ),
124
					'Set' => _t('OptionItem.PriceSet', 'Set as a new Price')
125
				)
126
			)->setEmptyString('')
127
			->setDescription(_t('OptionItem.PriceDescription', 'Does price modify or replace base price?')),
128
129
			// Code Modifier Fields
130
			HeaderField::create('CodeHD', _t('OptionItem.CodeHD', 'Modify Code'), 3),
131
			TextField::create('CodeModifier')
132
                ->setTitle(_t('OptionItem.CodeModifier', 'Code')),
133
			DropdownField::create('CodeModifierAction', _t('OptionItem.CodeModifierAction', 'Code Modification'),
134
				array(
135
					'Add' => _t(
136
                        'OptionItem.CodeAdd',
137
                        "Add to Base Code ({code})",
138
                        'Add to code',
139
                        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...
140
                    ),
141
					'Subtract' => _t(
142
                        'OptionItem.CodeSubtract',
143
                        'Subtract from Base Code ({code})',
144
                        'Subtract from code',
145
                        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...
146
                    ),
147
					'Set' => _t('OptionItem.CodeSet', 'Set as a new Code')
148
				)
149
			)->setEmptyString('')
150
			->setDescription(_t('OptionItem.CodeDescription', 'Does code modify or replace base code?'))
151
		));
152
153
        /*
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...
154
        // Cateogry Dropdown field w/ add new
155
        // removed until relevance determined
156
        $categories = function(){
157
            return ProductCategory::get()->map()->toArray();
158
        };
159
160
        // to do - have OptionItem category override set ProductPage category if selected: issue #155
161
        $categoryField = DropdownField::create('CategoryID', 'Category', $categories())
162
            ->setEmptyString('')
163
            ->setDescription('Categories can be managed in <a href="admin/settings">Settings > FoxyStripe > Categories</a>');
164
        if (class_exists('QuickAddNewExtension')) $categoryField->useAddNew('ProductCategory', $categories);
165
166
        $fields->insertAfter($categoryField, 'ProductOptionGroupID');
167
        */
168
169
        // allow CMS fields to be extended
170
		$this->extend('getCMSFields', $fields);
171
172
		return $fields;
173
	}
174
175
	public function validate(){
176
		$result = parent::validate();
177
178
		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...
179
			$result->error('Must set a Group prior to saving');
180
		}
181
182
		return $result;
183
	}
184
185
	public static function getOptionModifierActionSymbol($oma, $returnWithOnlyPlusMinus=false){
186
		switch($oma){
187
			case 'Subtract':
188
				$symbol = '-';
189
				break;
190
			case 'Set':
191
				$symbol = ($returnWithOnlyPlusMinus) ? '' : ':';
192
				break;
193
			default:
194
				$symbol = '+';
195
		}
196
		return $symbol;
197
	}
198
199
	public function getWeightModifierWithSymbol(){
200
		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...
201
	}
202
203
	public function getPriceModifierWithSymbol(){
204
		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...
205
	}
206
207
	public function getCodeModifierWithSymbol(){
208
		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...
209
	}
210
211
	public function getProductOptionGroupTitle(){
212
		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...
213
	}
214
215
	public function getGeneratedValue(){
216
		$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...
217
		$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...
218
		$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...
219
		$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...
220
		$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...
221
		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...
222
	}
223
224
	public function getGeneratedTitle(){
225
		$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...
226
		$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...
227
		$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...
228
		return $title;
229
	}
230
231
	public function getAvailability(){
232
		return ($this->Available == 0) ? 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...
233
	}
234
235
	public function canView($member = false) {
236
		return true;
237
	}
238
239
	public function canEdit($member = null) {
240
		return Permission::check('Product_CANCRUD');
241
	}
242
243
	public function canDelete($member = null) {
244
		return Permission::check('Product_CANCRUD');
245
	}
246
247
	public function canCreate($member = null) {
248
		return Permission::check('Product_CANCRUD');
249
	}
250
251
}
252