|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the Tmdb package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Vincent Faliès <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
* |
|
11
|
|
|
* @author Vincent Faliès <[email protected]> |
|
12
|
|
|
* @copyright Copyright (c) 2017 |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace vfalies\tmdb\Catalogs; |
|
16
|
|
|
|
|
17
|
|
|
use vfalies\tmdb\Interfaces\TmdbInterface; |
|
18
|
|
|
use vfalies\tmdb\lib\Guzzle\Client as HttpClient; |
|
19
|
|
|
use vfalies\tmdb\Exceptions\TmdbException; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Class to get jobs list with department |
|
23
|
|
|
* @package Tmdb |
|
24
|
|
|
* @author Vincent Faliès <[email protected]> |
|
25
|
|
|
* @copyright Copyright (c) 2017 |
|
26
|
|
|
*/ |
|
27
|
|
|
class Jobs |
|
28
|
|
|
{ |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Tmdb object |
|
32
|
|
|
* @var TmdbInterface |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $tmdb = null; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Constructor |
|
38
|
|
|
* @param \vfalies\tmdb\Interfaces\TmdbInterface $tmdb |
|
39
|
|
|
*/ |
|
40
|
2 |
|
public function __construct(TmdbInterface $tmdb) |
|
41
|
|
|
{ |
|
42
|
2 |
|
$this->tmdb = $tmdb; |
|
43
|
2 |
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Get job list |
|
47
|
|
|
* @param array $options |
|
48
|
|
|
* @return \Generator|\stdClass |
|
49
|
|
|
* @throws \vfalies\tmdb\Catalogs\TmdbException |
|
50
|
|
|
*/ |
|
51
|
2 |
|
public function getList(array $options = array()) |
|
52
|
|
|
{ |
|
53
|
|
|
try |
|
54
|
|
|
{ |
|
55
|
2 |
|
$params = $this->tmdb->checkOptions($options); |
|
56
|
2 |
|
$response = $this->tmdb->sendRequest(new HttpClient(new \GuzzleHttp\Client()), 'job/list', null, $params); |
|
57
|
|
|
|
|
58
|
1 |
|
$results = []; |
|
59
|
1 |
|
if (isset($response->jobs)) |
|
60
|
|
|
{ |
|
61
|
1 |
|
foreach ($response->jobs as $j) |
|
62
|
|
|
{ |
|
63
|
1 |
|
$result = new \stdClass(); |
|
64
|
1 |
|
$result->department = $j->department; |
|
65
|
1 |
|
$result->jobs = $j->job_list; |
|
66
|
|
|
|
|
67
|
1 |
|
$results[] = $result; |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
1 |
|
catch (TmdbException $ex) |
|
72
|
|
|
{ |
|
73
|
1 |
|
throw $ex; |
|
74
|
|
|
} |
|
75
|
1 |
|
return $this->genreItemGenerator($results); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Genre Item generator method |
|
80
|
|
|
* @param array $results |
|
81
|
|
|
*/ |
|
82
|
1 |
|
private function genreItemGenerator(array $results) |
|
83
|
|
|
{ |
|
84
|
1 |
|
foreach ($results as $result) |
|
85
|
|
|
{ |
|
86
|
1 |
|
yield $result; |
|
87
|
|
|
} |
|
88
|
1 |
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|