for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @file TProperty.php
* @brief This file contains the TProperty trait.
* @details
* @author Filippo F. Fadda
*/
//! Extensions and traits
namespace Meta\Extension;
* @brief This trait can be used by a class to emulate the C# properties.
trait TProperty {
public function __get($name) {
if (method_exists($this, ($method = 'get'.ucfirst($name))))
return $this->$method();
else
throw new \BadMethodCallException("Method $method is not implemented for property $name.");
}
public function __isset($name) {
if (method_exists($this, ($method = 'isset'.ucfirst($name))))
public function __set($name, $value) {
if (method_exists($this, ($method = 'set'.ucfirst($name))))
$this->$method($value);
public function __unset($name) {
if (method_exists($this, ($method = 'unset'.ucfirst($name))))
$this->$method();