HummingBirdAnimeClient/src/AnimeClient.php

56 lines
1.2 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 List Client
2015-11-16 19:30:04 -05:00
*
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
2015-11-16 19:30:04 -05:00
*
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>
2018-01-15 14:43:15 -05:00
* @copyright 2015 - 2018 Timothy J. Warren
2016-08-30 10:01:18 -04:00
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.0
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
2015-11-16 19:30:04 -05:00
*/
namespace Aviat\AnimeClient;
use Yosymfony\Toml\Toml;
2017-12-06 14:40:13 -05:00
if ( ! \function_exists('Aviat\AnimeClient\loadToml'))
{
/**
* Load configuration options from .toml files
*
* @param string $path - Path to load config
* @return array
*/
function loadToml(string $path): array
{
2017-12-06 14:40:13 -05:00
$output = [];
$files = glob("{$path}/*.toml");
2017-12-06 14:40:13 -05:00
foreach ($files as $file)
{
2017-12-06 14:40:13 -05:00
$key = str_replace('.toml', '', basename($file));
$toml = file_get_contents($file);
$config = Toml::parse($toml);
if ($key === 'config')
{
2017-12-06 14:40:13 -05:00
foreach($config as $name => $value)
{
$output[$name] = $value;
}
continue;
}
2017-12-06 14:40:13 -05:00
$output[$key] = $config;
}
2017-12-06 14:40:13 -05:00
return $output;
}
2017-12-06 14:40:13 -05:00
}