Passed
Push — master ( 1b54b9...ff455f )
by Sam
10:10 queued 11s
created

Factory::SIG()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 11
c 2
b 0
f 0
nc 1
nop 9
dl 0
loc 16
ccs 12
cts 12
cp 1
crap 1
rs 9.9

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of Badcow DNS Library.
7
 *
8
 * (c) Samuel Williams <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Badcow\DNS\Rdata;
15
16
use Badcow\DNS\Parser\ParseException;
17
use Badcow\DNS\Parser\Tokens;
18
use PhpIP\IPBlock;
19
20
class Factory
21
{
22
    /**
23
     * Creates a new RData object from a name.
24
     *
25
     * @param string $name
26
     *
27
     * @throws UnsupportedTypeException
28
     *
29
     * @return RdataInterface
30
     */
31 32
    public static function newRdataFromName(string $name): RdataInterface
32
    {
33 32
        if (!self::isTypeImplemented($name)) {
34 1
            throw new UnsupportedTypeException($name);
35
        }
36
37 31
        $className = self::getRdataClassName($name);
38
39 31
        return new $className();
40
    }
41
42
    /**
43
     * @param int $id
44
     *
45
     * @return RdataInterface
46
     *
47
     * @throws UnsupportedTypeException
48
     */
49 11
    public static function newRdataFromId(int $id): RdataInterface
50
    {
51 11
        return self::newRdataFromName(Types::getName($id));
52
    }
53
54
    /**
55
     * @param string $name
56
     *
57
     * @return bool
58
     */
59 34
    public static function isTypeImplemented(string $name): bool
60
    {
61 34
        return class_exists(self::getRdataClassName($name));
62
    }
63
64
    /**
65
     * @param int $typeCode
66
     *
67
     * @return bool
68
     */
69 3
    public static function isTypeCodeImplemented(int $typeCode): bool
70
    {
71
        try {
72 3
            return self::isTypeImplemented(Types::getName($typeCode));
73 2
        } catch (UnsupportedTypeException $e) {
74 2
            return false;
75
        }
76
    }
77
78
    /**
79
     * @param string $type
80
     * @param string $text
81
     *
82
     * @return RdataInterface
83
     *
84
     * @throws ParseException|UnsupportedTypeException
85
     */
86 23
    public static function textToRdataType(string $type, string $text): RdataInterface
87
    {
88 23
        if (1 === preg_match('/^TYPE(\d+)$/', $type, $matches)) {
89 3
            $typeCode = (int) $matches[1];
90 3
            if (self::isTypeCodeImplemented($typeCode)) {
91 2
                $type = Types::getName($typeCode);
92
            } else {
93 2
                $rdata = new UnknownType();
94 2
                $rdata->fromText($text);
95 2
                $rdata->setTypeCode($typeCode);
96
97 2
                return $rdata;
98
            }
99
        }
100
101 22
        if (!self::isTypeImplemented($type)) {
102 2
            return new PolymorphicRdata($type, $text);
103
        }
104
105 20
        if (1 === preg_match('/^\\\#\s+(\d+)(\s[a-f0-9\s]+)?$/i', $text, $matches)) {
106 2
            if ('0' === $matches[1]) {
107
                $className = self::getRdataClassName($type);
108
109
                return new $className();
110
            }
111
112 2
            if (false === $wireFormat = hex2bin(str_replace(Tokens::SPACE, '', $matches[2]))) {
113
                throw new ParseException(sprintf('Unable to decode hexadecimal parameter in "%s".', $text));
114
            }
115 2
            $rdata = self::newRdataFromName($type);
116 2
            $rdata->fromWire($wireFormat);
117
118 2
            return $rdata;
119
        }
120
121 18
        $rdata = self::newRdataFromName($type);
122 18
        $rdata->fromText($text);
123
124 16
        return $rdata;
125
    }
126
127
    /**
128
     * Get the fully qualified class name of the RData class for $type.
129
     *
130
     * @param string $type
131
     *
132
     * @return string
133
     */
134 34
    public static function getRdataClassName(string $type): string
135
    {
136 34
        return __NAMESPACE__.'\\'.strtoupper($type);
137
    }
138
139
    /**
140
     * Create a new AAAA R-Data object.
141
     *
142
     * @param string $address
143
     *
144
     * @return AAAA
145
     */
146 13
    public static function AAAA(string $address): AAAA
147
    {
148 13
        $rdata = new AAAA();
149 13
        $rdata->setAddress($address);
150
151 13
        return $rdata;
152
    }
153
154
    /**
155
     * Create a new A R-Data object.
156
     *
157
     * @param string $address
158
     *
159
     * @return A
160
     */
161 16
    public static function A(string $address): A
162
    {
163 16
        $rdata = new A();
164 16
        $rdata->setAddress($address);
165
166 16
        return $rdata;
167
    }
168
169
    /**
170
     * Create a new CNAME object.
171
     *
172
     * @param string $cname
173
     *
174
     * @return CNAME
175
     */
176 10
    public static function CNAME(string $cname): CNAME
177
    {
178 10
        $rdata = new CNAME();
179 10
        $rdata->setTarget($cname);
180
181 10
        return $rdata;
182
    }
183
184
    /**
185
     * @param string $cpu
186
     * @param string $os
187
     *
188
     * @return HINFO
189
     */
190 10
    public static function HINFO(string $cpu, string $os): HINFO
191
    {
192 10
        $rdata = new HINFO();
193 10
        $rdata->setCpu($cpu);
194 10
        $rdata->setOs($os);
195
196 10
        return $rdata;
197
    }
198
199
    /**
200
     * @param int    $preference
201
     * @param string $exchange
202
     *
203
     * @return MX
204
     */
205 12
    public static function MX(int $preference, string $exchange): MX
206
    {
207 12
        $rdata = new MX();
208 12
        $rdata->setPreference($preference);
209 12
        $rdata->setExchange($exchange);
210
211 12
        return $rdata;
212
    }
213
214
    /**
215
     * @param string $mname
216
     * @param string $rname
217
     * @param int    $serial
218
     * @param int    $refresh
219
     * @param int    $retry
220
     * @param int    $expire
221
     * @param int    $minimum
222
     *
223
     * @return SOA
224
     */
225 15
    public static function SOA(string $mname, string $rname, int $serial, int $refresh, int $retry, int $expire, int $minimum): SOA
226
    {
227 15
        $rdata = new SOA();
228 15
        $rdata->setMname($mname);
229 15
        $rdata->setRname($rname);
230 15
        $rdata->setSerial($serial);
231 15
        $rdata->setRefresh($refresh);
232 15
        $rdata->setRetry($retry);
233 15
        $rdata->setExpire($expire);
234 15
        $rdata->setMinimum($minimum);
235
236 15
        return $rdata;
237
    }
238
239
    /**
240
     * @param string $nsdname
241
     *
242
     * @return NS
243
     */
244 14
    public static function NS(string $nsdname): NS
245
    {
246 14
        $rdata = new NS();
247 14
        $rdata->setTarget($nsdname);
248
249 14
        return $rdata;
250
    }
251
252
    /**
253
     * @param string $text
254
     *
255
     * @return TXT
256
     */
257 11
    public static function TXT(string $text): TXT
258
    {
259 11
        $txt = new TXT();
260 11
        $txt->setText($text);
261
262 11
        return $txt;
263
    }
264
265
    /**
266
     * @param string $text
267
     *
268
     * @return SPF
269
     */
270 2
    public static function SPF(string $text): SPF
271
    {
272 2
        $spf = new SPF();
273 2
        $spf->setText($text);
274
275 2
        return $spf;
276
    }
277
278
    /**
279
     * @param string $target
280
     *
281
     * @return DNAME
282
     */
283 10
    public static function DNAME(string $target): DNAME
284
    {
285 10
        $rdata = new DNAME();
286 10
        $rdata->setTarget($target);
287
288 10
        return $rdata;
289
    }
290
291
    /**
292
     * @param float $lat
293
     * @param float $lon
294
     * @param float $alt
295
     * @param float $size
296
     * @param float $hp
297
     * @param float $vp
298
     *
299
     * @return LOC
300
     */
301 11
    public static function LOC(float $lat, float $lon, $alt = 0.0, $size = 1.0, $hp = 10000.0, $vp = 10.0): LOC
302
    {
303 11
        $loc = new LOC();
304 11
        $loc->setLatitude($lat);
305 11
        $loc->setLongitude($lon);
306 11
        $loc->setAltitude($alt);
307 11
        $loc->setSize($size);
308 11
        $loc->setHorizontalPrecision($hp);
309 11
        $loc->setVerticalPrecision($vp);
310
311 11
        return $loc;
312
    }
313
314
    /**
315
     * @param string $target
316
     *
317
     * @return PTR
318
     */
319 2
    public static function PTR(string $target): PTR
320
    {
321 2
        $ptr = new PTR();
322 2
        $ptr->setTarget($target);
323
324 2
        return $ptr;
325
    }
326
327
    /**
328
     * @param int    $flags
329
     * @param int    $algorithm
330
     * @param string $publicKey
331
     *
332
     * @return DNSKEY
333
     */
334 1
    public static function DNSKEY(int $flags, int $algorithm, string $publicKey): DNSKEY
335
    {
336 1
        $rdata = new DNSKEY();
337 1
        $rdata->setFlags($flags);
338 1
        $rdata->setAlgorithm($algorithm);
339 1
        $rdata->setPublicKey($publicKey);
340
341 1
        return $rdata;
342
    }
343
344
    /**
345
     * @param int    $keyTag
346
     * @param int    $algorithm
347
     * @param string $digest
348
     * @param int    $digestType
349
     *
350
     * @return DS
351
     */
352 1
    public static function DS(int $keyTag, int $algorithm, string $digest, int $digestType = DS::DIGEST_SHA1): DS
353
    {
354 1
        $rdata = new DS();
355 1
        $rdata->setKeyTag($keyTag);
356 1
        $rdata->setAlgorithm($algorithm);
357 1
        $rdata->setDigest($digest);
358 1
        $rdata->setDigestType($digestType);
359
360 1
        return $rdata;
361
    }
362
363
    /**
364
     * @param string $nextDomainName
365
     * @param array  $types
366
     *
367
     * @return NSEC
368
     */
369 1
    public static function NSEC(string $nextDomainName, array $types): NSEC
370
    {
371 1
        $rdata = new NSEC();
372 1
        $rdata->setNextDomainName($nextDomainName);
373 1
        array_map([$rdata, 'addType'], $types);
374
375 1
        return $rdata;
376
    }
377
378
    /**
379
     * @param string    $typeCovered
380
     * @param int       $algorithm
381
     * @param int       $labels
382
     * @param int       $originalTtl
383
     * @param \DateTime $signatureExpiration
384
     * @param \DateTime $signatureInception
385
     * @param int       $keyTag
386
     * @param string    $signersName
387
     * @param string    $signature
388
     *
389
     * @return RRSIG
390
     */
391 11
    public static function RRSIG(string $typeCovered, int $algorithm, int $labels, int $originalTtl,
392
                                    \DateTime $signatureExpiration, \DateTime $signatureInception, int $keyTag,
393
                                    string $signersName, string $signature): RRSIG
394
    {
395 11
        $rrsig = new RRSIG();
396 11
        $rrsig->setTypeCovered($typeCovered);
397 11
        $rrsig->setAlgorithm($algorithm);
398 11
        $rrsig->setLabels($labels);
399 11
        $rrsig->setOriginalTtl($originalTtl);
400 11
        $rrsig->setSignatureExpiration($signatureExpiration);
401 11
        $rrsig->setSignatureInception($signatureInception);
402 11
        $rrsig->setKeyTag($keyTag);
403 11
        $rrsig->setSignersName($signersName);
404 11
        $rrsig->setSignature($signature);
405
406 11
        return $rrsig;
407
    }
408
409
    /**
410
     * @param int    $priority
411
     * @param int    $weight
412
     * @param int    $port
413
     * @param string $target
414
     *
415
     * @return SRV
416
     */
417 11
    public static function SRV(int $priority, int $weight, int $port, string $target): SRV
418
    {
419 11
        $rdata = new SRV();
420 11
        $rdata->setPriority($priority);
421 11
        $rdata->setWeight($weight);
422 11
        $rdata->setPort($port);
423 11
        $rdata->setTarget($target);
424
425 11
        return $rdata;
426
    }
427
428
    /**
429
     * @param IPBlock[] $includedRanges
430
     * @param IPBlock[] $excludedRanges
431
     *
432
     * @return APL
433
     */
434 2
    public static function APL(array $includedRanges = [], array $excludedRanges = []): APL
435
    {
436 2
        $rdata = new APL();
437
438 2
        foreach ($includedRanges as $ipBlock) {
439 2
            $rdata->addAddressRange($ipBlock, true);
440
        }
441
442 2
        foreach ($excludedRanges as $ipBlock) {
443 2
            $rdata->addAddressRange($ipBlock, false);
444
        }
445
446 2
        return $rdata;
447
    }
448
449
    /**
450
     * @param int    $flag
451
     * @param string $tag
452
     * @param string $value
453
     *
454
     * @return CAA
455
     */
456 1
    public static function CAA(int $flag, string $tag, string $value): CAA
457
    {
458 1
        $rdata = new CAA();
459 1
        $rdata->setFlag($flag);
460 1
        $rdata->setTag($tag);
461 1
        $rdata->setValue($value);
462
463 1
        return $rdata;
464
    }
465
466
    /**
467
     * @param int    $subType
468
     * @param string $hostname
469
     *
470
     * @return AFSDB
471
     */
472 1
    public static function AFSDB(int $subType, string $hostname): AFSDB
473
    {
474 1
        $afsdb = new AFSDB();
475 1
        $afsdb->setSubType($subType);
476 1
        $afsdb->setHostname($hostname);
477
478 1
        return $afsdb;
479
    }
480
481
    /**
482
     * @param int    $flags
483
     * @param int    $algorithm
484
     * @param string $publicKey
485
     *
486
     * @return CDNSKEY
487
     */
488 1
    public static function CDNSKEY(int $flags, int $algorithm, string $publicKey): CDNSKEY
489
    {
490 1
        $cdnskey = new CDNSKEY();
491 1
        $cdnskey->setFlags($flags);
492 1
        $cdnskey->setAlgorithm($algorithm);
493 1
        $cdnskey->setPublicKey($publicKey);
494
495 1
        return $cdnskey;
496
    }
497
498
    /**
499
     * @param int    $keyTag
500
     * @param int    $algorithm
501
     * @param string $digest
502
     * @param int    $digestType
503
     *
504
     * @return CDS
505
     */
506 1
    public static function CDS(int $keyTag, int $algorithm, string $digest, int $digestType = DS::DIGEST_SHA1): CDS
507
    {
508 1
        $cds = new CDS();
509 1
        $cds->setKeyTag($keyTag);
510 1
        $cds->setAlgorithm($algorithm);
511 1
        $cds->setDigest($digest);
512 1
        $cds->setDigestType($digestType);
513
514 1
        return $cds;
515
    }
516
517
    /**
518
     * @param int|string $certificateType
519
     * @param int        $keyTag
520
     * @param int        $algorithm
521
     * @param string     $certificate
522
     *
523
     * @return CERT
524
     */
525 1
    public static function CERT($certificateType, int $keyTag, int $algorithm, string $certificate): CERT
526
    {
527 1
        $cert = new CERT();
528 1
        $cert->setCertificateType($certificateType);
529 1
        $cert->setKeyTag($keyTag);
530 1
        $cert->setAlgorithm($algorithm);
531 1
        $cert->setCertificate($certificate);
532
533 1
        return $cert;
534
    }
535
536 1
    public static function CSYNC(int $soaSerial, int $flags, array $types): CSYNC
537
    {
538 1
        $csync = new CSYNC();
539 1
        $csync->setSoaSerial($soaSerial);
540 1
        $csync->setFlags($flags);
541 1
        array_map([$csync, 'addType'], $types);
542
543 1
        return $csync;
544
    }
545
546
    /**
547
     * @param string|null $digest         Set to &null if the $identifier and $fqdn are known
548
     * @param int         $identifierType 16-bit integer
549
     * @param string|null $identifier     This is ignored if $digest is not &null
550
     * @param string|null $fqdn           This is ignored if $digest is not &null
551
     *
552
     * @return DHCID
553
     */
554 4
    public static function DHCID(?string $digest, int $identifierType, ?string $identifier = null, ?string $fqdn = null): DHCID
555
    {
556 4
        $dhcid = new DHCID();
557 4
        if (null !== $digest) {
558 3
            $dhcid->setIdentifierType($identifierType);
559 3
            $dhcid->setDigest($digest);
560
561 3
            return $dhcid;
562
        }
563
564 4
        if (null === $identifier || null === $fqdn) {
565 1
            throw new \InvalidArgumentException('Identifier and FQDN cannot be null if digest is null.');
566
        }
567
568 3
        $dhcid->setIdentifier($identifierType, $identifier);
569 3
        $dhcid->setFqdn($fqdn);
570
571 3
        return $dhcid;
572
    }
573
574
    /**
575
     * @param int    $keyTag
576
     * @param int    $algorithm
577
     * @param string $digest
578
     * @param int    $digestType
579
     *
580
     * @return DLV
581
     */
582 1
    public static function DLV(int $keyTag, int $algorithm, string $digest, int $digestType = DS::DIGEST_SHA1): DLV
583
    {
584 1
        $rdata = new DLV();
585 1
        $rdata->setKeyTag($keyTag);
586 1
        $rdata->setAlgorithm($algorithm);
587 1
        $rdata->setDigest($digest);
588 1
        $rdata->setDigestType($digestType);
589
590 1
        return $rdata;
591
    }
592
593
    /**
594
     * @param int      $publicKeyAlgorithm
595
     * @param string   $hostIdentityTag
596
     * @param string   $publicKey
597
     * @param string[] $rendezvousServers
598
     *
599
     * @return HIP
600
     */
601 1
    public static function HIP(int $publicKeyAlgorithm, string $hostIdentityTag, string $publicKey, array $rendezvousServers): HIP
602
    {
603 1
        $hip = new HIP();
604 1
        $hip->setPublicKeyAlgorithm($publicKeyAlgorithm);
605 1
        $hip->setHostIdentityTag($hostIdentityTag);
606 1
        $hip->setPublicKey($publicKey);
607 1
        array_map([$hip, 'addRendezvousServer'], $rendezvousServers);
608
609 1
        return $hip;
610
    }
611
612
    /**
613
     * @param int         $precedence an 8-bit unsigned integer
614
     * @param string|null $gateway    either &null for no gateway, a fully qualified domain name, or an IPv4 or IPv6 address
615
     * @param int         $algorithm  either IPSECKEY::ALGORITHM_NONE, IPSECKEY::ALGORITHM_DSA, IPSECKEY::ALGORITHM_RSA, or IPSECKEY::ALGORITHM_ECDSA
616
     * @param string|null $publicKey  base64 encoded public key
617
     *
618
     * @return IPSECKEY
619
     */
620 6
    public static function IPSECKEY(int $precedence, ?string $gateway, int $algorithm = 0, ?string $publicKey = null): IPSECKEY
621
    {
622 6
        $ipseckey = new IPSECKEY();
623 6
        $ipseckey->setPrecedence($precedence);
624 6
        $ipseckey->setGateway($gateway);
625 6
        $ipseckey->setPublicKey($algorithm, $publicKey);
626
627 6
        return $ipseckey;
628
    }
629
630
    /**
631
     * @param int    $flags
632
     * @param int    $protocol
633
     * @param int    $algorithm
634
     * @param string $publicKey
635
     *
636
     * @return KEY
637
     */
638 1
    public static function KEY(int $flags, int $protocol, int $algorithm, string $publicKey): KEY
639
    {
640 1
        $key = new KEY();
641 1
        $key->setFlags($flags);
642 1
        $key->setProtocol($protocol);
643 1
        $key->setAlgorithm($algorithm);
644 1
        $key->setPublicKey($publicKey);
645
646 1
        return $key;
647
    }
648
649
    /**
650
     * @param int    $preference
651
     * @param string $exchanger
652
     *
653
     * @return KX
654
     */
655 1
    public static function KX(int $preference, string $exchanger): KX
656
    {
657 1
        $kx = new KX();
658 1
        $kx->setPreference($preference);
659 1
        $kx->setExchanger($exchanger);
660
661 1
        return $kx;
662
    }
663
664
    /**
665
     * @param int    $order
666
     * @param int    $preference
667
     * @param string $flags
668
     * @param string $services
669
     * @param string $regexp
670
     * @param string $replacement
671
     *
672
     * @return NAPTR
673
     */
674 4
    public static function NAPTR(int $order, int $preference, string $flags, string $services, string $regexp, string $replacement): NAPTR
675
    {
676 4
        $naptr = new NAPTR();
677 4
        $naptr->setOrder($order);
678 4
        $naptr->setPreference($preference);
679 4
        $naptr->setFlags($flags);
680 4
        $naptr->setServices($services);
681 4
        $naptr->setRegexp($regexp);
682 4
        $naptr->setReplacement($replacement);
683
684 4
        return $naptr;
685
    }
686
687
    /**
688
     * @param int    $hashAlgorithm
689
     * @param bool   $unsignedDelegationsCovered
690
     * @param int    $iterations
691
     * @param string $salt
692
     * @param string $nextHashedOwnerName
693
     * @param array  $types
694
     *
695
     * @return NSEC3
696
     */
697 1
    public static function NSEC3(int $hashAlgorithm, bool $unsignedDelegationsCovered, int $iterations, string $salt, string $nextHashedOwnerName, array $types): NSEC3
698
    {
699 1
        $nsec3 = new NSEC3();
700 1
        $nsec3->setHashAlgorithm($hashAlgorithm);
701 1
        $nsec3->setUnsignedDelegationsCovered($unsignedDelegationsCovered);
702 1
        $nsec3->setIterations($iterations);
703 1
        $nsec3->setSalt($salt);
704 1
        $nsec3->setNextHashedOwnerName($nextHashedOwnerName);
705 1
        array_map([$nsec3, 'addType'], $types);
706
707 1
        return $nsec3;
708
    }
709
710
    /**
711
     * @param int    $hashAlgorithm
712
     * @param int    $flags
713
     * @param int    $iterations
714
     * @param string $salt
715
     *
716
     * @return NSEC3PARAM
717
     */
718 2
    public static function NSEC3PARAM(int $hashAlgorithm, int $flags, int $iterations, string $salt): NSEC3PARAM
719
    {
720 2
        $nsec3param = new NSEC3PARAM();
721 2
        $nsec3param->setHashAlgorithm($hashAlgorithm);
722 2
        $nsec3param->setFlags($flags);
723 2
        $nsec3param->setIterations($iterations);
724 2
        $nsec3param->setSalt($salt);
725
726 2
        return $nsec3param;
727
    }
728
729 2
    public static function RP(string $mboxDomain, string $txtDomain): RP
730
    {
731 2
        $rp = new RP();
732 2
        $rp->setMailboxDomainName($mboxDomain);
733 2
        $rp->setTxtDomainName($txtDomain);
734
735 2
        return $rp;
736
    }
737
738
    /**
739
     * @param string    $typeCovered
740
     * @param int       $algorithm
741
     * @param int       $labels
742
     * @param int       $originalTtl
743
     * @param \DateTime $signatureExpiration
744
     * @param \DateTime $signatureInception
745
     * @param int       $keyTag
746
     * @param string    $signersName
747
     * @param string    $signature
748
     *
749
     * @return SIG
750
     */
751 1
    public static function SIG(string $typeCovered, int $algorithm, int $labels, int $originalTtl,
752
                                 \DateTime $signatureExpiration, \DateTime $signatureInception, int $keyTag,
753
                                 string $signersName, string $signature): SIG
754
    {
755 1
        $sig = new SIG();
756 1
        $sig->setTypeCovered($typeCovered);
757 1
        $sig->setAlgorithm($algorithm);
758 1
        $sig->setLabels($labels);
759 1
        $sig->setOriginalTtl($originalTtl);
760 1
        $sig->setSignatureExpiration($signatureExpiration);
761 1
        $sig->setSignatureInception($signatureInception);
762 1
        $sig->setKeyTag($keyTag);
763 1
        $sig->setSignersName($signersName);
764 1
        $sig->setSignature($signature);
765
766 1
        return $sig;
767
    }
768
769
    /**
770
     * @param int    $algorithm
771
     * @param int    $fpType
772
     * @param string $fingerprint
773
     *
774
     * @return SSHFP
775
     */
776 6
    public static function SSHFP(int $algorithm, int $fpType, string $fingerprint): SSHFP
777
    {
778 6
        $sshfp = new SSHFP();
779 6
        $sshfp->setAlgorithm($algorithm);
780 4
        $sshfp->setFingerprintType($fpType);
781 2
        $sshfp->setFingerprint($fingerprint);
782
783 1
        return $sshfp;
784
    }
785
786
    /**
787
     * @param int    $keyTag
788
     * @param int    $algorithm
789
     * @param string $digest
790
     * @param int    $digestType
791
     *
792
     * @return TA
793
     */
794 1
    public static function TA(int $keyTag, int $algorithm, string $digest, int $digestType = DS::DIGEST_SHA1): TA
795
    {
796 1
        $ta = new TA();
797 1
        $ta->setKeyTag($keyTag);
798 1
        $ta->setAlgorithm($algorithm);
799 1
        $ta->setDigest($digest);
800 1
        $ta->setDigestType($digestType);
801
802 1
        return $ta;
803
    }
804
805
    /**
806
     * @param string    $algorithm
807
     * @param \DateTime $inception
808
     * @param \DateTime $expiration
809
     * @param int       $mode
810
     * @param int       $error
811
     * @param string    $keyData    binary string
812
     * @param string    $otherData  binary string
813
     *
814
     * @return TKEY
815
     */
816 1
    public static function TKEY(string $algorithm, \DateTime $inception, \DateTime $expiration, int $mode, int $error, string $keyData, string $otherData = ''): TKEY
817
    {
818 1
        $tkey = new TKEY();
819 1
        $tkey->setAlgorithm($algorithm);
820 1
        $tkey->setInception($inception);
821 1
        $tkey->setExpiration($expiration);
822 1
        $tkey->setMode($mode);
823 1
        $tkey->setError($error);
824 1
        $tkey->setKeyData($keyData);
825 1
        $tkey->setOtherData($otherData);
826
827 1
        return $tkey;
828
    }
829
830
    /**
831
     * @param int    $certificateUsage
832
     * @param int    $selector
833
     * @param int    $matchingType
834
     * @param string $certificateAssociationData
835
     *
836
     * @return TLSA
837
     */
838 1
    public static function TLSA(int $certificateUsage, int $selector, int $matchingType, string $certificateAssociationData): TLSA
839
    {
840 1
        $tlsa = new TLSA();
841 1
        $tlsa->setCertificateUsage($certificateUsage);
842 1
        $tlsa->setSelector($selector);
843 1
        $tlsa->setMatchingType($matchingType);
844 1
        $tlsa->setCertificateAssociationData($certificateAssociationData);
845
846 1
        return $tlsa;
847
    }
848
849
    /**
850
     * @param string    $algorithmName
851
     * @param \DateTime $timeSigned
852
     * @param int       $fudge
853
     * @param string    $mac
854
     * @param int       $originalId
855
     * @param int       $error
856
     * @param string    $otherData
857
     *
858
     * @return TSIG
859
     */
860 1
    public static function TSIG(string $algorithmName, \DateTime $timeSigned, int $fudge, string $mac, int $originalId, int $error, string $otherData): TSIG
861
    {
862 1
        $tsig = new TSIG();
863 1
        $tsig->setAlgorithmName($algorithmName);
864 1
        $tsig->setTimeSigned($timeSigned);
865 1
        $tsig->setFudge($fudge);
866 1
        $tsig->setMac($mac);
867 1
        $tsig->setOriginalId($originalId);
868 1
        $tsig->setError($error);
869 1
        $tsig->setOtherData($otherData);
870
871 1
        return $tsig;
872
    }
873
874
    /**
875
     * @param int    $priority
876
     * @param int    $weight
877
     * @param string $target
878
     *
879
     * @return URI
880
     */
881 6
    public static function URI(int $priority, int $weight, string $target): URI
882
    {
883 6
        $uri = new URI();
884 6
        $uri->setPriority($priority);
885 4
        $uri->setWeight($weight);
886 2
        $uri->setTarget($target);
887
888 1
        return $uri;
889
    }
890
}
891