1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the pexels-library package. |
5
|
|
|
* |
6
|
|
|
* (c) 2019 WEBEWEB |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace WBW\Library\Pexels\Model\Response; |
13
|
|
|
|
14
|
|
|
use WBW\Library\Pexels\Model\AbstractResponse; |
15
|
|
|
use WBW\Library\Pexels\Model\Photo; |
16
|
|
|
use WBW\Library\Pexels\Traits\PageTrait; |
17
|
|
|
use WBW\Library\Pexels\Traits\PerPageTrait; |
18
|
|
|
use WBW\Library\Pexels\Traits\UrlTrait; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Photos response. |
22
|
|
|
* |
23
|
|
|
* @author webeweb <https://github.com/webeweb/> |
24
|
|
|
* @package WBW\Library\Pexels\Model\Response |
25
|
|
|
*/ |
26
|
|
|
class PhotosResponse extends AbstractResponse { |
27
|
|
|
|
28
|
|
|
use PageTrait; |
29
|
|
|
use PerPageTrait; |
30
|
|
|
use UrlTrait; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Next page. |
34
|
|
|
* |
35
|
|
|
* @var string |
36
|
|
|
*/ |
37
|
|
|
private $nextPage; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Photos. |
41
|
|
|
* |
42
|
|
|
* @var Photo[] |
43
|
|
|
*/ |
44
|
|
|
private $photos; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Total results. |
48
|
|
|
* |
49
|
|
|
* @var int |
50
|
|
|
*/ |
51
|
|
|
private $totalResults; |
52
|
|
|
|
53
|
|
|
public function __construct() { |
54
|
|
|
parent::__construct(); |
55
|
|
|
$this->setPhotos([]); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Add a photo. |
60
|
|
|
* |
61
|
|
|
* @param Photo $photo The photo. |
62
|
|
|
* @return PhotosResponse Returns this photo response. |
63
|
|
|
*/ |
64
|
|
|
public function addPhoto(Photo $photo) { |
65
|
|
|
$this->photos[] = $photo; |
66
|
|
|
return $this; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Get the next page. |
71
|
|
|
* |
72
|
|
|
* @return string Returns the next page. |
73
|
|
|
*/ |
74
|
|
|
public function getNextPage() { |
75
|
|
|
return $this->nextPage; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Get the photos. |
80
|
|
|
* |
81
|
|
|
* @return Photo[] Returns the photos. |
82
|
|
|
*/ |
83
|
|
|
public function getPhotos() { |
84
|
|
|
return $this->photos; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Get the total results. |
89
|
|
|
* |
90
|
|
|
* @return int Returns the total results. |
91
|
|
|
*/ |
92
|
|
|
public function getTotalResults() { |
93
|
|
|
return $this->totalResults; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Set the next page. |
98
|
|
|
* |
99
|
|
|
* @param string $nextPage The next page. |
100
|
|
|
* @return AbstractResponse Returns this response. |
101
|
|
|
*/ |
102
|
|
|
public function setNextPage($nextPage) { |
103
|
|
|
$this->nextPage = $nextPage; |
104
|
|
|
return $this; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Set the photos. |
109
|
|
|
* |
110
|
|
|
* @param Photo[] $photos The photo. |
111
|
|
|
* @return PhotosResponse Returns this photo response. |
112
|
|
|
*/ |
113
|
|
|
protected function setPhotos(array $photos) { |
114
|
|
|
$this->photos = $photos; |
115
|
|
|
return $this; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Set the total results. |
120
|
|
|
* |
121
|
|
|
* @param int $totalResults The total result. |
122
|
|
|
* @return AbstractResponse Returns this response. |
123
|
|
|
*/ |
124
|
|
|
public function setTotalResults($totalResults) { |
125
|
|
|
$this->totalResults = $totalResults; |
126
|
|
|
return $this; |
127
|
|
|
} |
128
|
|
|
} |
129
|
|
|
|