HummingBirdAnimeClient/src/AnimeClient.php

69 lines
1.5 KiB
PHP
Raw Normal View History

2016-10-20 22:09:36 -04:00
<?php declare(strict_types=1);
2015-11-16 19:30:04 -05:00
/**
* Hummingbird Anime Client
*
* An API client for Hummingbird to manage anime and manga watch lists
*
2016-10-20 22:09:36 -04:00
* PHP version 7
2016-08-30 10:01:18 -04:00
*
2015-11-16 19:30:04 -05:00
* @package HummingbirdAnimeClient
2016-08-30 10:01:18 -04:00
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2016 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 3.1
2015-11-16 19:30:04 -05:00
* @link https://github.com/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient;
use Yosymfony\Toml\Toml;
2016-08-29 16:36:13 -04:00
define('SRC_DIR', realpath(__DIR__));
2016-01-06 17:06:30 -05:00
/**
* Application constants
*/
2015-11-16 19:30:04 -05:00
class AnimeClient {
2016-01-04 10:53:03 -05:00
const SESSION_SEGMENT = 'Aviat\AnimeClient\Auth';
2016-01-06 11:08:56 -05:00
const DEFAULT_CONTROLLER_NAMESPACE = 'Aviat\AnimeClient\Controller';
const DEFAULT_CONTROLLER = 'Aviat\AnimeClient\Controller\Anime';
const DEFAULT_CONTROLLER_METHOD = 'index';
2016-12-20 12:58:37 -05:00
const NOT_FOUND_METHOD = 'notFound';
const ERROR_MESSAGE_METHOD = 'errorPage';
2016-01-06 17:06:30 -05:00
const SRC_DIR = SRC_DIR;
2016-01-04 10:53:03 -05:00
/**
* Load configuration options from .toml files
*
* @param string $path - Path to load config
* @return array
*/
2016-12-20 12:58:37 -05:00
public static function loadToml(string $path): array
{
$output = [];
$files = glob("{$path}/*.toml");
foreach ($files as $file)
{
$key = str_replace('.toml', '', basename($file));
$toml = file_get_contents($file);
$config = Toml::Parse($toml);
if ($key === 'config')
{
foreach($config as $name => $value)
{
$output[$name] = $value;
}
continue;
}
$output[$key] = $config;
}
return $output;
}
2015-11-16 19:30:04 -05:00
}
// End of AnimeClient.php