N98\Magento\Application\ConfigFile::loadFile PHP Method

loadFile() public method

public loadFile ( string $path )
$path string
    public function loadFile($path)
    {
        $this->path = $path;
        if ('data://' !== substr($path, 0, 7) && !is_readable($path)) {
            throw new InvalidArgumentException(sprintf("Config-file is not readable: '%s'", $path));
        }
        $buffer = file_get_contents($path);
        if (!is_string($buffer)) {
            throw new InvalidArgumentException(sprintf("Fail while reading config-file: '%s'", $path));
        }
        $this->setBuffer($buffer);
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @test
  * @expectedException RuntimeException
  * @expectedExceptionMessage Failed to parse config-file 'data://,'
  */
 public function parseEmptyFile()
 {
     $configFile = new ConfigFile();
     $configFile->loadFile('data://,');
     $this->addToAssertionCount(1);
     $configFile->toArray();
     $this->fail('An expected exception has not been thrown.');
 }