21
21
use Pdp \Exception \InvalidLabel ;
22
22
use Pdp \Exception \InvalidLabelKey ;
23
23
use TypeError ;
24
- use function array_count_values ;
25
- use function array_keys ;
26
- use function array_reverse ;
27
- use function array_slice ;
28
- use function array_unshift ;
29
- use function count ;
30
- use function explode ;
31
- use function gettype ;
32
- use function implode ;
33
- use function in_array ;
34
- use function is_scalar ;
35
- use function ksort ;
36
- use function method_exists ;
37
- use function preg_match ;
38
- use function sprintf ;
39
- use function strlen ;
40
- use function strpos ;
41
- use function substr ;
42
24
43
25
/**
44
26
* Domain Value Object.
@@ -96,8 +78,8 @@ public static function __set_state(array $properties): self
96
78
/**
97
79
* New instance.
98
80
*
99
- * @param PublicSuffix $publicSuffix
100
- * @param null|mixed $domain
81
+ * @param null|mixed $domain
82
+ * @param null|PublicSuffix $publicSuffix
101
83
*/
102
84
public function __construct ($ domain = null , PublicSuffix $ publicSuffix = null )
103
85
{
@@ -113,7 +95,11 @@ public function __construct($domain = null, PublicSuffix $publicSuffix = null)
113
95
/**
114
96
* Sets the public suffix domain part.
115
97
*
98
+ * @param PublicSuffix $publicSuffix
99
+ *
116
100
* @throws CouldNotResolvePublicSuffix If the public suffic can not be attached to the domain
101
+ *
102
+ * @return PublicSuffix
117
103
*/
118
104
private function setPublicSuffix (PublicSuffix $ publicSuffix ): PublicSuffix
119
105
{
@@ -140,6 +126,10 @@ private function setPublicSuffix(PublicSuffix $publicSuffix): PublicSuffix
140
126
141
127
/**
142
128
* Normalize the domain name encoding content.
129
+ *
130
+ * @param PublicSuffix $subject
131
+ *
132
+ * @return PublicSuffix
143
133
*/
144
134
private function normalize (PublicSuffix $ subject ): PublicSuffix
145
135
{
@@ -297,7 +287,7 @@ public function keys(string $label): array
297
287
*
298
288
* This method returns null if the registrable domain is equal to the public suffix.
299
289
*
300
- * @return string|null
290
+ * @return string|null registrable domain
301
291
*/
302
292
public function getRegistrableDomain ()
303
293
{
@@ -312,7 +302,7 @@ public function getRegistrableDomain()
312
302
* This method returns null if the registrable domain is null
313
303
* This method returns null if the registrable domain is equal to the public suffix
314
304
*
315
- * @return string|null
305
+ * @return string|null registrable domain
316
306
*/
317
307
public function getSubDomain ()
318
308
{
@@ -335,6 +325,8 @@ public function getPublicSuffix()
335
325
* A domain is resolvable if:
336
326
* - it contains at least 2 labels
337
327
* - it is not a absolute domain (end with a '.' character)
328
+ *
329
+ * @return bool
338
330
*/
339
331
public function isResolvable (): bool
340
332
{
@@ -343,6 +335,8 @@ public function isResolvable(): bool
343
335
344
336
/**
345
337
* Tells whether the public suffix has a matching rule in a Public Suffix List.
338
+ *
339
+ * @return bool
346
340
*/
347
341
public function isKnown (): bool
348
342
{
@@ -351,6 +345,8 @@ public function isKnown(): bool
351
345
352
346
/**
353
347
* Tells whether the public suffix has a matching rule in a Public Suffix List ICANN Section.
348
+ *
349
+ * @return bool
354
350
*/
355
351
public function isICANN (): bool
356
352
{
@@ -359,6 +355,8 @@ public function isICANN(): bool
359
355
360
356
/**
361
357
* Tells whether the public suffix has a matching rule in a Public Suffix List Private Section.
358
+ *
359
+ * @return bool
362
360
*/
363
361
public function isPrivate (): bool
364
362
{
@@ -404,6 +402,10 @@ public function toUnicode()
404
402
*
405
403
* This method MUST retain the state of the current instance, and return
406
404
* an instance that contains the modified Public Suffix Information.
405
+ *
406
+ * @param mixed $publicSuffix
407
+ *
408
+ * @return self
407
409
*/
408
410
public function resolve ($ publicSuffix ): self
409
411
{
@@ -427,6 +429,10 @@ public function resolve($publicSuffix): self
427
429
*
428
430
* If the domain already has a public suffix it will be replaced by the new value
429
431
* otherwise the public suffix content is added to or remove from the current domain.
432
+ *
433
+ * @param mixed $publicSuffix
434
+ *
435
+ * @return self
430
436
*/
431
437
public function withPublicSuffix ($ publicSuffix ): self
432
438
{
@@ -447,14 +453,18 @@ public function withPublicSuffix($publicSuffix): self
447
453
return new self ($ domain .'. ' .$ publicSuffix ->getContent (), $ publicSuffix );
448
454
}
449
455
456
+
450
457
/**
451
458
* Returns an instance with the specified sub domain added.
452
459
*
453
460
* This method MUST retain the state of the current instance, and return
454
461
* an instance that contains the new sub domain
455
462
*
463
+ * @param mixed $subDomain the subdomain to add
456
464
*
457
465
* @throws CouldNotResolveSubDomain If the Sub domain can not be added to the current Domain
466
+ *
467
+ * @return self
458
468
*/
459
469
public function withSubDomain ($ subDomain ): self
460
470
{
@@ -477,6 +487,8 @@ public function withSubDomain($subDomain): self
477
487
/**
478
488
* Filter a subdomain to update the domain part.
479
489
*
490
+ * @param mixed $domain
491
+ *
480
492
* @throws TypeError if the domain can not be converted
481
493
*
482
494
* @return string|null
@@ -511,6 +523,10 @@ private function normalizeContent($domain)
511
523
* Prepends a label to the domain.
512
524
*
513
525
* @see ::withLabel
526
+ *
527
+ * @param mixed $label
528
+ *
529
+ * @return self
514
530
*/
515
531
public function prepend ($ label ): self
516
532
{
@@ -521,6 +537,10 @@ public function prepend($label): self
521
537
* Appends a label to the domain.
522
538
*
523
539
* @see ::withLabel
540
+ *
541
+ * @param mixed $label
542
+ *
543
+ * @return self
524
544
*/
525
545
public function append ($ label ): self
526
546
{
@@ -536,8 +556,13 @@ public function append($label): self
536
556
* If $key is non-negative, the added label will be the label at $key position from the start.
537
557
* If $key is negative, the added label will be the label at $key position from the end.
538
558
*
559
+ * @param int $key
560
+ * @param mixed $label
561
+ *
539
562
* @throws InvalidLabelKey If the key is out of bounds
540
563
* @throws InvalidLabel If the label is converted to the NULL value
564
+ *
565
+ * @return self
541
566
*/
542
567
public function withLabel (int $ key , $ label ): self
543
568
{
@@ -579,9 +604,12 @@ public function withLabel(int $key, $label): self
579
604
* If $key is non-negative, the removed label will be the label at $key position from the start.
580
605
* If $key is negative, the removed label will be the label at $key position from the end.
581
606
*
607
+ * @param int $key
582
608
* @param int ...$keys remaining keys to remove
583
609
*
584
610
* @throws InvalidLabelKey If the key is out of bounds
611
+ *
612
+ * @return self
585
613
*/
586
614
public function withoutLabel (int $ key , int ...$ keys ): self
587
615
{
0 commit comments