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\Response; |
13
|
|
|
|
14
|
|
|
use WBW\Library\Pexels\Api\PaginateResponseInterface; |
15
|
|
|
use WBW\Library\Pexels\Model\Photo; |
16
|
|
|
use WBW\Library\Pexels\Serializer\ResponseDeserializer; |
17
|
|
|
use WBW\Library\Pexels\Traits\Integers\IntegerTotalResultsTrait; |
18
|
|
|
use WBW\Library\Pexels\Traits\Strings\StringNextPageTrait; |
19
|
|
|
use WBW\Library\Pexels\Traits\Strings\StringPrevPageTrait; |
20
|
|
|
use WBW\Library\Traits\Integers\IntegerPageTrait; |
21
|
|
|
use WBW\Library\Traits\Integers\IntegerPerPageTrait; |
22
|
|
|
use WBW\Library\Traits\Strings\StringUrlTrait; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Photos response. |
26
|
|
|
* |
27
|
|
|
* @author webeweb <https://github.com/webeweb> |
28
|
|
|
* @package WBW\Library\Pexels\Response |
29
|
|
|
*/ |
30
|
|
|
class PhotosResponse extends AbstractMediaResponse implements PaginateResponseInterface { |
31
|
|
|
|
32
|
|
|
use IntegerPageTrait; |
33
|
|
|
use IntegerPerPageTrait; |
34
|
|
|
use IntegerTotalResultsTrait; |
35
|
|
|
use StringNextPageTrait; |
36
|
|
|
use StringPrevPageTrait; |
37
|
|
|
use StringUrlTrait; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Constructor. |
41
|
|
|
*/ |
42
|
|
|
public function __construct() { |
43
|
|
|
parent::__construct(); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Add a photo. |
48
|
|
|
* |
49
|
|
|
* @param Photo $photo The photo. |
50
|
|
|
* @return PhotosResponse Returns this photo response. |
51
|
|
|
*/ |
52
|
|
|
public function addPhoto(Photo $photo): PhotosResponse { |
53
|
|
|
return $this->addMedia($photo); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* {@inheritDoc} |
58
|
|
|
*/ |
59
|
|
|
public function deserializeResponse(string $rawResponse): AbstractResponse { |
60
|
|
|
return ResponseDeserializer::deserializePhotosResponse($rawResponse); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Get the photos. |
65
|
|
|
* |
66
|
|
|
* @return Photo[] Returns the photos. |
67
|
|
|
*/ |
68
|
|
|
public function getPhotos(): array { |
69
|
|
|
|
70
|
|
|
/** @var Photo[] */ |
71
|
|
|
return $this->getMedias(); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|