Completed
Pull Request — master (#287)
by Nic
05:31
created

OptionItem::getGeneratedTitle()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 6
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

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