Completed
Push — master ( 026ae8...9deabe )
by WEBEWEB
01:12
created

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