/**
  * Parses all bot metadatas
  *
  * @param MetadataCollection $collection
  * @param $content
  * @return array
  */
 private function parseBots(MetadataCollection $collection, $content)
 {
     if (!isset($content['bots'])) {
         return;
     }
     foreach ($content['bots'] as $name => $bot) {
         $ip = isset($bot['ip']) ? $bot['ip'] : null;
         $metadata = new Metadata($name, $bot['agent'], $ip);
         if (isset($bot['type'])) {
             $metadata->setType($bot['type']);
         }
         if (isset($bot['meta'])) {
             $metadata->setMeta($bot['meta']);
         }
         if (isset($bot['agent_match'])) {
             $metadata->setAgentMatch($bot['agent_match']);
         }
         $collection->addMetadata($metadata);
     }
 }
Exemple #2
0
 public function testMatchRegexp()
 {
     $metadata = new Metadata('TestBot', 'test', null, Metadata::TYPE_BOT, array(), Metadata::AGENT_MATCH_REGEXP);
     $this->assertTrue($metadata->match('test-agent', '127.0.0.1'));
 }
 private function createMetadata($agent, $ip = null)
 {
     $metadata = new Metadata('TestBot', $agent, $ip, Metadata::TYPE_BOT);
     $metadata->setAgentMatch(Metadata::AGENT_MATCH_EXACT);
     return $metadata;
 }