コード例 #1
0
 /**
  *
  * @param array $options
  * @return \webignition\RobotsTxt\DirectiveList\DirectiveList 
  */
 public function getDirectiveList($options = array())
 {
     $directives = $this->sourceDirectiveList->get();
     if (isset($options['field'])) {
         foreach ($directives as $directiveIndex => $directive) {
             /* @var $directive \webignition\RobotsTxt\Directive\Directive */
             if (!$directive->is($options['field'])) {
                 unset($directives[$directiveIndex]);
             }
         }
     }
     if (isset($options['value'])) {
         foreach ($directives as $directiveIndex => $directive) {
             /* @var $directive \webignition\RobotsTxt\Directive\Directive */
             if ((string) $directive->getValue() != $options['value']) {
                 unset($directives[$directiveIndex]);
             }
         }
     }
     $directiveList = new \webignition\RobotsTxt\DirectiveList\DirectiveList();
     foreach ($directives as $directive) {
         $directiveList->add((string) $directive);
     }
     return $directiveList;
 }
コード例 #2
0
 public function testCastingListToString()
 {
     $list = new DirectiveList();
     $list->add('field1:value1');
     $this->assertEquals('field1:value1', (string) $list);
     $list->add('field2:value2');
     $this->assertEquals('field1:value1' . "\n" . 'field2:value2', (string) $list);
 }
コード例 #3
0
 /**
  *
  * @param string $userAgentString
  * @return boolean 
  */
 public function contains($userAgentString)
 {
     return parent::contains('user-agent:' . $userAgentString);
 }