/** * Loads the Toml File * * @param string $file * * @throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException * @return array */ protected function loadFile($file) { if (!stream_is_local($file)) { throw new InvalidArgumentException(sprintf('This is not a local file "%s".', $file)); } if (!file_exists($file)) { throw new InvalidArgumentException(sprintf('The service file "%s" is not valid.', $file)); } return Toml::Parse($file); }
public function __construct($override_path = null) { $env_path = getenv('KOSH_CONFIG'); if ($env_path !== false) { $override_path = $env_path; } $this->mConfigFile = new ConfigFile($override_path); if ($this->mConfigFile->isValid()) { if ($this->mConfigFile->isURL()) { $tmpConfig = file_get_contents($this->mConfigFile->getFilename()); $this->mData = Toml::Parse($tmpConfig); } else { $this->mData = Toml::Parse($this->mConfigFile->getFilename()); } } }
/** * parse toml * * @param string $file * @return array */ protected function parseToml($file) { $cacheDir = sprintf('%s/framework/cache/tomlara/', storage_path()); $cacheFile = $cacheDir . basename($file) . '.cache.php'; if (@filemtime($cacheFile) < filemtime($file)) { $content = null === ($toml = Toml::Parse($file)) ? [] : $toml; array_walk_recursive($content, [$this, 'parseFunc']); if (!file_exists($cacheDir)) { @mkdir($cacheDir, 0644); } file_put_contents($cacheFile, '<?php' . PHP_EOL . PHP_EOL . 'return ' . var_export($content, true) . ';'); } else { $content = (require $cacheFile); } return $content; }
public function testArrayOfTables() { $tb = new TomlBuilder(); $result = $tb->addArrayTables('fruit')->addValue('name', 'apple')->addArrayTables('fruit.variety')->addValue('name', 'red delicious')->addArrayTables('fruit.variety')->addValue('name', 'granny smith')->addArrayTables('fruit')->addValue('name', 'banana')->addArrayTables('fruit.variety')->addValue('name', 'platain')->getTomlString(); $this->assertNotNull(Toml::Parse($result)); }
/** * Loads in the given file and parses it. * * @param string $file File to load * * @return array The parsed file data * * @since 0.2.4 * @codeCoverageIgnore */ protected function loadFile($file = null) { $this->file = $file; $contents = $this->parseVars(Utils::getContent($file)); return TomlLib::Parse($contents); }
/** * Parse toml files. * * @param array $paths * @return array */ private function parseToml(array $paths) { $toml = []; foreach ($paths as $path) { $toml[basename($path, '.toml')] = Toml::Parse($path); } return $toml; }