mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-12-24 23:07:48 -05:00
- Removed unused uses - Type hinting for method parameters - Removed commented code - Introduced comments for classes and methods - Short array syntax
30 lines
721 B
PHP
30 lines
721 B
PHP
<?php namespace App\Ninja\Import\CSV;
|
|
|
|
use App\Ninja\Import\BaseTransformer;
|
|
use League\Fractal\Resource\Item;
|
|
|
|
/**
|
|
* Class ProductTransformer
|
|
*/
|
|
class ProductTransformer extends BaseTransformer
|
|
{
|
|
/**
|
|
* @param $data
|
|
* @return bool|Item
|
|
*/
|
|
public function transform($data)
|
|
{
|
|
if (empty($data->product_key) || $this->hasProduct($data->product_key)) {
|
|
return false;
|
|
}
|
|
|
|
return new Item($data, function ($data) {
|
|
return [
|
|
'product_key' => $this->getString($data, 'product_key'),
|
|
'notes' => $this->getString($data, 'notes'),
|
|
'cost' => $this->getNumber($data, 'cost'),
|
|
];
|
|
});
|
|
}
|
|
}
|