Code Duplication    Length = 28-28 lines in 2 locations

src/Action/Api/CancelTransactionAction.php 1 location

@@ 9-36 (lines=28) @@
6
use PayumTW\Mypay\Request\Api\CancelTransaction;
7
use Payum\Core\Exception\RequestNotSupportedException;
8
9
class CancelTransactionAction extends BaseApiAwareAction
10
{
11
    /**
12
     * {@inheritdoc}
13
     *
14
     * @param $request RefundTransaction
15
     */
16
    public function execute($request)
17
    {
18
        RequestNotSupportedException::assertSupports($this, $request);
19
20
        $details = ArrayObject::ensureArrayObject($request->getModel());
21
22
        $details->validateNotEmpty(['uid', 'key']);
23
24
        $details->replace($this->api->cancelTransaction((array) $details));
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function supports($request)
31
    {
32
        return
33
            $request instanceof CancelTransaction &&
34
            $request->getModel() instanceof \ArrayAccess;
35
    }
36
}
37

src/Action/Api/RefundTransactionAction.php 1 location

@@ 9-36 (lines=28) @@
6
use PayumTW\Mypay\Request\Api\RefundTransaction;
7
use Payum\Core\Exception\RequestNotSupportedException;
8
9
class RefundTransactionAction extends BaseApiAwareAction
10
{
11
    /**
12
     * {@inheritdoc}
13
     *
14
     * @param $request RefundTransaction
15
     */
16
    public function execute($request)
17
    {
18
        RequestNotSupportedException::assertSupports($this, $request);
19
20
        $details = ArrayObject::ensureArrayObject($request->getModel());
21
22
        $details->validateNotEmpty(['uid', 'key', 'cost']);
23
24
        $details->replace($this->api->refundTransaction((array) $details));
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function supports($request)
31
    {
32
        return
33
            $request instanceof RefundTransaction &&
34
            $request->getModel() instanceof \ArrayAccess;
35
    }
36
}
37