for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Trait Magic
*
* @filesource Magic.php
* @created 13.11.2017
* @package chillerlan\Traits
* @author Smiley <[email protected]>
* @copyright 2017 Smiley
* @license MIT
*/
namespace chillerlan\Traits;
* A Container that turns methods into magic properties
trait Magic{
* @param string $name
* @return mixed|null
public function __get(string $name){
return $this->get($name);
}
* @param mixed $value
* @return void
public function __set(string $name, $value):void{
$this->set($name, $value);
private function get(string $name){
$method = 'magic_get_'.$name;
return \method_exists($this, $method) ? $this->$method() : null;
* @param $value
private function set(string $name, $value):void{
$method = 'magic_set_'.$name;
if(\method_exists($this, $method)){
$this->$method($value);