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

Commit

Permalink
Adds settable functionality through __set
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Paul committed Oct 19, 2016
1 parent 8dbc17c commit 88cf5c0
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/Settable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace CraigPaul\Moneris;

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

0 comments on commit 88cf5c0

Please sign in to comment.