Пример #1
0
 /**
  * @param $pathOrString
  *
  * @return Server[]
  * @since 1.0
  */
 public static function fileOrContent($pathOrString)
 {
     $isPath = stristr($pathOrString, DIRECTORY_SEPARATOR) || file_exists($pathOrString);
     if ($isPath) {
         $scope = Scope::fromFile($pathOrString);
     } else {
         $scope = Scope::fromString($pathOrString);
     }
     $results = [];
     foreach ($scope->getDirectives() as $directive) {
         if ($directive->getName() === 'server' && $directive->getChildScope() !== null) {
             $tmp = new static();
             $tmp->iterateDirectives($directive->getChildScope()->getDirectives());
             $results[] = $tmp;
         }
     }
     return $results;
 }
 public function testFromFile()
 {
     Scope::fromFile('tests/test_input.conf')->saveToFile('build/out.conf');
     $this->assertEquals(@file_get_contents('tests/test_input.conf'), @file_get_contents('build/out.conf'));
 }