ProductBulkLoader   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A setOtherProperties() 0 4 2
1
<?php
2
3
namespace AntonyThorpe\SilverShopUnleashed\BulkLoader;
4
5
use AntonyThorpe\Consumer\BulkLoader;
0 ignored issues
show
Bug introduced by
The type AntonyThorpe\Consumer\BulkLoader 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 SilverShop\Page\Product;
0 ignored issues
show
Bug introduced by
The type SilverShop\Page\Product 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
8
class ProductBulkLoader extends BulkLoader
9
{
10
    /**
11
     * The default behaviour for creating relations
12
     */
13
    protected bool $relationCreateDefault = false;
14
15
    /**
16
     * Specify a colsure to be run on every imported record.
17
     */
18
    public $recordCallback = 'setOtherProperties';
19
20
    /**
21
     * Column Map
22
     * @var array
23
     */
24
    public $columnMap = [
25
        'Guid' => 'Guid',
26
        'ProductCode' => 'InternalItemID',
27
        'ProductDescription' => 'Title',
28
        'ProductGroup' => 'Parent',
29
        'DefaultSellPrice' => 'BasePrice',
30
        'Width' => 'Width',
31
        'Height' => 'Height',
32
        'Depth' => 'Depth'
33
    ];
34
35
    /**
36
     * Keys that need to be unique
37
     * @var array
38
     */
39
    public $duplicateChecks = [
40
        'Guid', 'InternalItemID'
41
    ];
42
43
    /**
44
     * Specify a colsure to be run on every imported record to set other records
45
     * @param Product $obj The placeholder
46
     * @param array $record A row from the external API
47
     */
48
    public function setOtherProperties(Product &$obj, array $record): void
49
    {
50
        if ($record['Obsolete']) {
51
            $obj->AllowPurchase = false;
52
        }
53
    }
54
}
55