Skip to content

Instantly share code, notes, and snippets.

@caionitro
Created September 20, 2014 17:39
Show Gist options
  • Save caionitro/57ec166ab4646befb84c to your computer and use it in GitHub Desktop.
Save caionitro/57ec166ab4646befb84c to your computer and use it in GitHub Desktop.
métodos mágicos
<?php
public function __get($property)
{
if(!property_exists($this,$property))
{
throw new InvalidArgumentException("Propriedade {$property} inexistente!");
}
return $this->$property;
}
public function __set($property, $value)
{
if(!property_exists($this,$property))
{
throw new InvalidArgumentException("Propriedade {$property} inexistente!");
}
$this->$property = $value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment