Code Duplication    Length = 38-46 lines in 4 locations

src/Networks/Admitad.php 1 location

@@ 143-181 (lines=39) @@
140
	 * @return array of Transaction
141
	 * @throws \Exception
142
	 */
143
    public function getSales(\DateTime $dateFrom, \DateTime $dateTo, array $arrMerchantID = array()) : array
144
    {
145
146
        $arrResult = array();
147
        $transactionList = $this->_network->getTransactionList($arrMerchantID, $dateFrom, $dateTo);
148
        foreach($transactionList as $transaction) {
149
            $Transaction = Transaction::createInstance();
150
            if (isset($transaction['currency']) && !empty($transaction['currency'])) {
151
                $Transaction->currency = $transaction['currency'];
152
            } else {
153
                $Transaction->currency = "EUR";
154
            }
155
            $Transaction->status = $transaction['status'];
156
            $Transaction->amount = $transaction['amount'];
157
            array_key_exists_safe( $transaction,'custom_id' ) ? $Transaction->custom_ID = $transaction['custom_id'] : $Transaction->custom_ID = '';
158
            $Transaction->title = '';
159
            $Transaction->unique_ID = $transaction['unique_id'];
160
            $Transaction->commission = $transaction['commission'];
161
            $date = new \DateTime($transaction['date']);
162
            $Transaction->date = $date; // $date->format('Y-m-d H:i:s');
163
            // Future use - Only few providers returns these dates values - <PN> - 2017-06-29
164
            if (isset($transaction['click_date']) && !empty($transaction['click_date'])) {
165
                $Transaction->click_date = new \DateTime($transaction['click_date']);
166
            }
167
            if (isset($transaction['update_date']) && !empty($transaction['update_date'])) {
168
                $Transaction->update_date = new \DateTime($transaction['update_date']);
169
            }
170
            $Transaction->merchant_ID = $transaction['merchantId'];
171
            $Transaction->campaign_name =  $transaction['merchantName'];
172
            $Transaction->IP =  $transaction['IP'];
173
            $Transaction->approved = false;
174
            if ($Transaction->status == \Oara\Utilities::STATUS_CONFIRMED){
175
                $Transaction->approved = true;
176
            }
177
            $arrResult[] = $Transaction;
178
        }
179
180
        return $arrResult;
181
    }
182
183
    /**
184
     * @param \DateTime $dateFrom

src/Networks/Daisycon.php 1 location

@@ 157-194 (lines=38) @@
154
     * @param int $merchantID
155
     * @return array of Transaction
156
     */
157
    public function getSales(\DateTime $dateFrom, \DateTime $dateTo, array $arrMerchantID = array()) : array
158
    {
159
        $arrResult = array();
160
        $transactionList = $this->_network->getTransactionList($arrMerchantID, $dateFrom, $dateTo);
161
        foreach($transactionList as $transaction) {
162
            $Transaction = Transaction::createInstance();
163
            if (isset($transaction['currency']) && !empty($transaction['currency'])) {
164
                $Transaction->currency = $transaction['currency'];
165
            } else {
166
                $Transaction->currency = "EUR";
167
            }
168
            $Transaction->status = $transaction['status'];
169
            $Transaction->amount = $transaction['amount'];
170
            array_key_exists_safe( $transaction,'custom_id' ) ? $Transaction->custom_ID = $transaction['custom_id'] : $Transaction->custom_ID = '';
171
            $Transaction->title = '';
172
            $Transaction->unique_ID = $transaction['unique_id'];
173
            $Transaction->commission = $transaction['commission'];
174
            $date = new \DateTime($transaction['date']);
175
            $Transaction->date = $date; // $date->format('Y-m-d H:i:s');
176
            // Future use - Only few providers returns these dates values - <PN> - 2017-06-29
177
            if (isset($transaction['click_date']) && !empty($transaction['click_date'])) {
178
                $Transaction->click_date = new \DateTime($transaction['click_date']);
179
            }
180
            if (isset($transaction['update_date']) && !empty($transaction['update_date'])) {
181
                $Transaction->update_date = new \DateTime($transaction['update_date']);
182
            }
183
            $Transaction->merchant_ID = $transaction['merchantId'];
184
            $Transaction->campaign_name =  $transaction['merchantName'];
185
            $Transaction->IP =  $transaction['IP'];
186
            $Transaction->approved = false;
187
            if ($Transaction->status==\Oara\Utilities::STATUS_CONFIRMED){
188
                $Transaction->approved = true;
189
            }
190
            $arrResult[] = $Transaction;
191
        }
192
193
        return $arrResult;
194
    }
195
196
    /**
197
     * @param \DateTime $dateFrom

src/Networks/Ebay.php 1 location

@@ 109-147 (lines=39) @@
106
     * @param int $merchantID
107
     * @return array of Transaction
108
     */
