Let's say there is class called AccountingService.
Using this class I fetch all kinds of ecommerce records like products, customers, etc. The fetching happens inside a controller action. Once fetched, I should process and save these records to some kind of ecommerce shop.
What I want to do is create an implementation of Shop
namespace PrestaShop;
use Shop\ShopInterface;
class Shop implements ShopInterface
{
public function saveProduct(array $products)
public function saveProductQuantities(array $productQuantities)
public function saveCustomers(array $customers)
public function getOrder($orderReference)
}
The problem is that the methods are incredibly long, because many foreign keys, pivot tables, relations need to be saved to MySQL tables. I would like to extract product, customer, quantitiy methods into seperate classes/components that work as dependencies for this class.
I am using array because the fetched records are in bulk (lets say 10k), so I can't instantiate an object for each record and save it via active record.
Using separate Repository pattern objects doesn't make sense to me, because all these objects product, customer, quantity are related and have connected tables.
I'm looking for advice on how to split up the implementation PrestaShop\Shop into smaller classes.
Any other advice on hwo to structure this app logic is welcomed.