TimelineSearchRequest::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Osnova\Services\Timeline\Requests;
4
5
class TimelineSearchRequest extends TimelineRequest
6
{
7
    /** @var string */
8
    protected $query;
9
10
    /** @var string */
11
    protected $orderBy;
12
13
    /** @var int */
14
    protected $page;
15
16
    /**
17
     * TimelineSearchRequest constructor.
18
     *
19
     * @param string $orderBy
20
     * @param int    $page
21
     */
22
    public function __construct(string $orderBy, int $page = 1)
23
    {
24
        parent::__construct('', 0, 0);
25
26
        $this->orderBy = $orderBy;
27
        $this->page = $page;
28
    }
29
30
    /**
31
     * Set request query.
32
     *
33
     * @param string $query
34
     *
35
     * @return TimelineSearchRequest
36
     */
37
    public function setQuery(string $query)
38
    {
39
        $this->query = $query;
40
41
        return $this;
42
    }
43
44
    /**
45
     * Get parameters for the current request.
46
     *
47
     * @return array
48
     */
49
    public function getParams()
50
    {
51
        return [
52
            'query' => $this->query,
53
            'order_by' => $this->orderBy,
54
            'page' => $this->page,
55
        ];
56
    }
57
}
58