Skip to content

Instantly share code, notes, and snippets.

@magickatt
Last active December 19, 2017 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save magickatt/5434032 to your computer and use it in GitHub Desktop.
Save magickatt/5434032 to your computer and use it in GitHub Desktop.
Safe __toString method
<?php
/**
* String representation of this object
* @return string
*/
public function __toString()
{
try {
return (string) $this->name;
} catch (Exception $exception) {
return '';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment