updateAttributes()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 8
rs 10
c 0
b 0
f 0
ccs 0
cts 6
cp 0
cc 4
nc 3
nop 1
crap 20
1
<?php
2
3
namespace Dynamic\FoxyStripe\ORM;
4
5
use SilverStripe\CMS\Controllers\ContentController;
6
use SilverStripe\Control\Controller;
7
use SilverStripe\ORM\DataExtension;
8
9
/**
10
 * Class FoxyStripeProductFormFieldExtension.
11
 */
12
class FoxyStripeProductFormFieldExtension extends DataExtension
13
{
14
    /**
15
     * @param $attributes
16
     */
17
    public function updateAttributes(&$attributes)
18
    {
19
        if (Controller::curr() instanceof ContentController &&
20
            Controller::curr()->data()->Classname == 'DonationProduct'
21
        ) {
22
            if (preg_match('/^(product_id)/', $this->owner->getName())) {
23
                $attributes['h:name'] = $attributes['name'];
24
                unset($attributes['name']);
25
            }
26
        }
27
    }
28
}
29