Created
October 1, 2013 08:39
-
-
Save fabiocicerchia/6775515 to your computer and use it in GitHub Desktop.
PHP - Black Hole Class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Black Hole Class. | |
* | |
* This class could be used as testing class. | |
*/ | |
class BlackHole | |
{ | |
/** | |
* Magic Method CALL. | |
* Triggered when invoking inaccessible methods in an object context. | |
* | |
* @param string $name The name of the method being called. | |
* @param array $arguments An enumerated array containing the parameters passed to the $name'ed method. | |
* | |
* @return \blackHole | |
*/ | |
public function __call($name, array $arguments) | |
{ | |
return $this; | |
} | |
/** | |
* Magic Method CALL STATIC. | |
* Triggered when invoking inaccessible methods in a static context. | |
* | |
* @param string $name The name of the method being called. | |
* @param array $arguments An enumerated array containing the parameters passed to the $name'ed method. | |
* | |
* @return \blackHole | |
*/ | |
public static function __callStatic($name, array $arguments) | |
{ | |
return self; | |
} | |
/** | |
* Magic Method SET. | |
* Run when writing data to inaccessible properties. | |
* | |
* @param string $name The name of the property being interacted with. | |
* @param mixed $value The value the $name'ed property should be set to. | |
* | |
* @return \blackHole | |
*/ | |
public function __set($name, $value) | |
{ | |
return $this; | |
} | |
/** | |
* Magic Method GET. | |
* Utilized for reading data from inaccessible properties. | |
* | |
* @param string $name The name of the property being interacted with. | |
* | |
* @return \blackHole | |
*/ | |
public function __get($name) | |
{ | |
return $this; | |
} | |
/** | |
* Magic Method ISSET. | |
* Triggered by calling isset() or empty() on inaccessible properties. | |
* | |
* @param string $name The name of the property being interacted with. | |
* | |
* @return boolean | |
*/ | |
public function __isset($name) | |
{ | |
return true; | |
} | |
/** | |
* Magic Method UNSET. | |
* Invoked when unset() is used on inaccessible properties. | |
* | |
* @param string $name The name of the property being interacted with. | |
* | |
* @return null | |
*/ | |
public function __unset($name) | |
{ | |
return null; | |
} | |
/** | |
* Magic Method TO STRING. | |
* Allows a class to decide how it will react when it is treated like a string. | |
* | |
* @return string | |
*/ | |
public function __toString() | |
{ | |
return ''; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment