1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-15 23:52:33 +01:00
invoiceninja/app/Repositories/Import/Quickbooks/Repository.php

38 lines
1.0 KiB
PHP
Raw Normal View History

2024-07-29 22:16:48 +02:00
<?php
namespace App\Repositories\Import\QuickBooks;
use Illuminate\Support\Collection;
use App\Repositories\Import\Quickbooks\Contracts\RepositoryInterface;
use App\Services\Import\Quickbooks\Contracts\SdkInterface as QuickbooksInterface;
use App\Repositories\Import\Quickbooks\Transformers\Transformer as QuickbooksTransformer;
abstract class Repository implements RepositoryInterface
{
protected string $entity;
protected QuickbooksInterface $db;
protected QuickbooksTransformer $transfomer;
public function __construct(QuickbooksInterface $db, QuickbooksTransformer $transfomer)
{
$this->db= $db;
$this->transformer = $transfomer;
}
public function count() : int {
return $this->db->totalRecords($this->entity);
}
public function all() : Collection
{
return $this->get($this->count());
}
public function get(int $max = 100): Collection
{
return $this->transformer->transform($this->db->fetchRecords($this->entity, $max), $this->entity);
}
}