/** * Find DNS entity by FQDN. * * @param string $fqdn * * @return array */ public function findByFqdn($fqdn) { $entities = $this->findAll(); $arr = array(); foreach ($entities as $entity) { /** @var $entity Dns */ $collection = $entity->getZonecollection(); $records = $collection->getValues(); foreach ($records as $record) { /** @var $record AbstractResourceRecord */ $recordFqdn = FqdnTransformer::getFqdn($entity, $record); if ($fqdn == $recordFqdn) { $arr[] = $entity; } } } return $arr; }
/** * Get resource record by FQDN. * * @param Dns $dns * @param string $fqdn * * @return AbstractResourceRecord[] */ protected function _getResourceRecordsByFqdn(Dns $dns, $fqdn) { $records = array(); $matRecords = array(); // Collect records by type foreach (self::$_types as $type) { $records = array_merge($records, $dns->getZonecollection()->getByType($type)); } // Collect matching records foreach ($records as $rr) { /** @var $rr AbstractResourceRecord */ if (FqdnTransformer::getFqdn($dns, $rr) === $fqdn) { $matRecords[] = $rr; } } return $matRecords; }
/** * Test getFqdn. * * @dataProvider provider */ public function testGetFqdn(Dns $dns, AbstractResourceRecord $rr, $expect) { $result = FqdnTransformer::getFqdn($dns, $rr); $this->assertEquals($expect, $result); }