Completed
Pull Request — master (#304)
by Jason
09:34
created

ProductCategory::getDataMap()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 20
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 20
cts 20
cp 1
rs 9.0856
c 0
b 0
f 0
cc 1
eloc 20
nc 1
nop 0
crap 1
1
<?php
2
3
use Dynamic\FoxyStripe\Model\FoxyStripeClient;
4
5
class ProductCategory extends DataObject {
6
7
    private static $db = array(
8
		'Title' => 'Varchar(255)',
9
		'Code' => 'Varchar(50)',
10
        'DeliveryType' => 'Varchar(50)',
11
        'MaxDownloads' => 'Int',
12
        'MaxDownloadsTime' => 'Int',
13
        'DefaultWeight' => 'Float',
14
        'DefaultWeightUnit' => 'Enum("LBS, KBS", "LBS")',
15
        'DefaultLengthUnit' => 'Enum("in, cm", "in")',
16
        'ShippingFlatRate' => 'Currency',
17
        'ShippingFlatRateType' => 'Varchar(50)',
18
        'HandlingFeeType' => 'Varchar(50)',
19
        'HandlingFee' => 'Currency',
20
        'HandlingFeePercentage' => 'Decimal',
21
        'HandlingFeeMinimum' => 'Currency',
22
        'DiscountType' => 'Varchar(50)',
23
        'DiscountName' => 'Varchar(50)',
24
        'DiscountDetails' => 'Varchar(200)',
25
        'CustomsValue' => 'Currency',
26
	);
27
28
    private static $singular_name = 'FoxyCart Category';
29
    private static $plural_name = 'FoxyCart Categories';
30
    private static $description = 'Set the FoxyCart Category on a Product';
31
32
    private static $summary_fields = array(
33
        'Title' => 'Name',
34
        'Code' => 'Code'
35
    );
36
37
	private static $indexes = array(
38
		'Code' => true
39
	);
40
41 29
    public function getCMSFields() {
42
43 29
        $fields = parent::getCMSFields();
44
45 29
        if ($this->ID) {
46
            if ($this->Title == 'Default') {
0 ignored issues
show
Documentation introduced by
The property Title does not exist on object<ProductCategory>. 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...
47
                $fields->replaceField(
48
                    'Title',
49
                    ReadonlyField::create('Title')
50
                );
51
            }
52
53
            $fields->replaceField(
54
                'Code',
55
                ReadonlyField::create('Code')
56
            );
57
        }
58
59 1
        $fields->insertBefore(HeaderField::create('DeliveryHD', 'Delivery Options', 3), 'DeliveryType');
0 ignored issues
show
Documentation introduced by
'DeliveryType' is of type string, but the function expects a object<FormField>.

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...
60
61
        $fields->replaceField(
62
            'DeliveryType',
63
            OptionsetField::create('DeliveryType', 'Delivery Type', $this->getShippingOptions())
64 1
        );
65
66
        $fields->dataFieldByName('MaxDownloads')
67
            ->displayIf('DeliveryType')->isEqualTo('downloaded');
68
69
        $fields->dataFieldByName('MaxDownloadsTime')
70
            ->displayIf('DeliveryType')->isEqualTo('downloaded');
71
72
        $fields->dataFieldByName('DefaultWeight')
73
            ->displayIf('DeliveryType')->isEqualTo('shipped');
74
75
        $fields->dataFieldByName('DefaultWeightUnit')
76
            ->displayIf('DeliveryType')->isEqualTo('shipped');
77
78
        $fields->dataFieldByName('DefaultLengthUnit')
79
            ->displayIf('DeliveryType')->isEqualTo('shipped');
80
81
        $fields->dataFieldByName('ShippingFlatRate')
82
            ->displayIf('DeliveryType')->isEqualTo('flat_rate');
83
84
        $fields->replaceField(
85
            'ShippingFlatRateType',
86
            DropdownField::create('ShippingFlatRateType', 'Flat Rate Type', $this->getShippingFlatRateTypes())
87
                ->setEmptyString('')
88
                ->displayIf('DeliveryType')->isEqualTo('flat_rate')->end()
89
        );
90
91
        $fields->insertBefore(HeaderField::create('HandlingHD', 'Handling Fees and Discounts', 3), 'HandlingFeeType');
0 ignored issues
show
Documentation introduced by
'HandlingFeeType' is of type string, but the function expects a object<FormField>.

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...
92
93
        $fields->replaceField(
94
            'HandlingFeeType',
95
            DropdownField::create('HandlingFeeType', 'Handling Fee Type', $this->getHandlingFeeTypes())
96
                ->setEmptyString('')
97
                ->setDescription('This determines what type of Handling Fee you would like to use.')
98
        );
99
100
        $fields->dataFieldByName('HandlingFee')
101
            ->displayIf('HandlingFeeType')->isNotEqualTo('');
102
103
        $fields->dataFieldByName('HandlingFeeMinimum')
104
            ->displayIf('HandlingFeeType')->isEqualTo('flat_percent_with_minimum');
105
106
        $fields->dataFieldByName('HandlingFeePercentage')
107
            ->displayIf('HandlingFeeType')->isEqualTo('flat_percent_with_minimum')
108
            ->orIf('HandlingFeeType')->isEqualTo('flat_percent');
109
110
        $fields->replaceField(
111
            'DiscountType',
112
            DropdownField::create('DiscountType', 'Discount Type', $this->getDiscountTypes())
113
                ->setEmptyString('')
114
                ->setDescription('This determines what type of per category discount you would like to use, if any.')
115
        );
116
117
        $fields->dataFieldByName('DiscountName')
118
            ->displayIf('DiscountType')->isNotEqualTo('');
119
120
        $fields->dataFieldByName('DiscountDetails')
121
            ->displayIf('DiscountType')->isNotEqualTo('');
122
123
        $fields->dataFieldByName('CustomsValue')
124
            ->setDescription('Enter a dollar amount here for the declared customs value for international shipments. If you leave this blank, the sale price of the item will be used.');
125
126
        /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% 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...
127
		$fields = FieldList::create(
128
            LiteralField::create(
129
                'PCIntro',
130
                _t(
131
                    'ProductCategory.PCIntro',
132
                    '<p>Categories must be created in your
133
                        <a href="https://admin.foxycart.com/admin.php?ThisAction=ManageProductCategories" target="_blank">
134
                            FoxyCart Product Categories
135
                        </a>, and also manually created in FoxyStripe.
136
                    </p>'
137
                )
138
            ),
139
            TextField::create('Code')
140
                ->setTitle(_t('ProductCategory.Code', 'Category Code'))
141
                ->setDescription(_t('ProductCategory.CodeDescription', 'copy/paste from FoxyCart')),
142
            TextField::create('Title')
143
                ->setTitle(_t('ProductCategory.Title', 'Category Title'))
144
                ->setDescription(_t('ProductCategory.TitleDescription', 'copy/paste from FoxyCart')),
145
            DropdownField::create(
146
                'DeliveryType',
147
                'Delivery Type',
148
                singleton('ProductCategory')->dbObject('DeliveryType')->enumValues()
149
            )->setEmptyString('')
150
        );
151
152
        $this->extend('updateCMSFields', $fields);
153
        */
154
155
        return $fields;
156
	}
157
158
	public function requireDefaultRecords() {
159
		parent::requireDefaultRecords();
160
		$allCats = DataObject::get('ProductCategory');
161
		if(!$allCats->count()){
162
			$cat = new ProductCategory();
163
			$cat->Title = 'Default';
0 ignored issues
show
Documentation introduced by
The property Title does not exist on object<ProductCategory>. 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...
164
			$cat->Code = 'DEFAULT';
0 ignored issues
show
Documentation introduced by
The property Code does not exist on object<ProductCategory>. 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...
165
			$cat->write();
166
		}
167
	}
168
169
	public function canView($member = false) {
170
		return true;
171
	}
172
173
	public function canEdit($member = null) {
174
		return Permission::check('Product_CANCRUD', 'any', $member);
175
	}
176
177 1
	public function canDelete($member = null) {
178
179
		//don't allow deletion of DEFAULT category
180 1
		return ($this->Code == 'DEFAULT') ? false : Permission::check('Product_CANCRUD', 'any', $member);
0 ignored issues
show
Documentation introduced by
The property Code does not exist on object<ProductCategory>. 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...
181
	}
182
183
	public function canCreate($member = null) {
184
		return Permission::check('Product_CANCRUD', 'any', $member);
185
	}
186
187
    /**
188
     * @return array
189
     */
190
	public function getShippingOptions()
191
    {
192
        return [
193
            'shipped' => 'Shipped using live shipping rates',
194
            'downloaded' => 'Downloaded by the customer',
195
            'flat_rate' => 'Shipped using a flat rate fee',
196
            'pickup' => 'Picked up by the customer',
197
            'notshipped' => 'No Shipping',
198
        ];
199
    }
200
201
    /**
202
     * @return array
203
     */
204
    public function getShippingFlatRateTypes()
205
    {
206
        return [
207
            'per_order' => 'Charge per order',
208
            'per_item' => 'Charge per item',
209
        ];
210
    }
211
212
    /**
213
     * @return array
214
     */
215
    public function getHandlingFeeTypes()
216
    {
217
        return [
218
            'flat_per_order' => 'Flat fee per order with products in this category',
219
            'flat_per_item' => 'Flat fee per product in this category',
220
            'flat_percent' => 'Flat fee per shipment + % of price for products in this category',
221
            'flat_percent_with_minimum' => 'Flat fee per shipment OR % of order total with products in this category. Whichever is greater.',
222
        ];
223
    }
224
225
    public function getDiscountTypes()
226
    {
227
        return [
228
            'quantity_amount' => 'Discount by an amount based on the quantity',
229
            'quantity_percentage' => 'Discount by a percentage based on the quantity',
230
            'price_amount' => 'Discount by an amount based on the price in this category',
231
            'price_percentage' => 'Discount by a percentage based on the price in this category',
232
        ];
233
    }
234
235
    /**
236
     * @return array
237
     */
238 29
	public function getDataMap()
239
    {
240
        return [
241 29
            'name' => $this->Title,
0 ignored issues
show
Documentation introduced by
The property Title does not exist on object<ProductCategory>. 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...
242 29
            'code' => $this->Code,
0 ignored issues
show
Documentation introduced by
The property Code does not exist on object<ProductCategory>. 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...
243 29
            'item_delivery_type' => $this->DeliveryType,
0 ignored issues
show
Documentation introduced by
The property DeliveryType does not exist on object<ProductCategory>. 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...
244 29
            'max_downloads_per_customer' => $this->MaxDownloads,
0 ignored issues
show
Documentation introduced by
The property MaxDownloads does not exist on object<ProductCategory>. 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...
245 29
            'max_downloads_time_period' => $this->MaxDownloadsTime,
0 ignored issues
show
Documentation introduced by
The property MaxDownloadsTime does not exist on object<ProductCategory>. 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...
246 29
            'customs_value' => $this->CustomsValue,
0 ignored issues
show
Documentation introduced by
The property CustomsValue does not exist on object<ProductCategory>. 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...
247 29
            'default_weight' => $this->DefaultWeight,
0 ignored issues
show
Documentation introduced by
The property DefaultWeight does not exist on object<ProductCategory>. 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 29
            'default_weight_unit' => $this->DefaultWeightUnit,
0 ignored issues
show
Documentation introduced by
The property DefaultWeightUnit does not exist on object<ProductCategory>. 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...
249 29
            'default_length_unit' => $this->DefautlLengthUnit,
0 ignored issues
show
Documentation introduced by
The property DefautlLengthUnit does not exist on object<ProductCategory>. 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...
250 29
            'shipping_flat_rate' => $this->ShippingFlatRate,
0 ignored issues
show
Documentation introduced by
The property ShippingFlatRate does not exist on object<ProductCategory>. 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...
251 29
            'shipping_flat_rate_type' => $this->ShippingFlatRateType,
0 ignored issues
show
Documentation introduced by
The property ShippingFlatRateType does not exist on object<ProductCategory>. 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...
252 29
            'handling_fee_type' => $this->HandlingFeeType,
0 ignored issues
show
Documentation introduced by
The property HandlingFeeType does not exist on object<ProductCategory>. 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...
253 29
            'handling_fee' => $this->HandlingFee,
0 ignored issues
show
Documentation introduced by
The property HandlingFee does not exist on object<ProductCategory>. 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...
254 29
            'handling_fee_minimum' => $this->HandlingFeeMinimum,
0 ignored issues
show
Documentation introduced by
The property HandlingFeeMinimum does not exist on object<ProductCategory>. 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...
255 29
            'handling_fee_percentage' => $this->HandlingFeePercentage,
0 ignored issues
show
Documentation introduced by
The property HandlingFeePercentage does not exist on object<ProductCategory>. 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 29
            'discount_type' => $this->DiscountType,
0 ignored issues
show
Documentation introduced by
The property DiscountType does not exist on object<ProductCategory>. 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...
257 29
            'discount_name' => $this->DiscountName,
0 ignored issues
show
Documentation introduced by
The property DiscountName does not exist on object<ProductCategory>. 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...
258 29
            'discount_details' => $this->DiscountDetails,
0 ignored issues
show
Documentation introduced by
The property DiscountDetails does not exist on object<ProductCategory>. 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...
259 29
        ];
260
    }
261
262
    /**
263
     *
264
     */
265 29
	public function onAfterWrite()
266
    {
267 29
        parent::onAfterWrite();
268
269 29
        if ($this->isChanged()) {
270 29
            if ($fc = new FoxyStripeClient()) {
271 29
                $fc->putCategory($this->getDataMap());
272 29
            }
273 29
        }
274 29
    }
275
276
    /**
277
     *
278
     */
279 1
    public function onAfterDelete()
280
    {
281 1
        parent::onAfterDelete();
282
283 1
        if ($fc = new FoxyStripeClient()) {
284 1
            $fc->deleteCategory($this->getDataMap());
285 1
        }
286 1
    }
287
}
288