FoxyStripeProductFormFieldExtension   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 6
c 1
b 0
f 0
dl 0
loc 13
ccs 0
cts 6
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A updateAttributes() 0 8 4
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