/** * Create a resource record from a Line * * @param Line $line * @return ResourceRecord */ private function lineToRr(Line $line) { $rr = new ResourceRecord(); if (null !== ($class = Interpreter::getClassFromLine($line->getData()))) { $rr->setClass($class); } $rr->setRdata($this->getRData($line->getData())); $rr->setComment($line->getComment()); $rr->setName(Interpreter::getResourceNameFromLine($line->getData())); return $rr; }
public function testGetClassFromLine() { $test_data1 = 'www IN CNAME example.com ; This is a comment that needs to be stripped'; $test_data2 = ' @ A 255.255.255.255; Comments'; $test_data3 = '@ HS TXT "This is some data"'; $test_data4 = " IN\tCH TXT \"This is some data\""; $test_data5 = 'www IM CNAME example.com; Comments '; $this->assertEquals('IN', Interpreter::getClassFromLine($test_data1)); $this->assertEquals(null, Interpreter::getClassFromLine($test_data2)); $this->assertEquals('HS', Interpreter::getClassFromLine($test_data3)); $this->assertEquals('CH', Interpreter::getClassFromLine($test_data4)); $this->assertEquals(null, Interpreter::getClassFromLine($test_data5)); }