Passed
Push — master ( 75f027...d75bb0 )
by vincent
01:46
created

Company::getLogoPath()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
crap 2
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\Items;
16
17
use VfacTmdb\Abstracts\Item;
18
use VfacTmdb\Interfaces\Items\CompanyInterface;
19
use VfacTmdb\Results;
20
use VfacTmdb\Traits\ElementTrait;
21
use VfacTmdb\Interfaces\TmdbInterface;
22
23
/**
24
 * Company class
25
 * @package Tmdb
26
 * @author Vincent Faliès <[email protected]>
27
 * @copyright Copyright (c) 2017
28
 */
29
class Company extends Item implements CompanyInterface
30
{
31
    use ElementTrait;
32
33
    /**
34
     * Constructor
35
     * @param TmdbInterface $tmdb
36
     * @param int $company_id
37
     * @param array $options
38
     */
39 15
    public function __construct(TmdbInterface $tmdb, int $company_id, array $options = array())
40
    {
41 15
        parent::__construct($tmdb, $company_id, $options, 'company');
42
43 14
        $this->setElementTrait($this->data);
44 14
    }
45
46
    /**
47
     * Company description
48
     * @return string
49
     */
50 2
    public function getDescription() : string
51
    {
52 2
        if (isset($this->data->description)) {
53 1
            return $this->data->description;
54
        }
55 1
        return '';
56
    }
57
58
    /**
59
     * Company Head quarters
60
     * @return string
61
     */
62 2
    public function getHeadQuarters() : string
63
    {
64 2
        if (isset($this->data->headquarters)) {
65 1
            return $this->data->headquarters;
66
        }
67 1
        return '';
68
    }
69
70
    /**
71
     * Company Homepage
72
     * @return string
73
     */
74 2
    public function getHomePage() : string
75
    {
76 2
        if (isset($this->data->homepage)) {
77 1
            return $this->data->homepage;
78
        }
79 1
        return '';
80
    }
81
82
    /**
83
     * Company Id
84
     * @return int
85
     */
86 3
    public function getId() : int
87
    {
88 3
        if (isset($this->data->id)) {
89 2
            return $this->data->id;
90
        }
91 1
        return 0;
92
    }
93
94
    /**
95
     * Company image logo path
96
     * @return string
97
     */
98 2
    public function getLogoPath() : string
99
    {
100 2
        if (isset($this->data->logo_path)) {
101 1
            return $this->data->logo_path;
102
        }
103 1
        return '';
104
    }
105
106
    /**
107
     * Company name
108
     * @return string
109
     */
110 2
    public function getName() : string
111
    {
112 2
        if (isset($this->data->name)) {
113 1
            return $this->data->name;
114
        }
115 1
        return '';
116
    }
117
118
    /**
119
     * Company movies list
120
     * @return \Generator|Results\Movie
121
     */
122 1 View Code Duplication
    public function getMovies() : \Generator
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
123
    {
124 1
        $params = [];
125 1
        $this->tmdb->checkOptionLanguage($this->params, $params);
126 1
        $data = $this->tmdb->getRequest('company/' . (int) $this->id . '/movies', $params);
127
128 1
        foreach ($data->results as $m) {
129 1
            $movie = new Results\Movie($this->tmdb, $m);
130 1
            yield $movie;
131
        }
132 1
    }
133
}
134