/** * * @param string $directiveString * @return \webignition\RobotsTxt\Directive\Directive */ public function getDirective($directiveString) { $directive = new \webignition\RobotsTxt\Directive\Directive(); $directive->parse($directiveString); if ($directive->is(self::USER_AGENT_FIELD_NAME)) { $directive = new \webignition\RobotsTxt\UserAgentDirective\UserAgentDirective(); $directive->parse($directiveString); } return $directive; }
private function deriveStateFromCurrentLine() { if (!$this->isCurrentLineADirective()) { $this->sourceLineIndex++; return $this->currentState = self::STATE_UNKNOWN; } $directive = new \webignition\RobotsTxt\Directive\Directive(); $directive->parse($this->getCurrentLine()); if ($directive->is(self::USER_AGENT_FIELD_NAME)) { return $this->currentState = self::STATE_STARTING_RECORD; } return $this->currentState = self::STATE_ADDING_TO_FILE; }
/** * * @param string $directiveString * @return \webignition\RobotsTxt\Directive\Directive */ protected function getNewDirective($directiveString) { $directive = new \webignition\RobotsTxt\Directive\Directive(); $directive->parse($directiveString); return $directive; }