OrderModifierExtension::onBeforeWrite()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace AntonyThorpe\SilverShopUnleashed\Extension;
4
5
use SilverShop\Model\Modifiers\OrderModifier;
0 ignored issues
show
Bug introduced by
The type SilverShop\Model\Modifiers\OrderModifier was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use SilverStripe\Core\Extension;
0 ignored issues
show
Bug introduced by
The type SilverStripe\Core\Extension was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use AntonyThorpe\SilverShopUnleashed\Utils;
8
9
/**
10
 * @extends Extension<OrderModifier&static>
11
 */
12
class OrderModifierExtension extends Extension
13
{
14
    /**
15
     * Map OrderModifier
16
     * @config
17
     */
18
    private static string $product_code = '';
0 ignored issues
show
introduced by
The private property $product_code is not used, and could be removed.
Loading history...
19
20
    /**
21
     * Apply Guid if absent
22
     */
23
    public function onBeforeWrite(): void
24
    {
25
        if (!$this->getOwner()->getField('Guid')) {
26
            $this->getOwner()->Guid = Utils::createGuid();
27
        }
28
    }
29
}
30