for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace GloBee\PaymentApi\Models;
trait PropertyTrait
{
/**
* @param $name
*
* @return mixed
*/
public function getProperty($name)
$methodName = 'get'.$this->strToStudlyCase($name);
if (method_exists($this, $methodName)) {
return $this->{$methodName}();
}
if (property_exists($this, $name)) {
return $this->{$name};
* @param $value
protected function setProperty($name, $value)
$methodName = 'set'.$this->strToStudlyCase($name);
$this->{$methodName}($value);
return;
$this->{$name} = $value;
public function __get($name)
return $this->getProperty($name);
public function __set($name, $value)
$this->setProperty($name, $value);
* @param $key
protected function strToStudlyCase($key)
return str_replace(' ', '', ucwords(str_replace('_', ' ', $key)));