2012-05-21 14:58:58 -04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* MiniMVC
|
|
|
|
*
|
|
|
|
* Convention-based micro-framework for PHP
|
|
|
|
*
|
|
|
|
* @package miniMVC
|
|
|
|
* @author Timothy J. Warren
|
|
|
|
* @copyright Copyright (c) 2011 - 2012
|
2012-05-23 12:01:13 -04:00
|
|
|
* @link https://github.com/aviat4ion/miniMVC
|
2012-05-21 14:58:58 -04:00
|
|
|
* @license http://philsturgeon.co.uk/code/dbad-license
|
|
|
|
*/
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
2012-05-22 11:11:36 -04:00
|
|
|
namespace miniMVC;
|
|
|
|
|
2012-05-21 14:58:58 -04:00
|
|
|
/**
|
|
|
|
* Simple Trait to include most useful default methods
|
|
|
|
*
|
|
|
|
* @package miniMVC
|
|
|
|
* @subpackage System
|
|
|
|
*/
|
|
|
|
trait Generic {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prints out the contents of the object when used as a string
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function __toString()
|
|
|
|
{
|
|
|
|
if (ENVIRONMENT == 'DEVELOPMENT')
|
|
|
|
{
|
|
|
|
$args = func_get_args();
|
|
|
|
$method = ( ! empty($args)) ? $args[0] : "print_r";
|
|
|
|
$data = (isset($args[1])) ? $args[1] : [];
|
|
|
|
|
|
|
|
if (empty($data))
|
|
|
|
{
|
|
|
|
$data =& $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
$output = '<pre>';
|
|
|
|
|
|
|
|
if ($method == "var_dump")
|
|
|
|
{
|
|
|
|
ob_start();
|
|
|
|
var_dump($data);
|
|
|
|
$output .= ob_get_contents();
|
|
|
|
ob_end_clean();
|
|
|
|
}
|
|
|
|
elseif ($method == "var_export")
|
|
|
|
{
|
|
|
|
ob_start();
|
|
|
|
var_export($data);
|
|
|
|
$output .= ob_get_contents();
|
|
|
|
ob_end_clean();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$output .= print_r($data, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $output . '</pre>';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PHP magic method that is called when an object is treated as a function
|
|
|
|
*
|
|
|
|
* @param array $args
|
|
|
|
*/
|
|
|
|
public static function __invoke($args = [])
|
|
|
|
{
|
|
|
|
$class = __CLASS__;
|
|
|
|
return new $class($args);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// End of Generic.php
|