Completed
Push — master ( f90dd6...0a073f )
by WEBEWEB
05:01
created

PhotoResponse   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 22
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getPhoto() 0 4 2
A setPhoto() 0 3 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\Model\Response;
13
14
use WBW\Library\Pexels\Model\AbstractResponse;
15
use WBW\Library\Pexels\Model\Photo;
16
17
/**
18
 * Photo response.
19
 *
20
 * @author webeweb <https://github.com/webeweb/>
21
 * @package WBW\Library\Pexels\Model\Response
22
 */
23
class PhotoResponse extends AbstractResponse {
24
25
    /**
26
     * Get the photo.
27
     *
28
     * @return Photo Returns the photo.
29
     */
30
    public function getPhoto() {
31
        $medias = $this->getMedias();
32
        return 1 === count($medias) ? $medias[0] : null;
33
    }
34
35
    /**
36
     * Set the photo.
37
     *
38
     * @param Photo $photo The photo.
39
     * @return PhotoResponse Returns this photo response.
40
     */
41
    public function setPhoto(Photo $photo) {
42
        return $this->setMedias([$photo]);
43
    }
44
}
45