HasPagination::setSinceToken()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1.125

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 4
cp 0.5
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1.125
1
<?php
2
3
namespace Omnipay\Spreedly\Message\Concerns;
4
5
use Omnipay\Common\CreditCard;
6
use Omnipay\Common\Exception\InvalidRequestException;
7
use Omnipay\Spreedly\BankAccount;
8
9
trait HasPagination
10
{
11 12
    public function getOrder()
12
    {
13 12
        return $this->getParameter('order');
0 ignored issues
show
Bug introduced by
It seems like getParameter() 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...
14
    }
15
16 4
    public function setOrder($value)
17
    {
18 4
        return $this->setParameter('order', $value);
0 ignored issues
show
Bug introduced by
It seems like setParameter() 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...
19
    }
20
21 12
    public function getSinceToken()
22
    {
23 12
        return $this->getParameter('since_token');
0 ignored issues
show
Bug introduced by
It seems like getParameter() 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...
24
    }
25
26 4
    public function setSinceToken($value)
27
    {
28 4
        return $this->setParameter('since_token', $value);
0 ignored issues
show
Bug introduced by
It seems like setParameter() 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...
29
    }
30
31
    /**
32
     * Map data with existing parameters
33
     *
34
     * @param array $data
35
     * @return array
36
     */
37 12
    protected function fillPaginationParameters($data)
38
    {
39 12
        if ($order = $this->getOrder()) {
40 4
            $data['order'] = $order;
41 4
        }
42
43 12
        if ($sinceToken = $this->getSinceToken()) {
44 4
            $data['since_token'] = $sinceToken;
45 4
        }
46
47 12
        return $data;
48
    }
49
}
50