mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
add transformer for underline raw data
This commit is contained in:
parent
4c3829b8c1
commit
85220bf58f
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Import\Quickbooks\Transformers;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class Transformer
|
||||
{
|
||||
public function transform(array $items, string $type): Collection
|
||||
{
|
||||
if(!method_exists($this, ($method = "transform{$type}s"))) throw new \InvalidArgumentException("Unknown type: $type");
|
||||
|
||||
return call_user_func([$this, $method], $items);
|
||||
}
|
||||
|
||||
protected function transformInvoices(array $items): Collection
|
||||
{
|
||||
return $this->transformation($items, []);
|
||||
}
|
||||
|
||||
protected function transformCustomers(array $items): Collection
|
||||
{
|
||||
return $this->transformation($items, [
|
||||
'CompanyName',
|
||||
'PrimaryPhone',
|
||||
'BillAddr',
|
||||
'ShipAddr',
|
||||
'Notes',
|
||||
'GivenName',
|
||||
'FamilyName',
|
||||
'PrimaryEmailAddr',
|
||||
'CurrencyRef',
|
||||
'MetaData'
|
||||
]);
|
||||
}
|
||||
|
||||
protected function transformation(array $items, array $keys) : Collection
|
||||
{
|
||||
return collect($items)->select($keys);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user