109
    public function getSales(\DateTime $dateFrom, \DateTime $dateTo, array $arrMerchantID = array()): array
110
    {
111
        $arrResult = array();
112
        $transactionList = $this->_network->getTransactionList($arrMerchantID, $dateFrom, $dateTo);
113
        foreach ($transactionList as $transaction) {
114
            $Transaction = Transaction::createInstance();
115
116
            if (isset($transaction['currency']) && !empty($transaction['currency'])) {
117
                $Transaction->currency = $transaction['currency'];
118
            } else {
119
                $Transaction->currency = "EUR";
120
            }
121
            $Transaction->status = $transaction['status'];
122
            $Transaction->amount = $transaction['amount'];
123
            array_key_exists_safe($transaction, 'custom_id') ? $Transaction->custom_ID = $transaction['custom_id'] : $Transaction->custom_ID = '';
124
            $Transaction->title = '';
125
            $Transaction->unique_ID = $transaction['unique_id'];
126
            $Transaction->commission = $transaction['commission'];
127
            $date = new \DateTime($transaction['date']);
128
            $Transaction->date = $date;
129
            // Future use - Only few providers returns these dates values - <PN> - 2017-06-29
130
            if (isset($transaction['click_date']) && !empty($transaction['click_date'])) {
131
                $Transaction->click_date = new \DateTime($transaction['click_date']);
132
            }
133
            if (isset($transaction['update_date']) && !empty($transaction['update_date'])) {
134
                $Transaction->update_date = new \DateTime($transaction['update_date']);
135
            }
136
            $Transaction->merchant_ID = $transaction['merchantId'];
137
            $Transaction->campaign_name = $transaction['merchantName'];
138
            // $Transaction->IP =  $transaction['IP'];
139
            $Transaction->approved = false;
140
            if ($Transaction->status == \Oara\Utilities::STATUS_CONFIRMED) {
141
                $Transaction->approved = true;
142
            }
143
            $arrResult[] = $Transaction;
144
        }
145
146
        return $arrResult;
147
    }
148
149
    /**
150
     * @param \DateTime $dateFrom

src/Networks/TradeTracker.php 1 location

@@ 135-180 (lines=46) @@
132
     * @param int $merchantID
133
     * @return array of Transaction
134
     */
135
    public function getSales(\DateTime $dateFrom, \DateTime $dateTo, array $arrMerchantID = array()) : array
136
    {
137
        /*
138
        if (count( $arrMerchantID ) < 1) {
139
            $merchants = $this->getMerchants();
140
            foreach ($merchants as $merchant) {
141
                $arrMerchantID[$merchant->merchant_ID] = ['cid' => $merchant->merchant_ID, 'name' => $merchant->name];
142
            }
143
        }
144
        */
145
        $arrResult = array();
146
        $transactionList = $this->_network->getTransactionList($arrMerchantID, $dateFrom, $dateTo);
147
        foreach($transactionList as $transaction) {
148
            $Transaction = Transaction::createInstance();
149
            if (isset($transaction['currency']) && !empty($transaction['currency'])) {
150
                $Transaction->currency = $transaction['currency'];
151
            } else {
152
                $Transaction->currency = "EUR";
153
            }
154
            $Transaction->status = $transaction['status'];
155
            $Transaction->amount = $transaction['amount'];
156
            array_key_exists_safe( $transaction,'custom_id' ) ? $Transaction->custom_ID = $transaction['custom_id'] : $Transaction->custom_ID = '';
157
            $Transaction->title = '';
158
            $Transaction->unique_ID = $transaction['unique_id'];
159
            $Transaction->commission = $transaction['commission'];
160
            $date = new \DateTime($transaction['date']);
161
            $Transaction->date = $date; // $date->format('Y-m-d H:i:s');
162
            // Future use - Only few providers returns these dates values - <PN> - 2017-06-29
163
            if (isset($transaction['click_date']) && !empty($transaction['click_date'])) {
164
                $Transaction->click_date = new \DateTime($transaction['click_date']);
165
            }
166
            if (isset($transaction['update_date']) && !empty($transaction['update_date'])) {
167
                $Transaction->update_date = new \DateTime($transaction['update_date']);
168
            }
169
            $Transaction->merchant_ID = $transaction['merchantId'];
170
            $Transaction->campaign_name =  $transaction['merchantName'];
171
            $Transaction->IP =  $transaction['IP'];
172
            $Transaction->approved = false;
173
            if ($Transaction->status==\Oara\Utilities::STATUS_CONFIRMED){
174
                $Transaction->approved = true;
175
            }
176
            $arrResult[] = $Transaction;
177
        }
178
179
        return $arrResult;
180
    }
181
182
    /**
183
     * @param \DateTime $dateFrom