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

ProductBulkLoader   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 45
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;
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
     */
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 object $obj The placeholder
46
     * @param array $record A row from the external API
47
     */
48
    public function setOtherProperties(&$obj, $record)
49
    {
50
        if ($record['Obsolete']) {
51
            $obj->AllowPurchase = 0;
52
        }
53
    }
54
}
55