| 1: | <?php |
| 2: | namespace Duyplus\TMDBApi\Classes\Data; |
| 3: | |
| 4: | class Role |
| 5: | { |
| 6: | //------------------------------------------------------------------------------ |
| 7: | // Class Variables |
| 8: | //------------------------------------------------------------------------------ |
| 9: | |
| 10: | protected $crawl; |
| 11: | |
| 12: | /** |
| 13: | * Construct Class |
| 14: | * |
| 15: | * @param array $data An array with the data of a Role |
| 16: | * @param int|null $personId The person id |
| 17: | */ |
| 18: | public function __construct($data, $personId = null) |
| 19: | { |
| 20: | $this->crawl = $data; |
| 21: | if ($personId !== null) { |
| 22: | $this->crawl['person_id'] = $personId; |
| 23: | } |
| 24: | } |
| 25: | |
| 26: | //------------------------------------------------------------------------------ |
| 27: | // Get Variables |
| 28: | //------------------------------------------------------------------------------ |
| 29: | |
| 30: | /** |
| 31: | * Get the Role's character |
| 32: | * |
| 33: | * @return string|null |
| 34: | */ |
| 35: | public function getCharacter() |
| 36: | { |
| 37: | return isset($this->crawl['character']) ? $this->crawl['character'] : null; |
| 38: | } |
| 39: | |
| 40: | /** |
| 41: | * Get the Movie's credit id |
| 42: | * |
| 43: | * @return string|null |
| 44: | */ |
| 45: | public function getCreditID() |
| 46: | { |
| 47: | return isset($this->crawl['credit_id']) ? $this->crawl['credit_id'] : null; |
| 48: | } |
| 49: | |
| 50: | /** |
| 51: | * Get Generic.<br> |
| 52: | * Get a item of the array, you should not get used to use this, better use specific get's. |
| 53: | * |
| 54: | * @param string $item The item of the $data array you want |
| 55: | * @return array|mixed|null Returns the entire data array, a specific item, or null if the item does not exist. |
| 56: | */ |
| 57: | public function get($item = '') |
| 58: | { |
| 59: | if (empty($item)) { |
| 60: | return $this->crawl; |
| 61: | } |
| 62: | if (array_key_exists($item, $this->crawl)) { |
| 63: | return $this->crawl[$item]; |
| 64: | } |
| 65: | return null; |
| 66: | } |
| 67: | } |