Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
HacKanCuBa committed Dec 10, 2017
1 parent bb76175 commit 63ec209
Show file tree
Hide file tree
Showing 16 changed files with 1,577 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*~
*.bak
*.swp
65 changes: 65 additions & 0 deletions HC/Autoloader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

namespace HC;

/**
* Autoloader for HC libraries.
*
* @version v0.1.1
* ----------------------------------------------------------------------------
* Copyright (C) 2017 HacKan (https://hackan.net)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ----------------------------------------------------------------------------
*
*/
class Autoloader
{
/**
* Register autoloader
*/
public static function register()
{
if (function_exists('__autoload')) {
// Just in case...
spl_autoload_register('__autoload');
}
return spl_autoload_register([\HC\Autoloader::class, 'load'], true, true);
}

/**
* Autoload a HC class identified by name.
*
* @param string $className Name of the object to load
*/
public static function load($className)
{
$prefix = 'HC\\';
if ((class_exists($className, false)) || (strpos($className, $prefix) !== 0)) {
// Either already loaded, or not a HC class request
return false;
}

$classFilePath = __DIR__ . DIRECTORY_SEPARATOR .
str_replace([$prefix, '\\'], ['', DIRECTORY_SEPARATOR], $className) .
'.php';

if ((file_exists($classFilePath) === false) || (is_readable($classFilePath) === false)) {
// Can't load
return false;
}

require $classFilePath;
}
}
28 changes: 28 additions & 0 deletions HC/Bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

/**
* Bootstraping for HC
*
*
* ----------------------------------------------------------------------------
* Copyright (C) 2017 HacKan (https://hackan.net)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ----------------------------------------------------------------------------
*
*/

require_once __DIR__ . '/Autoloader.php';

\HC\Autoloader::register();
Loading

0 comments on commit 63ec209

Please sign in to comment.