Passed
Branch account (e3661f)
by vincent
02:30
created

ElementTrait::setElementTrait()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php declare(strict_types=1);
2
/**
3
 * This file is part of the Tmdb package.
4
 *
5
 * (c) Vincent Faliès <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @author Vincent Faliès <[email protected]>
11
 * @copyright Copyright (c) 2017
12
 */
13
14
15
namespace VfacTmdb\Traits;
16
17
/**
18
 * Common element methods trait
19
 * @package Tmdb
20
 * @author Vincent Faliès <[email protected]>
21
 * @copyright Copyright (c) 2017
22
 */
23
trait ElementTrait
24
{
25
    /**
26
     * ElementTrait object variable
27
     * @var \stdClass
28
     */
29
    protected $element_trait;
30
31
    /**
32
     * Set ElementTrait variable
33
     * @param \stdClass|null $data
34
     * @return void
35
     */
36 250
    protected function setElementTrait(?\stdClass $data) : void
37
    {
38 250
        $this->element_trait = $data;
39 250
    }
40
41
    /**
42
     * Get poster path
43
     * @return string
44
     */
45 6
    public function getPosterPath() : string
46
    {
47 6
        if (isset($this->element_trait->poster_path)) {
48 3
            return $this->element_trait->poster_path;
49
        }
50 3
        return '';
51
    }
52
53
    /**
54
     * Get backdrop
55
     * @return string
56
     */
57 4
    public function getBackdropPath() : string
58
    {
59 4
        if (isset($this->element_trait->backdrop_path)) {
60 2
            return $this->element_trait->backdrop_path;
61
        }
62 2
        return '';
63
    }
64
}
65