/** * Create new Scope from the configuration string. * * @param \RomanPitak\Nginx\Config\Text $configString * @return Scope * @throws Exception */ public static function fromString(Text $configString) { $scope = new Scope(); while (false === $configString->eof()) { if (true === $configString->isEmptyLine()) { $scope->addPrintable(EmptyLine::fromString($configString)); } $char = $configString->getChar(); if ('#' === $char) { $scope->addPrintable(Comment::fromString($configString)); continue; } if ('a' <= $char && 'z' >= $char) { $scope->addDirective(Directive::fromString($configString)); continue; } if ('}' === $configString->getChar()) { break; } $configString->inc(); } return $scope; }