VideoResponse::setVideo()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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 AbstractMediaResponse {
23
24
    /**
25
     * Get the video.
26
     *
27
     * @return Video|null Returns the video.
28
     */
29
    public function getVideo(): ?Video {
30
31
        /** @var Video[] $medias */
32
        $medias = $this->getMedias();
33
34
        return 1 === count($medias) ? $medias[0] : null;
35
    }
36
37
    /**
38
     * Set the video.
39
     *
40
     * @param Video $video The video.
41
     * @return VideoResponse Returns this video response.
42
     */
43
    public function setVideo(Video $video): VideoResponse {
44
        return $this->setMedias([$video]);
45
    }
46
}
47