Code Duplication    Length = 9-13 lines in 4 locations

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

@@ 1443-1455 (lines=13) @@
1440
     * @param int $productType The type of product
1441
     * @return int The number of affected rows. Otherwise return false
1442
     */
1443
    public function updateItem(array $itemData, $productId, $productType)
1444
    {
1445
        $itemTable = Database::get_main_table(BuyCoursesPlugin::TABLE_ITEM);
1446
1447
        return Database::update(
1448
            $itemTable,
1449
            $itemData,
1450
            [
1451
                'product_id = ? AND ' => intval($productId),
1452
                'product_type' => $productType
1453
            ]
1454
        );
1455
    }
1456
1457
    /**
1458
     * Remove all beneficiaries for a item
@@ 1663-1673 (lines=11) @@
1660
     * @param int $status The status to set (-1 to cancel, 0 to pending, 1 to completed)
1661
     * @return array
1662
     */
1663
    public function setStatusPayouts($payoutId, $status)
1664
    {
1665
        $payoutsTable = Database::get_main_table(BuyCoursesPlugin::TABLE_PAYPAL_PAYOUTS);
1666
1667
        Database::update(
1668
            $payoutsTable,
1669
            ['status' => intval($status)],
1670
            ['id = ?' => intval($payoutId)]
1671
        );
1672
1673
    }
1674
1675
    /**
1676
     * Gets the stored platform commission params
@@ 1694-1702 (lines=9) @@
1691
     * @param int $params platform commission
1692
     * @return int The number of affected rows. Otherwise return false
1693
     */
1694
    public function updateCommission($params)
1695
    {
1696
        $commissionTable = Database::get_main_table(BuyCoursesPlugin::TABLE_COMMISSION);
1697
1698
        return Database::update(
1699
            $commissionTable,
1700
            ['commission' => intval($params['commission'])]
1701
        );
1702
    }
1703
1704
    /**
1705
     * Register addicional service
@@ 2108-2117 (lines=10) @@
2105
     * @param int $newStatus The new status
2106
     * @return boolean
2107
     */
2108
    private function updateServiceSaleStatus($serviceSaleId, $newStatus = self::SERVICE_STATUS_PENDING)
2109
    {
2110
        $serviceSaleTable = Database::get_main_table(self::TABLE_SERVICES_SALE);
2111
2112
        return Database::update(
2113
            $serviceSaleTable,
2114
            ['status' => intval($newStatus)],
2115
            ['id = ?' => intval($serviceSaleId)]
2116
        );
2117
    }
2118
2119
    /**
2120
     * Register a Service sale