public static function getTopByNumOfOrders($dateFrom = null, $dateTo = null, int $limit = 10) : array { $db = DataBaseHelper::getConnection(); list($dateFrom, $dateTo) = DateHelper::formatDates($dateFrom, $dateTo); $handle = static::queryTopByNumOfOrders($dateFrom, $dateTo, $limit, $db); // create customers foreach ($handle as $customer) { $customers[] = static::createNew($customer); } //close database connection $db = null; return $customers ?? []; }
public static function getTopOrdersByRevenue($dateFrom = null, $dateTo = null, int $limit = 10) : array { $db = DataBaseHelper::getConnection(); list($dateFrom, $dateTo) = DateHelper::formatDates($dateFrom, $dateTo); $handle = static::queryTopOrdersByRevenue($dateFrom, $dateTo, $limit, $db); foreach ($handle as $order) { $newOrder = static::createNew($order); $newOrder->setTotalRevenue(new Money($order['totalPrice'])); $orders[] = $newOrder; } //close database connection $db = null; return $orders ?? []; }