Test Failed
Push — master ( dd0813...14557d )
by Antony
06:13
created

ProductBulkLoader   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 46
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;
4
5
use AntonyThorpe\Consumer\BulkLoader;
6
7
class ProductBulkLoader extends BulkLoader
8
{
9
    /**
10
     * The default behaviour for creating relations
11
     * @var boolean
12
     */
13
    protected $relationCreateDefault = false;
14
15
    /**
16
     * Specify a colsure to be run on every imported record.
17
     * @var Closure
0 ignored issues
show
Bug introduced by
The type AntonyThorpe\SilverShopUnleashed\Closure was not found. Did you mean Closure? If so, make sure to prefix the type with \.
Loading history...
18
     */
19
    public $recordCallback = 'setOtherProperties';
20
21
    /**
22
     * Column Map
23
     * @var array
24
     */
25
    public $columnMap = [
26
        'Guid' => 'Guid',
27
        'ProductCode' => 'InternalItemID',
28
        'ProductDescription' => 'Title',
29
        'ProductGroup' => 'Parent',
30
        'DefaultSellPrice' => 'BasePrice',
31
        'Width' => 'Width',
32
        'Height' => 'Height',
33
        'Depth' => 'Depth'
34
    ];
35
36
    /**
37
     * Keys that need to be unique
38
     * @var array
39
     */
40
    public $duplicateChecks = [
41
        'Guid', 'InternalItemID'
42
    ];
43
44
    /**
45
     * Specify a colsure to be run on every imported record to set other records
46
     * @param object $obj The placeholder
47
     * @param array $record A row from the external API
48
     */
49
    public function setOtherProperties(&$obj, $record)
50
    {
51
        if ($record['Obsolete']) {
52
            $obj->AllowPurchase = 0;
53
        }
54
    }
55
}
56