Code Duplication    Length = 9-13 lines in 4 locations

plugin/buycourses/src/buy_course_plugin.class.php 4 locations

@@ 1421-1433 (lines=13) @@
1418
     * @param int $productType The type of product
1419
     * @return int The number of affected rows. Otherwise return false
1420
     */
1421
    public function updateItem(array $itemData, $productId, $productType)
1422
    {
1423
        $itemTable = Database::get_main_table(BuyCoursesPlugin::TABLE_ITEM);
1424
1425
        return Database::update(
1426
            $itemTable,
1427
            $itemData,
1428
            [
1429
                'product_id = ? AND ' => intval($productId),
1430
                'product_type' => $productType
1431
            ]
1432
        );
1433
    }
1434
1435
    /**
1436
     * Remove all beneficiaries for a item
@@ 1641-1651 (lines=11) @@
1638
     * @param int $status The status to set (-1 to cancel, 0 to pending, 1 to completed)
1639
     * @return array
1640
     */
1641
    public function setStatusPayouts($payoutId, $status)
1642
    {
1643
        $payoutsTable = Database::get_main_table(BuyCoursesPlugin::TABLE_PAYPAL_PAYOUTS);
1644
1645
        Database::update(
1646
            $payoutsTable,
1647
            ['status' => intval($status)],
1648
            ['id = ?' => intval($payoutId)]
1649
        );
1650
1651
    }
1652
1653
    /**
1654
     * Gets the stored platform commission params
@@ 1672-1680 (lines=9) @@
1669
     * @param int $params platform commission
1670
     * @return int The number of affected rows. Otherwise return false
1671
     */
1672
    public function updateCommission($params)
1673
    {
1674
        $commissionTable = Database::get_main_table(BuyCoursesPlugin::TABLE_COMMISSION);
1675
1676
        return Database::update(
1677
            $commissionTable,
1678
            ['commission' => intval($params['commission'])]
1679
        );
1680
    }
1681
1682
    /**
1683
     * Register addicional service
@@ 2081-2090 (lines=10) @@
2078
     * @param int $newStatus The new status
2079
     * @return boolean
2080
     */
2081
    private function updateServiceSaleStatus($serviceSaleId, $newStatus = self::SERVICE_STATUS_PENDING)
2082
    {
2083
        $serviceSaleTable = Database::get_main_table(self::TABLE_SERVICES_SALE);
2084
2085
        return Database::update(
2086
            $serviceSaleTable,
2087
            ['status' => intval($newStatus)],
2088
            ['id = ?' => intval($serviceSaleId)]
2089
        );
2090
    }
2091
2092
    /**
2093
     * Register a Service sale