Code Duplication    Length = 9-13 lines in 4 locations

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

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