Moved files and added namespaces

This commit is contained in:
Josh Sherman 2014-09-27 17:57:07 -04:00
parent 8a1ac4fb47
commit 48c5289060
22 changed files with 46 additions and 66 deletions

View file

@ -20,6 +20,8 @@
"php": ">=5.4"
},
"autoload": {
"classmap": ["src/"]
"psr-4": {
"Pickles\\" : "src/"
}
}
}

View file

@ -15,6 +15,8 @@
* @link https://github.com/joshtronic/pickles
*/
namespace Pickles;
/**
* Browser Utility Class
*

View file

@ -15,6 +15,8 @@
* @link https://github.com/joshtronic/pickles
*/
namespace Pickles;
/**
* Cache Class
*

View file

@ -15,6 +15,8 @@
* @link https://github.com/joshtronic/pickles
*/
namespace Pickles;
/**
* Config Class
*

View file

@ -15,6 +15,8 @@
* @link https://github.com/joshtronic/pickles
*/
namespace Pickles;
/**
* Convert Class
*

View file

@ -17,6 +17,8 @@
* @todo More assumptions for the datasource variables
*/
namespace Pickles;
/**
* Database Class
*

View file

@ -15,6 +15,8 @@
* @link https://github.com/joshtronic/pickles
*/
namespace Pickles;
/**
* Date Class
*

View file

@ -15,6 +15,8 @@
* @link https://github.com/joshtronic/pickles
*/
namespace Pickles;
/**
* Distance Class
*

9
src/Exception.php Normal file
View file

@ -0,0 +1,9 @@
<?php
namespace Pickles;
class Exception extends \Exception
{
}

View file

@ -15,6 +15,8 @@
* @link https://github.com/joshtronic/pickles
*/
namespace Pickles;
/**
* File Class
*

View file

@ -15,6 +15,8 @@
* @link https://github.com/joshtronic/pickles
*/
namespace Pickles;
/**
* Model Class
*

View file

@ -15,6 +15,8 @@
* @link https://github.com/joshtronic/pickles
*/
namespace Pickles;
/**
* Number Class
*

View file

@ -15,6 +15,8 @@
* @link https://github.com/joshtronic/pickles
*/
namespace Pickles;
/**
* Object Class
*

View file

@ -15,6 +15,8 @@
* @link https://github.com/joshtronic/pickles
*/
namespace Pickles;
/**
* Profiler Class
*

View file

@ -15,6 +15,8 @@
* @link https://github.com/joshtronic/pickles
*/
namespace Pickles;
/**
* Resource Class
*

View file

@ -15,6 +15,8 @@
* @link https://github.com/joshtronic/pickles
*/
namespace Pickles;
/**
* Router Class
*

View file

@ -15,6 +15,8 @@
* @link https://github.com/joshtronic/pickles
*/
namespace Pickles;
/**
* Sort Class
*

View file

@ -15,6 +15,8 @@
* @link https://github.com/joshtronic/pickles
*/
namespace Pickles;
/**
* String Class
*

View file

@ -15,6 +15,8 @@
* @link https://github.com/joshtronic/pickles
*/
namespace Pickles;
/**
* Time Class
*

View file

@ -1,7 +0,0 @@
<?php
class PicklesException extends Exception
{
}

View file

@ -62,64 +62,6 @@ ini_set('session.gc_probability', 1);
ini_set('session.gc_divisor', 1000);
ini_set('session.hash_function', 1);
// }}}
// {{{ Auto[magical] Loader
/**
* Magic function to automatically load classes
*
* Attempts to load a core PICKLES class or a site level data model or
* module class.
*
* @param string $class Name of the class to be loaded
* @return boolean Return value of require_once() or false (default)
*/
function __autoload($class)
{
$loaded = false;
$filename = preg_replace('/_/', '/', $class) . '.php';
$pickles_path = dirname(__FILE__) . '/';
$pickles_paths = [
'class' => $pickles_path,
];
// Hack to deal with namespaces
if (strpos($class, '\\') !== false)
{
list($namespace, $class) = explode('\\', $class);
return require_once $pickles_path . 'classes/' . $class . '.php';
}
// Path as the key, boolean value is whether ot not to convert back to hyphenated
$paths = [
$pickles_paths['class'] => false,
SITE_CLASS_PATH => false,
SITE_MODEL_PATH => false,
SITE_RESOURCE_PATH => true,
];
foreach ($paths as $path => $hyphenated)
{
// Converts the filename back to hypenated
if ($hyphenated == true)
{
$filename = strtolower(preg_replace('/([A-Z]{1})/', '-$1', $filename));;
}
if (file_exists($path . $filename))
{
$loaded = require_once $path . $filename;
break;
}
}
return $loaded;
}
spl_autoload_register('__autoload');
// }}}
// {{{ Loads the configuration file and sets any configuration options