Skip to content

Commit f0f7e2d

Browse files
committed
Update namespacing
1 parent b27ab45 commit f0f7e2d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+353
-353
lines changed

.gitignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
.idea
2-
vendor
1+
/.idea
2+
/vendor
3+
/composer.lock

composer.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
"ext-ctype": "*"
99
},
1010
"autoload": {
11-
"psr-4": {
12-
"LibDNS\\": "src/"
13-
},
11+
"psr-4": { "DaveRandom\\LibDNS\\": "src/" },
1412
"files": ["src/functions.php"]
1513
},
1614
"support": {

examples/AQuery.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@
1111
* @license http://www.opensource.org/licenses/mit-license.html MIT License
1212
* @version 1.0.0
1313
*/
14-
namespace LibDNS\Examples;
14+
namespace DaveRandom\LibDNS\Examples;
1515

16-
use \LibDNS\Messages\MessageFactory;
17-
use \LibDNS\Messages\MessageTypes;
18-
use \LibDNS\Records\QuestionFactory;
19-
use \LibDNS\Records\ResourceQTypes;
20-
use \LibDNS\Encoder\EncoderFactory;
21-
use \LibDNS\Decoder\DecoderFactory;
16+
use DaveRandom\LibDNS\Messages\MessageFactory;
17+
use DaveRandom\LibDNS\Messages\MessageTypes;
18+
use DaveRandom\LibDNS\Records\QuestionFactory;
19+
use DaveRandom\LibDNS\Records\ResourceQTypes;
20+
use DaveRandom\LibDNS\Encoder\EncoderFactory;
21+
use DaveRandom\LibDNS\Decoder\DecoderFactory;
2222

2323
// Config
2424
$queryName = 'faß.de';
2525
$serverIP = '8.8.8.8';
2626
$requestTimeout = 3;
2727

28-
require __DIR__ . '/autoload.php';
28+
require __DIR__ . '/../vendor/autoload.php';
2929

3030
// Create question record
3131
$question = (new QuestionFactory)->create(ResourceQTypes::A);
@@ -66,7 +66,7 @@
6666
$answers = $response->getAnswerRecords();
6767
if (count($answers)) {
6868
foreach ($response->getAnswerRecords() as $record) {
69-
/** @var \LibDNS\Records\Resource $record */
69+
/** @var \DaveRandom\LibDNS\Records\Resource $record */
7070
echo " " . $record->getData() . "\n";
7171
}
7272
} else {

examples/SOAQuery.php

+11-11
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@
1111
* @license http://www.opensource.org/licenses/mit-license.html MIT License
1212
* @version 1.0.0
1313
*/
14-
namespace LibDNS\Examples;
14+
namespace DaveRandom\LibDNS\Examples;
1515

16-
use \LibDNS\Messages\MessageFactory;
17-
use \LibDNS\Messages\MessageTypes;
18-
use \LibDNS\Records\QuestionFactory;
19-
use \LibDNS\Records\ResourceTypes;
20-
use \LibDNS\Records\ResourceQTypes;
21-
use \LibDNS\Encoder\EncoderFactory;
22-
use \LibDNS\Decoder\DecoderFactory;
23-
use \LibDNS\Records\TypeDefinitions\TypeDefinitionManagerFactory;
16+
use DaveRandom\LibDNS\Messages\MessageFactory;
17+
use DaveRandom\LibDNS\Messages\MessageTypes;
18+
use DaveRandom\LibDNS\Records\QuestionFactory;
19+
use DaveRandom\LibDNS\Records\ResourceTypes;
20+
use DaveRandom\LibDNS\Records\ResourceQTypes;
21+
use DaveRandom\LibDNS\Encoder\EncoderFactory;
22+
use DaveRandom\LibDNS\Decoder\DecoderFactory;
23+
use DaveRandom\LibDNS\Records\TypeDefinitions\TypeDefinitionManagerFactory;
2424

2525
// Config
2626
$queryName = 'google.com';
2727
$serverIP = '8.8.8.8';
2828
$requestTimeout = 3;
2929

30-
require __DIR__ . '/autoload.php';
30+
require __DIR__ . '/../vendor/autoload.php';
3131

3232
// Create question record
3333
$question = (new QuestionFactory)->create(ResourceQTypes::SOA);
@@ -84,7 +84,7 @@
8484
$answers = $response->getAnswerRecords();
8585
if (count($answers)) {
8686
foreach ($response->getAnswerRecords() as $record) {
87-
/** @var \LibDNS\Records\Resource $record */
87+
/** @var \DaveRandom\LibDNS\Records\Resource $record */
8888
echo " " . $record->getData() . "\n";
8989
}
9090
} else {

src/Decoder/Decoder.php

+65-65
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,28 @@
1111
* @license http://www.opensource.org/licenses/mit-license.html MIT License
1212
* @version 2.0.0
1313
*/
14-
namespace LibDNS\Decoder;
15-
16-
use LibDNS\Messages\Message;
17-
use LibDNS\Messages\MessageFactory;
18-
use LibDNS\Packets\Packet;
19-
use LibDNS\Packets\PacketFactory;
20-
use LibDNS\Records\Question;
21-
use LibDNS\Records\QuestionFactory;
22-
use LibDNS\Records\Resource;
23-
use LibDNS\Records\ResourceBuilder;
24-
use LibDNS\Records\Types\Anything;
25-
use LibDNS\Records\Types\BitMap;
26-
use LibDNS\Records\Types\Char;
27-
use LibDNS\Records\Types\CharacterString;
28-
use LibDNS\Records\Types\DomainName;
29-
use LibDNS\Records\Types\IPv4Address;
30-
use LibDNS\Records\Types\IPv6Address;
31-
use LibDNS\Records\Types\Long;
32-
use LibDNS\Records\Types\Short;
33-
use LibDNS\Records\Types\Type;
34-
use LibDNS\Records\Types\TypeBuilder;
35-
use LibDNS\Records\Types\Types;
14+
namespace DaveRandom\LibDNS\Decoder;
15+
16+
use DaveRandom\LibDNS\Messages\Message;
17+
use DaveRandom\LibDNS\Messages\MessageFactory;
18+
use DaveRandom\LibDNS\Packets\Packet;
19+
use DaveRandom\LibDNS\Packets\PacketFactory;
20+
use DaveRandom\LibDNS\Records\Question;
21+
use DaveRandom\LibDNS\Records\QuestionFactory;
22+
use DaveRandom\LibDNS\Records\Resource as ResourceRecord;
23+
use DaveRandom\LibDNS\Records\ResourceBuilder;
24+
use DaveRandom\LibDNS\Records\Types\Anything;
25+
use DaveRandom\LibDNS\Records\Types\BitMap;
26+
use DaveRandom\LibDNS\Records\Types\Char;
27+
use DaveRandom\LibDNS\Records\Types\CharacterString;
28+
use DaveRandom\LibDNS\Records\Types\DomainName;
29+
use DaveRandom\LibDNS\Records\Types\IPv4Address;
30+
use DaveRandom\LibDNS\Records\Types\IPv6Address;
31+
use DaveRandom\LibDNS\Records\Types\Long;
32+
use DaveRandom\LibDNS\Records\Types\Short;
33+
use DaveRandom\LibDNS\Records\Types\Type;
34+
use DaveRandom\LibDNS\Records\Types\TypeBuilder;
35+
use DaveRandom\LibDNS\Records\Types\Types;
3636

3737
/**
3838
* Decodes raw network data to Message objects
@@ -44,32 +44,32 @@
4444
class Decoder
4545
{
4646
/**
47-
* @var \LibDNS\Packets\PacketFactory
47+
* @var \DaveRandom\LibDNS\Packets\PacketFactory
4848
*/
4949
private $packetFactory;
5050

5151
/**
52-
* @var \LibDNS\Messages\MessageFactory
52+
* @var \DaveRandom\LibDNS\Messages\MessageFactory
5353
*/
5454
private $messageFactory;
5555

5656
/**
57-
* @var \LibDNS\Records\QuestionFactory
57+
* @var \DaveRandom\LibDNS\Records\QuestionFactory
5858
*/
5959
private $questionFactory;
6060

6161
/**
62-
* @var \LibDNS\Records\ResourceBuilder
62+
* @var \DaveRandom\LibDNS\Records\ResourceBuilder
6363
*/
6464
private $resourceBuilder;
6565

6666
/**
67-
* @var \LibDNS\Records\Types\TypeBuilder
67+
* @var \DaveRandom\LibDNS\Records\Types\TypeBuilder
6868
*/
6969
private $typeBuilder;
7070

7171
/**
72-
* @var \LibDNS\Decoder\DecodingContextFactory
72+
* @var \DaveRandom\LibDNS\Decoder\DecodingContextFactory
7373
*/
7474
private $decodingContextFactory;
7575

@@ -81,12 +81,12 @@ class Decoder
8181
/**
8282
* Constructor
8383
*
84-
* @param \LibDNS\Packets\PacketFactory $packetFactory
85-
* @param \LibDNS\Messages\MessageFactory $messageFactory
86-
* @param \LibDNS\Records\QuestionFactory $questionFactory
87-
* @param \LibDNS\Records\ResourceBuilder $resourceBuilder
88-
* @param \LibDNS\Records\Types\TypeBuilder $typeBuilder
89-
* @param \LibDNS\Decoder\DecodingContextFactory $decodingContextFactory
84+
* @param \DaveRandom\LibDNS\Packets\PacketFactory $packetFactory
85+
* @param \DaveRandom\LibDNS\Messages\MessageFactory $messageFactory
86+
* @param \DaveRandom\LibDNS\Records\QuestionFactory $questionFactory
87+
* @param \DaveRandom\LibDNS\Records\ResourceBuilder $resourceBuilder
88+
* @param \DaveRandom\LibDNS\Records\Types\TypeBuilder $typeBuilder
89+
* @param \DaveRandom\LibDNS\Decoder\DecodingContextFactory $decodingContextFactory
9090
* @param bool $allowTrailingData
9191
*/
9292
public function __construct(
@@ -110,7 +110,7 @@ public function __construct(
110110
/**
111111
* Read a specified number of bytes of data from a packet
112112
*
113-
* @param \LibDNS\Packets\Packet $packet
113+
* @param \DaveRandom\LibDNS\Packets\Packet $packet
114114
* @param int $length
115115
* @return string
116116
* @throws \UnexpectedValueException When the read operation does not result in the requested number of bytes
@@ -127,8 +127,8 @@ private function readDataFromPacket(Packet $packet, int $length): string
127127
/**
128128
* Decode the header section of the message
129129
*
130-
* @param \LibDNS\Decoder\DecodingContext $decodingContext
131-
* @param \LibDNS\Messages\Message $message
130+
* @param \DaveRandom\LibDNS\Decoder\DecodingContext $decodingContext
131+
* @param \DaveRandom\LibDNS\Messages\Message $message
132132
* @throws \UnexpectedValueException When the header section is invalid
133133
*/
134134
private function decodeHeader(DecodingContext $decodingContext, Message $message)
@@ -157,8 +157,8 @@ private function decodeHeader(DecodingContext $decodingContext, Message $message
157157
/**
158158
* Decode an Anything field
159159
*
160-
* @param \LibDNS\Decoder\DecodingContext $decodingContext
161-
* @param \LibDNS\Records\Types\Anything $anything The object to populate with the result
160+
* @param \DaveRandom\LibDNS\Decoder\DecodingContext $decodingContext
161+
* @param \DaveRandom\LibDNS\Records\Types\Anything $anything The object to populate with the result
162162
* @param int $length
163163
* @return int The number of packet bytes consumed by the operation
164164
* @throws \UnexpectedValueException When the packet data is invalid
@@ -173,8 +173,8 @@ private function decodeAnything(DecodingContext $decodingContext, Anything $anyt
173173
/**
174174
* Decode a BitMap field
175175
*
176-
* @param \LibDNS\Decoder\DecodingContext $decodingContext
177-
* @param \LibDNS\Records\Types\BitMap $bitMap The object to populate with the result
176+
* @param \DaveRandom\LibDNS\Decoder\DecodingContext $decodingContext
177+
* @param \DaveRandom\LibDNS\Records\Types\BitMap $bitMap The object to populate with the result
178178
* @param int $length
179179
* @return int The number of packet bytes consumed by the operation
180180
* @throws \UnexpectedValueException When the packet data is invalid
@@ -189,8 +189,8 @@ private function decodeBitMap(DecodingContext $decodingContext, BitMap $bitMap,
189189
/**
190190
* Decode a Char field
191191
*
192-
* @param \LibDNS\Decoder\DecodingContext $decodingContext
193-
* @param \LibDNS\Records\Types\Char $char The object to populate with the result
192+
* @param \DaveRandom\LibDNS\Decoder\DecodingContext $decodingContext
193+
* @param \DaveRandom\LibDNS\Records\Types\Char $char The object to populate with the result
194194
* @return int The number of packet bytes consumed by the operation
195195
* @throws \UnexpectedValueException When the packet data is invalid
196196
*/
@@ -205,8 +205,8 @@ private function decodeChar(DecodingContext $decodingContext, Char $char): int
205205
/**
206206
* Decode a CharacterString field
207207
*
208-
* @param \LibDNS\Decoder\DecodingContext $decodingContext
209-
* @param \LibDNS\Records\Types\CharacterString $characterString The object to populate with the result
208+
* @param \DaveRandom\LibDNS\Decoder\DecodingContext $decodingContext
209+
* @param \DaveRandom\LibDNS\Records\Types\CharacterString $characterString The object to populate with the result
210210
* @return int The number of packet bytes consumed by the operation
211211
* @throws \UnexpectedValueException When the packet data is invalid
212212
*/
@@ -222,8 +222,8 @@ private function decodeCharacterString(DecodingContext $decodingContext, Charact
222222
/**
223223
* Decode a DomainName field
224224
*
225-
* @param \LibDNS\Decoder\DecodingContext $decodingContext
226-
* @param \LibDNS\Records\Types\DomainName $domainName The object to populate with the result
225+
* @param \DaveRandom\LibDNS\Decoder\DecodingContext $decodingContext
226+
* @param \DaveRandom\LibDNS\Records\Types\DomainName $domainName The object to populate with the result
227227
* @return int The number of packet bytes consumed by the operation
228228
* @throws \UnexpectedValueException When the packet data is invalid
229229
*/
@@ -278,8 +278,8 @@ private function decodeDomainName(DecodingContext $decodingContext, DomainName $
278278
/**
279279
* Decode an IPv4Address field
280280
*
281-
* @param \LibDNS\Decoder\DecodingContext $decodingContext
282-
* @param \LibDNS\Records\Types\IPv4Address $ipv4Address The object to populate with the result
281+
* @param \DaveRandom\LibDNS\Decoder\DecodingContext $decodingContext
282+
* @param \DaveRandom\LibDNS\Records\Types\IPv4Address $ipv4Address The object to populate with the result
283283
* @return int The number of packet bytes consumed by the operation
284284
* @throws \UnexpectedValueException When the packet data is invalid
285285
*/
@@ -294,8 +294,8 @@ private function decodeIPv4Address(DecodingContext $decodingContext, IPv4Address
294294
/**
295295
* Decode an IPv6Address field
296296
*
297-
* @param \LibDNS\Decoder\DecodingContext $decodingContext
298-
* @param \LibDNS\Records\Types\IPv6Address $ipv6Address The object to populate with the result
297+
* @param \DaveRandom\LibDNS\Decoder\DecodingContext $decodingContext
298+
* @param \DaveRandom\LibDNS\Records\Types\IPv6Address $ipv6Address The object to populate with the result
299299
* @return int The number of packet bytes consumed by the operation
300300
* @throws \UnexpectedValueException When the packet data is invalid
301301
*/
@@ -310,8 +310,8 @@ private function decodeIPv6Address(DecodingContext $decodingContext, IPv6Address
310310
/**
311311
* Decode a Long field
312312
*
313-
* @param \LibDNS\Decoder\DecodingContext $decodingContext
314-
* @param \LibDNS\Records\Types\Long $long The object to populate with the result
313+
* @param \DaveRandom\LibDNS\Decoder\DecodingContext $decodingContext
314+
* @param \DaveRandom\LibDNS\Records\Types\Long $long The object to populate with the result
315315
* @return int The number of packet bytes consumed by the operation
316316
* @throws \UnexpectedValueException When the packet data is invalid
317317
*/
@@ -326,8 +326,8 @@ private function decodeLong(DecodingContext $decodingContext, Long $long): int
326326
/**
327327
* Decode a Short field
328328
*
329-
* @param \LibDNS\Decoder\DecodingContext $decodingContext
330-
* @param \LibDNS\Records\Types\Short $short The object to populate with the result
329+
* @param \DaveRandom\LibDNS\Decoder\DecodingContext $decodingContext
330+
* @param \DaveRandom\LibDNS\Records\Types\Short $short The object to populate with the result
331331
* @return int The number of packet bytes consumed by the operation
332332
* @throws \UnexpectedValueException When the packet data is invalid
333333
*/
@@ -342,8 +342,8 @@ private function decodeShort(DecodingContext $decodingContext, Short $short): in
342342
/**
343343
* Decode a Type field
344344
*
345-
* @param \LibDNS\Decoder\DecodingContext $decodingContext
346-
* @param \LibDNS\Records\Types\Type $type The object to populate with the result
345+
* @param \DaveRandom\LibDNS\Decoder\DecodingContext $decodingContext
346+
* @param \DaveRandom\LibDNS\Records\Types\Type $type The object to populate with the result
347347
* @param int $length Expected data length
348348
* @return int The number of packet bytes consumed by the operation
349349
* @throws \UnexpectedValueException When the packet data is invalid
@@ -379,13 +379,13 @@ private function decodeType(DecodingContext $decodingContext, Type $type, int $l
379379
/**
380380
* Decode a question record
381381
*
382-
* @param \LibDNS\Decoder\DecodingContext $decodingContext
383-
* @return \LibDNS\Records\Question
382+
* @param \DaveRandom\LibDNS\Decoder\DecodingContext $decodingContext
383+
* @return \DaveRandom\LibDNS\Records\Question
384384
* @throws \UnexpectedValueException When the record is invalid
385385
*/
386386
private function decodeQuestionRecord(DecodingContext $decodingContext): Question
387387
{
388-
/** @var \LibDNS\Records\Types\DomainName $domainName */
388+
/** @var \DaveRandom\LibDNS\Records\Types\DomainName $domainName */
389389
$domainName = $this->typeBuilder->build(Types::DOMAIN_NAME);
390390
$this->decodeDomainName($decodingContext, $domainName);
391391
$meta = \unpack('ntype/nclass', $this->readDataFromPacket($decodingContext->getPacket(), 4));
@@ -400,14 +400,14 @@ private function decodeQuestionRecord(DecodingContext $decodingContext): Questio
400400
/**
401401
* Decode a resource record
402402
*
403-
* @param \LibDNS\Decoder\DecodingContext $decodingContext
404-
* @return \LibDNS\Records\Resource
403+
* @param \DaveRandom\LibDNS\Decoder\DecodingContext $decodingContext
404+
* @return \DaveRandom\LibDNS\Records\Resource
405405
* @throws \UnexpectedValueException When the record is invalid
406406
* @throws \InvalidArgumentException When a type subtype is unknown
407407
*/
408-
private function decodeResourceRecord(DecodingContext $decodingContext): Resource
408+
private function decodeResourceRecord(DecodingContext $decodingContext): ResourceRecord
409409
{
410-
/** @var \LibDNS\Records\Types\DomainName $domainName */
410+
/** @var \DaveRandom\LibDNS\Records\Types\DomainName $domainName */
411411
$domainName = $this->typeBuilder->build(Types::DOMAIN_NAME);
412412
$this->decodeDomainName($decodingContext, $domainName);
413413
$meta = \unpack('ntype/nclass/Nttl/nlength', $this->readDataFromPacket($decodingContext->getPacket(), 10));
@@ -446,7 +446,7 @@ private function decodeResourceRecord(DecodingContext $decodingContext): Resourc
446446
* Decode a Message from raw network data
447447
*
448448
* @param string $data The data string to decode
449-
* @return \LibDNS\Messages\Message
449+
* @return \DaveRandom\LibDNS\Messages\Message
450450
* @throws \UnexpectedValueException When the packet data is invalid
451451
* @throws \InvalidArgumentException When a type subtype is unknown
452452
*/

0 commit comments

Comments
 (0)