Example #1
0
 /**
  * Constructor.
  *
  * @param  string  $version
  * @param  string  $apiKey
  * @param  string  $apiVersion
  * @return void
  * @throws \RuntimeException
  */
 public function __construct($version, $apiKey, $apiVersion)
 {
     $api_key = $apiKey ?: getenv('STRIPE_API_KEY');
     $api_version = $apiVersion ?: getenv('STRIPE_API_VERSION') ?: '2015-03-24';
     if (!$api_key) {
         throw new \RuntimeException('The Stripe API key is not defined!');
     }
     parent::__construct(compact('version', 'api_key', 'api_version'));
 }
Example #2
0
 /** @test */
 public function it_can_slice_a_collection()
 {
     $collection = new Collection(['a', 'b', 'c', 'd', 'e']);
     $sliced1 = $collection->slice(2);
     $this->assertEquals(['c', 'd', 'e'], $sliced1->all());
     $sliced2 = $collection->slice(-2, 1);
     $this->assertEquals(['d'], $sliced2->all());
     $sliced3 = $collection->slice(2, -1, true);
     $expected = [2 => 'c', 3 => 'd'];
     $this->assertEquals($expected, $sliced3->all());
 }
 /** @test */
 public function it_can_list_items_from_the_collection_using_a_key()
 {
     $collection = new Collection([['id' => 'foo'], ['id' => 'bar']]);
     $this->assertEquals(['foo', 'bar'], $collection->lists('id'));
 }