ElementTrait   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 40
ccs 11
cts 11
cp 1
rs 10
c 1
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getPosterPath() 0 6 2
A getBackdropPath() 0 6 2
A setElementTrait() 0 3 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 816
    protected function setElementTrait(?\stdClass $data) : void
37
    {
38 816
        $this->element_trait = $data;
39 816
    }
40
41
    /**
42
     * Get poster path
43
     * @return string
44
     */
45 18
    public function getPosterPath() : string
46
    {
47 18
        if (isset($this->element_trait->poster_path)) {
48 9
            return $this->element_trait->poster_path;
49
        }
50 9
        return '';
51
    }
52
53
    /**
54
     * Get backdrop
55
     * @return string
56
     */
57 12
    public function getBackdropPath() : string
58
    {
59 12
        if (isset($this->element_trait->backdrop_path)) {
60 6
            return $this->element_trait->backdrop_path;
61
        }
62 6
        return '';
63
    }
64
}
65