Example #1
0
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';
use Chadicus\Marvel\Api\Client;
$publicApiKey = getenv('PUBLIC_KEY');
$privateApiKey = getenv('PRIVATE_KEY');
$client = new Client($privateApiKey, $publicApiKey);
//1009165 is the character id for the Avangers
$comics = $client->comics(['characters' => 1009165]);
foreach ($comics as $comic) {
    echo "{$comic->getTitle()}\n";
}
 /**
  * Verify basic bahvior of __call() for entity collection.
  *
  * @test
  * @covers ::__call
  *
  * @return void
  */
 public function callCollection()
 {
     $client = new Client('not under test', 'not under test', new Assets\ComicAdapter());
     $comics = $client->comics();
     $this->assertInstanceOf('Chadicus\\Marvel\\Api\\Collection', $comics);
     $this->assertSame(5, $comics->count());
     foreach ($comics as $key => $comic) {
         $this->assertSame($key + 1, $comic->getId());
     }
 }