Search   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
c 1
b 0
f 0
dl 0
loc 45
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getQuery() 0 10 1
1
<?php
2
3
namespace Viktoras\Scryfall\Client\Request\Cards;
4
5
use Viktoras\Scryfall\Client\Request\AbstractRequest;
6
use Viktoras\Scryfall\Client\Request\Traits\Paginatable;
7
8
class Search extends AbstractRequest
9
{
10
    use Paginatable;
11
12
    /** Sorting direction */
13
    public const SORTING_DIRECTION_AUTO = 'auto';
14
    public const SORTING_DIRECTION_ASC  = 'asc';
15
    public const SORTING_DIRECTION_DESC = 'desc';
16
17
    /** Sorting order */
18
    public const SORTING_ORDER_NAME   = 'name';
19
    public const SORTING_ORDER_CMC    = 'cmc';
20
    public const SORTING_ORDER_SET    = 'set';
21
    public const SORTING_ORDER_RARITY = 'rarity';
22
23
    /**
24
     * @var string
25
     */
26
    protected $order = self::SORTING_ORDER_NAME;
27
28
    /**
29
     * @var string
30
     */
31
    protected $dir = self::SORTING_DIRECTION_AUTO;
32
33
    /**
34
     * @var string
35
     */
36
    protected $query;
37
38
    public function __construct(string $query)
39
    {
40
        $this->query = $query;
41
    }
42
43
    public function getQuery(): string
44
    {
45
        return 'cards/search?' . http_build_query(
46
                [
47
                    'q'      => $this->query,
48
                    'order'  => $this->order,
49
                    'dir'    => $this->dir,
50
                    'page'   => $this->getPage(),
51
                    'format' => $this->format,
52
                    'pretty' => $this->isPretty()
53
                ]
54
            );
55
    }
56
}
57