1
0
mirror of https://github.com/danog/dns.git synced 2024-12-12 09:29:46 +01:00
dns/lib/Native/NativeDecoderFactory.php

49 lines
1.4 KiB
PHP
Raw Normal View History

2019-08-22 20:44:19 +02:00
<?php
/**
* Creates NativeDecoder objects.
*
* @author Daniil Gentili <https://daniil.it>, Chris Wright <https://github.com/DaveRandom>
* @copyright Copyright (c) Chris Wright <https://github.com/DaveRandom>,
* @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
2019-08-22 20:46:31 +02:00
2019-08-22 20:44:19 +02:00
namespace Amp\Dns\Native;
use \LibDNS\Messages\MessageFactory;
use \LibDNS\Packets\PacketFactory;
use \LibDNS\Records\QuestionFactory;
use \LibDNS\Records\RecordCollectionFactory;
use \LibDNS\Records\TypeDefinitions\TypeDefinitionManager;
use \LibDNS\Records\Types\TypeBuilder;
use \LibDNS\Records\Types\TypeFactory;
use LibDNS\Decoder\DecoderFactory;
use LibDNS\Encoder\EncodingContextFactory;
/**
* Creates NativeDecoder objects.
*
* @author Daniil Gentili <https://daniil.it>, Chris Wright <https://github.com/DaveRandom>
*/
class NativeDecoderFactory
{
/**
* Create a new NativeDecoder object.
*
* @param \LibDNS\Records\TypeDefinitions\TypeDefinitionManager $typeDefinitionManager
* @return NativeDecoder
*/
public function create(TypeDefinitionManager $typeDefinitionManager = null): NativeDecoder
{
$typeBuilder = new TypeBuilder(new TypeFactory);
return new NativeDecoder(
new PacketFactory,
new MessageFactory(new RecordCollectionFactory),
new QuestionFactory,
$typeBuilder,
new EncodingContextFactory,
new DecoderFactory
);
}
}