Skip to content

Commit

Permalink
Merge pull request #502 from stripe/ob-stripe-object-is-deleted
Browse files Browse the repository at this point in the history
Add `isDeleted()` method to `StripeObject`
  • Loading branch information
ob-stripe authored Jul 31, 2018
2 parents 1e02436 + 6f731f0 commit 1a18afd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/StripeObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -507,4 +507,16 @@ public function setLastResponse($resp)
{
$this->_lastResponse = $resp;
}

/**
* Indicates whether or not the resource has been deleted on the server.
* Note that some, but not all, resources can indicate whether they have
* been deleted.
*
* @return bool Whether the resource is deleted.
*/
public function isDeleted()
{
return isset($this->_values['deleted']) ? $this->_values['deleted'] : false;
}
}
12 changes: 12 additions & 0 deletions tests/Stripe/StripeObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -461,4 +461,16 @@ public function testDeepCopyMaintainClass()
$copyCharge = $this->deepCopyReflector->invoke(null, $charge);
$this->assertEquals(get_class($charge), get_class($copyCharge));
}

public function testIsDeleted()
{
$obj = StripeObject::constructFrom([]);
$this->assertFalse($obj->isDeleted());

$obj = StripeObject::constructFrom(['deleted' => false]);
$this->assertFalse($obj->isDeleted());

$obj = StripeObject::constructFrom(['deleted' => true]);
$this->assertTrue($obj->isDeleted());
}
}

0 comments on commit 1a18afd

Please sign in to comment.