blessing-skin-server/app/Services/Translations/Yaml.php

27 lines
556 B
PHP
Raw Normal View History

2019-09-06 18:52:34 +08:00
<?php
namespace App\Services\Translations;
use Illuminate\Contracts\Cache\Repository;
use Symfony\Component\Yaml\Yaml as YamlParser;
2019-09-07 21:23:38 +08:00
class Yaml
2019-09-06 18:52:34 +08:00
{
/** @var Repository */
protected $cache;
2019-09-07 10:32:26 +08:00
public function __construct(Repository $cache)
2019-09-06 18:52:34 +08:00
{
$this->cache = $cache;
}
public function parse(string $path): array
2019-09-06 18:52:34 +08:00
{
$key = 'yaml-trans-'.md5($path).'-'.filemtime($path);
2019-09-06 18:52:34 +08:00
return $this->cache->rememberForever($key, function () use ($path) {
return YamlParser::parseFile($path);
});
}
}