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

AbstractResponse   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 50
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A addMedia() 0 4 1
A getMedias() 0 3 1
A setMedias() 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\Core\Model\Attribute\StringRawResponseTrait;
15
use WBW\Library\Pexels\Model\AbstractMedia;
16
use WBW\Library\Pexels\Model\RateLimitTrait;
17
18
/**
19
 * Abstract response.
20
 *
21
 * @author webeweb <https://github.com/webeweb/>
22
 * @package WBW\Library\Pexels\Response
23
 * @abstract
24
 */
25
abstract class AbstractResponse {
26
27
    use RateLimitTrait;
28
    use StringRawResponseTrait;
29
30
    /**
31
     * Medias.
32
     *
33
     * @var AbstractMedia[]
34
     */
35
    private $medias;
36
37
    /**
38
     * Constructor.
39
     */
40
    public function __construct() {
41
        $this->setMedias([]);
42
    }
43
44
    /**
45
     * Add a media.
46
     *
47
     * @param AbstractMedia $media The media.
48
     * @return AbstractResponse Returns this response.
49
     */
50
    protected function addMedia(AbstractMedia $media): AbstractResponse {
51
        $this->medias[] = $media;
52
        return $this;
53
    }
54
55
    /**
56
     * Get the medias.
57
     *
58
     * @return AbstractMedia[] Returns the medias.
59
     */
60
    protected function getMedias(): array {
61
        return $this->medias;
62
    }
63
64
    /**
65
     * Set the medias.
66
     *
67
     * @param AbstractMedia[] $medias The medias.
68
     * @return AbstractResponse Returns this response.
69
     */
70
    protected function setMedias(array $medias): AbstractResponse {
71
        $this->medias = $medias;
72
        return $this;
73
    }
74
}
75