SwitchFunction.php


namespace SwitchIt;

/**
 * @author Chris Chase
 * @version 1       
 */
class SwitchFunction {
	public function __construct($what = null, $data = null) {
		if (! empty ( $what )) {
			return $this->SwitchIt ( $what, $data );
		}
	}
	
	/**
	 *
	 * @param string $what        	
	 * @param unknown $data        	
	 */
	public function SwitchIt($what, $data = null) {
		if (is_callable ( array ( static::class, $what ) )) {
			return $this->{ $what } ( $data );
		} else {
			return $this->DefaultSwitch ( $data );
		}
	}
	/**
	 *
	 * @param unknown $data        	
	 * @return boolean
	 */
	public function DefaultSwitch($data) {
		return false;
	}
}

1 Trackback / Pingback

  1. Switch Hell in PHP – S|RMonkeys

Leave a Reply

Your email address will not be published.


*