Skip to content

Commit

Permalink
Small updates
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Jan 18, 2014
1 parent 7fd7485 commit 207e403
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 10 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,13 @@ $images = $client->getMoviesApi()->getMovie(550);
If you want to provide any other query arguments.

```php
$token = new \Tmdb\ApiToken('your_tmdb_api_key_here');
$client = new \Tmdb\Client($token);

$images = $client->getMoviesApi()->getMovie(550, array('language' => 'en'));
```

Model Usage
-----------

However the library can be used in an object oriented manner.
However the library can also be used in an object oriented manner.

First we always have to construct the client:

Expand Down
6 changes: 0 additions & 6 deletions lib/Tmdb/Model/Changes.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/
namespace Tmdb\Model;

use Tmdb\Client;
use Tmdb\Model\Changes\Change;
use Tmdb\Model\Common\Collection;

Expand All @@ -22,11 +21,6 @@ class Changes extends AbstractModel {
private $to = null;
private $page = null;

public function __construct(Client $client)
{
$this->setClient($client);
}

/**
* Set the from parameter
*
Expand Down
55 changes: 55 additions & 0 deletions lib/Tmdb/Repository/ChangesRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <[email protected]>
* @copyright (c) 2013, Michael Roterman
* @version 0.0.1
*/
namespace Tmdb\Repository;

use Tmdb\Factory\CompanyFactory;
use Tmdb\Model\Common\Collection;
use Tmdb\Model\Company;

class CompanyRepository extends AbstractRepository {
/**
* Load a company with the given identifier
*
* @param $id
* @param array $parameters
* @param array $headers
* @return Company
*/
public function load($id, array $parameters = array(), array $headers = array()) {
$data = $this->getApi()->getCompany($id, $this->parseQueryParameters($parameters), $this->parseHeaders($headers));

return CompanyFactory::create($data);
}

/**
* If you obtained an person model which is not completely hydrated, you can use this function.
*
* @param Company $company
* @param array $parameters
* @param array $headers
* @return Company
*/
public function refresh(Company $company, array $parameters = array(), array $headers = array()) {
return $this->load($company->getId(), $parameters, $headers);
}

/**
* Return the related API class
*
* @return \Tmdb\Api\Companies
*/
public function getApi()
{
return $this->getClient()->getCompaniesApi();
}
}

0 comments on commit 207e403

Please sign in to comment.