Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from vfalies/companies
Add Company methods & tests
- Loading branch information
Showing
14 changed files
with
644 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace vfalies\tmdb\Interfaces\Items; | ||
|
||
interface CompanyInterface | ||
{ | ||
public function getDescription(); | ||
|
||
public function getHeadQuarters(); | ||
|
||
public function getHomePage(); | ||
|
||
public function getId(); | ||
|
||
public function getLogoPath(); | ||
|
||
public function getName(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace vfalies\tmdb\Interfaces\Results; | ||
|
||
interface CompanyResultsInterface extends ResultsInterface | ||
{ | ||
|
||
/** | ||
* Get company name | ||
* @return string | ||
*/ | ||
public function getName(); | ||
|
||
/** | ||
* Get company logo path | ||
* @return string | ||
*/ | ||
public function getLogoPath(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
namespace vfalies\tmdb\Items; | ||
|
||
use vfalies\tmdb\Abstracts\Item; | ||
use vfalies\tmdb\Interfaces\Items\CompanyInterface; | ||
use vfalies\tmdb\Tmdb; | ||
|
||
class Company extends Item implements CompanyInterface | ||
{ | ||
/** | ||
* Constructor | ||
* @param \vfalies\tmdb\Tmdb $tmdb | ||
* @param int $company_id | ||
* @param array $options | ||
*/ | ||
public function __construct(Tmdb $tmdb, $company_id, array $options = array()) | ||
{ | ||
parent::__construct($tmdb, $company_id, $options, 'company'); | ||
} | ||
|
||
public function getDescription() | ||
{ | ||
if (isset($this->data->description)) { | ||
return $this->data->description; | ||
} | ||
return ''; | ||
} | ||
|
||
public function getHeadQuarters() | ||
{ | ||
if (isset($this->data->headquarters)) { | ||
return $this->data->headquarters; | ||
} | ||
return ''; | ||
} | ||
|
||
public function getHomePage() | ||
{ | ||
if (isset($this->data->homepage)) { | ||
return $this->data->homepage; | ||
} | ||
return ''; | ||
} | ||
|
||
public function getId() | ||
{ | ||
if (isset($this->data->id)) { | ||
return $this->data->id; | ||
} | ||
return 0; | ||
} | ||
|
||
public function getLogoPath() | ||
{ | ||
if (isset($this->data->logo_path)) { | ||
return $this->data->logo_path; | ||
} | ||
return ''; | ||
} | ||
|
||
public function getName() | ||
{ | ||
if (isset($this->data->name)) { | ||
return $this->data->name; | ||
} | ||
return ''; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace vfalies\tmdb\Results; | ||
|
||
use vfalies\tmdb\Abstracts\Results; | ||
use vfalies\tmdb\Tmdb; | ||
use vfalies\tmdb\Interfaces\Results\CompanyResultsInterface; | ||
|
||
class Company extends Results implements CompanyResultsInterface | ||
{ | ||
|
||
protected $name = null; | ||
protected $logo_path = null; | ||
|
||
/** | ||
* Constructor | ||
* @param \vfalies\tmdb\Tmdb $tmdb | ||
* @param \stdClass $result | ||
*/ | ||
public function __construct(Tmdb $tmdb, \stdClass $result) | ||
{ | ||
parent::__construct($tmdb, $result); | ||
|
||
// Populate data | ||
$this->id = $this->data->id; | ||
$this->name = $this->data->name; | ||
$this->logo_path = $this->data->logo_path; | ||
} | ||
|
||
public function getId() | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function getLogoPath() | ||
{ | ||
return $this->logo_path; | ||
} | ||
|
||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.