Completed
Push — master ( 92e87d...c7ea00 )
by Raza
03:11
created

PayPalTransactions::getTransactionDetails()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
namespace Srmklive\PayPal\Traits;
4
5
trait PayPalTransactions
6
{
7
    /**
8
     * Perform a GetTransactionDetails API call on PayPal.
9
     *
10
     * @param string $transaction
11
     *
12
     * @return array
13
     */
14
    public function getTransactionDetails($transaction)
15
    {
16
        $this->setRequestData([
0 ignored issues
show
Bug introduced by
It seems like setRequestData() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
17
            'TRANSACTIONID' => $transaction,
18
        ]);
19
20
        return $this->doPayPalRequest('GetTransactionDetails');
0 ignored issues
show
Bug introduced by
It seems like doPayPalRequest() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
21
    }
22
23
    /**
24
     * Perform a DoReferenceTransaction API operation on PayPal.
25
     *
26
     * @param string $transaction
27
     * @param string $action
28
     *
29
     * @return array
30
     */
31
    public function doReferenceTransaction($transaction, $action)
32
    {
33
        $this->setRequestData([
0 ignored issues
show
Bug introduced by
It seems like setRequestData() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
34
            'REFERENCEID'       => $transaction,
35
            'PAYMENTACTION'     => $action,
36
        ]);
37
38
        return $this->doPayPalRequest('DoReferenceTransaction');
0 ignored issues
show
Bug introduced by
It seems like doPayPalRequest() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
39
    }
40
41
    /**
42
     * Refund PayPal Transaction.
43
     *
44
     * @param string $transaction
45
     * @param float  $amount
46
     *
47
     * @return array
48
     */
49
    public function refundTransaction($transaction, $amount = 0.00)
50
    {
51
        $this->setRequestData([
0 ignored issues
show
Bug introduced by
It seems like setRequestData() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
52
            'TRANSACTIONID' => $transaction,
53
        ]);
54
55
        if ($amount > 0) {
56
            $this->post = $this->post->merge([
0 ignored issues
show
Bug introduced by
The property post does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
57
                'REFUNDTYPE' => 'Partial',
58
                'AMT'        => $amount,
59
            ]);
60
        }
61
62
        return $this->doPayPalRequest('RefundTransaction');
0 ignored issues
show
Bug introduced by
It seems like doPayPalRequest() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
63
    }
64
65
    /**
66
     * Search Transactions On PayPal.
67
     *
68
     * @param array $post
69
     *
70
     * @return array
71
     */
72
    public function searchTransactions($post)
73
    {
74
        $this->setRequestData($post);
0 ignored issues
show
Bug introduced by
It seems like setRequestData() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
75
76
        return $this->doPayPalRequest('TransactionSearch');
0 ignored issues
show
Bug introduced by
It seems like doPayPalRequest() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
77
    }
78
}
79