Skip to content
This repository has been archived by the owner on Oct 30, 2020. It is now read-only.

Commit

Permalink
Adds proper setter for customer data
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Paul committed Oct 26, 2016
1 parent fbff9e7 commit 9da220e
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
class Customer
{
use Gettable, Preparable, Settable;
use Preparable;

/**
* The Customer data.
Expand Down Expand Up @@ -71,4 +71,24 @@ public function __get($property)

throw new \InvalidArgumentException('['.get_class($this).'] does not contain a property named ['.$property.']');
}

/**
* Set a property that exists on the class.
*
* @param string $property
* @param mixed $value
*
* @throws \InvalidArgumentException
* @return void
*/
public function __set($property, $value)
{
if (property_exists($this, $property)) {
$this->$property = $value;
} else if (!is_null($this->data)) {
$this->data[$property] = $value;
} else {
throw new \InvalidArgumentException('['.get_class($this).'] does not contain a property named ['.$property.']');
}
}
}

0 comments on commit 9da220e

Please sign in to comment.