Skip to content

Instantly share code, notes, and snippets.

@nerdsrescueme
Created October 19, 2011 20:17
Show Gist options
  • Save nerdsrescueme/1299541 to your computer and use it in GitHub Desktop.
Save nerdsrescueme/1299541 to your computer and use it in GitHub Desktop.
Uninstantiable
<?php
/**
* Design namespace. This namespace is meant for abstract concepts and in most
* cases simply just interfaces that in someway structures the general design
* used in the core components.
*
* @package Atom
* @subpackage Library
*/
namespace Atom\Design;
/**
* Uninstantiable Class
*
* This abstract class is used for classes that should not be instantiated
* or cloned. This includes fully static classes, informational classes...
*
* @package Atom
* @subpackage Library
*/
abstract class Uninstantiable {
/**
* Throw an error if subclass construction is attempted
*
* @throws RuntimeException
*/
final public function __construct()
{
throw new \RuntimeException(__CLASS__.' is uninstantiable.');
}
/**
* Throw an error if subclass cloning is attempted
*
* @throws RuntimeException
*/
final public function __clone()
{
throw new \RuntimeException(__CLASS__.' is uninstantiable.');
}
}
/* End of file uninstantiable.php */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment