PhotosResponse   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 11
c 1
b 1
f 0
dl 0
loc 42
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A addPhoto() 0 2 1
A deserializeResponse() 0 2 1
A getPhotos() 0 4 1
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