Completed
Pull Request — master (#304)
by Jason
11:13
created

ProductCategory::getDataMap()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 0
cts 0
cp 0
rs 9.0856
c 0
b 0
f 0
cc 1
eloc 20
nc 1
nop 0
crap 2
1
<?php
2
3
use Dynamic\FoxyStripe\Model\FoxyStripeClient;
4
5
class ProductCategory extends DataObject
6
{
7
    /**
8
     * @var array
9
     */
10
    private static $db = array(
11
        'Title' => 'Varchar(255)',
12
        'Code' => 'Varchar(50)',
13
        'DeliveryType' => 'Varchar(50)',
14
        'MaxDownloads' => 'Int',
15
        'MaxDownloadsTime' => 'Int',
16
        'DefaultWeight' => 'Float',
17
        'DefaultWeightUnit' => 'Enum("LBS, KBS", "LBS")',
18
        'DefaultLengthUnit' => 'Enum("in, cm", "in")',
19
        'ShippingFlatRate' => 'Currency',
20
        'ShippingFlatRateType' => 'Varchar(50)',
21
        'HandlingFeeType' => 'Varchar(50)',
22
        'HandlingFee' => 'Currency',
23
        'HandlingFeePercentage' => 'Decimal',
24
        'HandlingFeeMinimum' => 'Currency',
25
        'DiscountType' => 'Varchar(50)',
26
        'DiscountName' => 'Varchar(50)',
27
        'DiscountDetails' => 'Varchar(200)',
28
        'CustomsValue' => 'Currency',
29
    );
30
31
    /**
32
     * @var string
33
     */
34
    private static $singular_name = 'FoxyCart Category';
35
36
    /**
37
     * @var string
38
     */
39
    private static $plural_name = 'FoxyCart Categories';
40
41
    /**
42
     * @var string
43
     */
44
    private static $description = 'Set the FoxyCart Category on a Product';
45
46
    /**
47
     * @var array
48
     */
49
    private static $summary_fields = array(
50
        'Title' => 'Name',
51
        'Code' => 'Code'
52
    );
53
54
    /**
55
     * @var array
56
     */
57
    private static $indexes = array(
58
        'Code' => true
59
    );
60
61
    /**
62
     * @return FieldList
63
     */
64
    public function getCMSFields()
65
    {
66
        $fields = parent::getCMSFields();
67
68
        if ($this->ID) {
69
            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...
70
                $fields->replaceField(
71
                    'Title',
72
                    ReadonlyField::create('Title')
73
                );
74 1
            }
75
76
            $fields->replaceField(
77 1
                'Code',
78
                ReadonlyField::create('Code')
79
            );
80
        }
81
82
        $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...
83
84
        $fields->replaceField(
85 1
            'DeliveryType',
86
            OptionsetField::create('DeliveryType', 'Delivery Type', $this->getShippingOptions())
87
        );
88
89
        $fields->dataFieldByName('MaxDownloads')
90
            ->displayIf('DeliveryType')->isEqualTo('downloaded');
91
92
        $fields->dataFieldByName('MaxDownloadsTime')
93
            ->displayIf('DeliveryType')->isEqualTo('downloaded');
94
95
        $fields->dataFieldByName('DefaultWeight')
96
            ->displayIf('DeliveryType')->isEqualTo('shipped');
97
98
        $fields->dataFieldByName('DefaultWeightUnit')
99
            ->displayIf('DeliveryType')->isEqualTo('shipped');
100
101
        $fields->dataFieldByName('DefaultLengthUnit')
102
            ->displayIf('DeliveryType')->isEqualTo('shipped');
103
104
        $fields->dataFieldByName('ShippingFlatRate')
105
            ->displayIf('DeliveryType')->isEqualTo('flat_rate');
106
107
        $fields->replaceField(
108
            'ShippingFlatRateType',
109
            DropdownField::create('ShippingFlatRateType', 'Flat Rate Type', $this->getShippingFlatRateTypes())
110
                ->setEmptyString('')
111
                ->displayIf('DeliveryType')->isEqualTo('flat_rate')->end()
112
        );
113
114
        $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...
115
116
        $fields->replaceField(
117
            'HandlingFeeType',
118
            DropdownField::create('HandlingFeeType', 'Handling Fee Type', $this->getHandlingFeeTypes())
119
                ->setEmptyString('')
120
                ->setDescription('This determines what type of Handling Fee you would like to use.')
121
        );
122
123
        $fields->dataFieldByName('HandlingFee')
124
            ->displayIf('HandlingFeeType')->isNotEqualTo('');
125
126
        $fields->dataFieldByName('HandlingFeeMinimum')
127
            ->displayIf('HandlingFeeType')->isEqualTo('flat_percent_with_minimum');
128
129
        $fields->dataFieldByName('HandlingFeePercentage')
130
            ->displayIf('HandlingFeeType')->isEqualTo('flat_percent_with_minimum')
131
            ->orIf('HandlingFeeType')->isEqualTo('flat_percent');
132
133
        $fields->replaceField(
134
            'DiscountType',
135
            DropdownField::create('DiscountType', 'Discount Type', $this->getDiscountTypes())
136
                ->setEmptyString('')
137
                ->setDescription('This determines what type of per category discount you would like to use, if any.')
138
        );
139
140
        $fields->dataFieldByName('DiscountName')
141
            ->displayIf('DiscountType')->isNotEqualTo('');
142
143
        $fields->dataFieldByName('DiscountDetails')
144
            ->displayIf('DiscountType')->isNotEqualTo('');
145
146
        $fields->dataFieldByName('CustomsValue')
147
            ->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.');
148
149
        /*
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...
150
        $fields = FieldList::create(
151
            LiteralField::create(
152
                'PCIntro',
153
                _t(
154
                    'ProductCategory.PCIntro',
155
                    '<p>Categories must be created in your
156
                        <a href="https://admin.foxycart.com/admin.php?ThisAction=ManageProductCategories" target="_blank">
157
                            FoxyCart Product Categories
158
                        </a>, and also manually created in FoxyStripe.
159
                    </p>'
160
                )
161
            ),
162
            TextField::create('Code')
163
                ->setTitle(_t('ProductCategory.Code', 'Category Code'))
164
                ->setDescription(_t('ProductCategory.CodeDescription', 'copy/paste from FoxyCart')),
165
            TextField::create('Title')
166
                ->setTitle(_t('ProductCategory.Title', 'Category Title'))
167
                ->setDescription(_t('ProductCategory.TitleDescription', 'copy/paste from FoxyCart')),
168
            DropdownField::create(
169
                'DeliveryType',
170
                'Delivery Type',
171
                singleton('ProductCategory')->dbObject('DeliveryType')->enumValues()
172
            )->setEmptyString('')
173
        );
174
175
        $this->extend('updateCMSFields', $fields);
176
        */
177
178
        return $fields;
179
    }
180
181
    /**
182
     *
183
     */
184
    public function requireDefaultRecords()
185
    {
186
        parent::requireDefaultRecords();
187
        $allCats = DataObject::get('ProductCategory');
188
        if (!$allCats->count()) {
189
            $cat = new ProductCategory();
190
            $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...
191
            $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...
192
            $cat->write();
193
        }
194
    }
195
196
    /**
197
     * @param bool $member
198
     * @return bool
199
     */
200
    public function canView($member = false)
201
    {
202
        return true;
203
    }
204
205
    /**
206
     * @param null $member
207
     * @return bool|int
208
     */
209
    public function canEdit($member = null)
210
    {
211
        return Permission::check('Product_CANCRUD', 'any', $member);
212
    }
213
214
    /**
215
     * @param null $member
216
     * @return bool|int
217
     */
218
    public function canDelete($member = null)
219
    {
220
221
        //don't allow deletion of DEFAULT category
222
        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...
223
    }
224
225
    /**
226
     * @param null $member
227
     * @return bool|int
228
     */
229
    public function canCreate($member = null)
230
    {
231
        return Permission::check('Product_CANCRUD', 'any', $member);
232
    }
233
234
    /**
235
     * @return array
236
     */
237
    public function getShippingOptions()
238
    {
239
        return [
240
            'shipped' => 'Shipped using live shipping rates',
241
            'downloaded' => 'Downloaded by the customer',
242
            'flat_rate' => 'Shipped using a flat rate fee',
243
            'pickup' => 'Picked up by the customer',
244
            'notshipped' => 'No Shipping',
245
        ];
246
    }
247
248
    /**
249
     * @return array
250
     */
251
    public function getShippingFlatRateTypes()
252
    {
253
        return [
254
            'per_order' => 'Charge per order',
255
            'per_item' => 'Charge per item',
256
        ];
257
    }
258
259
    /**
260
     * @return array
261
     */
262
    public function getHandlingFeeTypes()
263
    {
264
        return [
265
            'flat_per_order' => 'Flat fee per order with products in this category',
266
            'flat_per_item' => 'Flat fee per product in this category',
267
            'flat_percent' => 'Flat fee per shipment + % of price for products in this category',
268
            'flat_percent_with_minimum' => 'Flat fee per shipment OR % of order total with products in this category. Whichever is greater.',
269
        ];
270
    }
271
272
    /**
273
     * @return array
274
     */
275
    public function getDiscountTypes()
276
    {
277
        return [
278
            'quantity_amount' => 'Discount by an amount based on the quantity',
279
            'quantity_percentage' => 'Discount by a percentage based on the quantity',
280
            'price_amount' => 'Discount by an amount based on the price in this category',
281
            'price_percentage' => 'Discount by a percentage based on the price in this category',
282
        ];
283
    }
284
285
    /**
286
     * @return array
287
     */
288
    public function getDataMap()
289
    {
290
        return [
291
            '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...
292
            '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...
293
            '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...
294
            '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...
295
            '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...
296
            '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...
297
            '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...
298
            '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...
299
            '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...
300
            '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...
301
            '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...
302
            '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...
303
            '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...
304
            '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...
305
            '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...
306
            '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...
307
            '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...
308
            '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...
309
        ];
310
    }
311
312
    /**
313
     *
314
     */
315
    public function onAfterWrite()
316
    {
317
        parent::onAfterWrite();
318
319
        if ($this->isChanged()) {
320
            if ($fc = new FoxyStripeClient()) {
321
                $fc->putCategory($this->getDataMap());
322
            }
323
        }
324
    }
325
326
    /**
327
     *
328
     */
329
    public function onAfterDelete()
330
    {
331
        parent::onAfterDelete();
332
333
        if ($fc = new FoxyStripeClient()) {
334
            $fc->deleteCategory($this->getDataMap());
335
        }
336
    }
337
}
338