Passed
Branch master (8d4084)
by Antony
03:09 queued 01:05
created

OrderItem   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 10
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A onBeforeWrite() 0 5 2
1
<?php
2
3
namespace AntonyThorpe\SilvershopUnleashed\Extension;
4
5
use AntonyThorpe\SilverShopUnleashed\Utils;
6
use SilverStripe\ORM\DataExtension;
7
8
class OrderItem extends DataExtension
9
{
10
    /**
11
     * Apply Guid if absent
12
     */
13
    public function onBeforeWrite()
14
    {
15
        parent::onBeforeWrite();
16
        if (!$this->owner->getField("Guid")) {
17
            $this->owner->Guid = (string) Utils::createGuid();
18
        }
19
    }
20
}
21