QueryBuilder::username()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace MarkSitko\LaravelUnsplash\Queries;
4
5
trait QueryBuilder
6
{
7
    public $query = [];
8
9
    /* ###### List photos params ###### */
10
11
    /**
12
     * Page number to retrive.
13
     * @param int|string $param
14
     * @return MarkSitko\LaravelUnsplash\Queries\QueryBuilder
15
     */
16
    public function page( $param = null )
17
    {
18
        $this->query['page'] = $param ?? null;
19
        return $this;
20
    }
21
22
    /**
23
     * Number of items per page
24
     * @param int|string $param
25
     * @return MarkSitko\LaravelUnsplash\Queries\QueryBuilder
26
     */
27
    public function perPage( $param = null )
28
    {
29
        $this->query['per_page'] = $param ?? null;
30
        return $this;
31
    }
32
33
    /**
34
     * How to sort the photos.
35
     * @param int|string $param Valid values: latest, oldest, popular
36
     * @return MarkSitko\LaravelUnsplash\Queries\QueryBuilder
37
     */
38
    public function orderBy( $param = null )
39
    {
40
        $this->query['order_by'] = $param ?? null;
41
        return $this;
42
    }
43
44
45
    /* ###### Random photos params ###### */
46
47
    /**
48
     * Public collection ID(‘s) to filter selection. If multiple, comma-separated.
49
     * @param string $param
50
     * @return MarkSitko\LaravelUnsplash\Queries\QueryBuilder
51
     */
52
    public function collections( $param = null )
53
    {
54
        $this->query['collections'] = $param ?? null;
55
        return $this;
56
    }
57
58
    /**
59
     * Limit selection to featured photos.
60
     * @param string $param
61
     * @return MarkSitko\LaravelUnsplash\Queries\QueryBuilder
62
     */
63
    public function featured( $param = null )
64
    {
65
        $this->query['featured'] = $param ?? null;
66
        return $this;
67
    }
68
69
    /**
70
     * Limit selection to a single user.
71
     * @param string $param
72
     * @return MarkSitko\LaravelUnsplash\Queries\QueryBuilder
73
     */
74
    public function username( $param = null )
75
    {
76
        $this->query['username'] = $param ?? null;
77
        return $this;
78
    }
79
80
    /**
81
     * Filter search results by photo orientation.
82
     * @param string $param Valid values: landscape, portrait, and squarish
83
     * @return MarkSitko\LaravelUnsplash\Queries\QueryBuilder
84
     */
85
    public function orientation( $param = null )
86
    {
87
        $this->query['orientation'] = $param ?? null;
88
        return $this;
89
    }
90
91
    /**
92
     * Limit selection to photos matching a search term.
93
     * @param string $param
94
     * @return MarkSitko\LaravelUnsplash\Queries\QueryBuilder
95
     */
96
    public function term( $param = null )
97
    {
98
        $this->query['query'] = $param ?? null;
99
        return $this;
100
    }
101
102
    /**
103
     * The number of photos to return.
104
     * @param int|string $param min 1, max 30
105
     * @return MarkSitko\LaravelUnsplash\Queries\QueryBuilder
106
     */
107
    public function count( $param = null )
108
    {
109
        $this->query['count'] = $param ?? null;
110
        return $this;
111
    }
112
113
114
    /* ###### Photos Statistics params ###### */
115
116
    /**
117
     * The public id of the photo.
118
     * @param int|string $param required
119
     * @return MarkSitko\LaravelUnsplash\Queries\QueryBuilder
120
     */
121
    public function id( $param = null )
122
    {
123
        $this->query['id'] = $param ?? null;
124
        return $this;
125
    }
126
127
    /**
128
     * The frequency of the stats.
129
     * @param string $param default days
130
     * @return MarkSitko\LaravelUnsplash\Queries\QueryBuilder
131
     */
132
    public function resolution( $param = null )
133
    {
134
        $this->query['resolution'] = $param ?? null;
135
        return $this;
136
    }
137
138
    /**
139
     * The amount of for each stat.
140
     * @param int|string $param
141
     * @return MarkSitko\LaravelUnsplash\Queries\QueryBuilder
142
     */
143
    public function quantity( $param = null )
144
    {
145
        $this->query['quantity'] = $param ?? null;
146
        return $this;
147
    }
148
149
150
    /* ###### Search photos params ###### */
151
152
    /**
153
     * Filter results by color.
154
     * @param string $param Valid values are: black_and_white, black, white, yellow, orange, red, purple, magenta, green, teal, and blue.
155
     * @return MarkSitko\LaravelUnsplash\Queries\QueryBuilder
156
     */
157
    public function color( $param = null )
158
    {
159
        $this->query['color'] = $param ?? null;
160
        return $this;
161
    }
162
163
    /**
164
     * Query for search terms
165
     * @param string $param
166
     * @return MarkSitko\LaravelUnsplash\Queries\QueryBuilder
167
     */
168
    public function query( $param = null )
169
    {
170
        $this->query['query'] = $param ?? null;
171
        return $this;
172
    }
173
174
175
    public function getQuery()
176
    {
177
        return http_build_query($this->query, '', '&');
178
    }
179
180
}
181