It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.
If you suppress an error, we recommend checking for the error condition explicitly:
// For example instead of@mkdir($dir);// Better useif(@mkdir($dir)===false){thrownew\RuntimeException('The directory '.$dir.' could not be created.');}
The trait Idable provides a method equalsId that in turn relies on the
method getId(). If this method does not exist on a class mixing in this
trait, the method will fail.
Adding the getId() as an abstract method to the trait will make sure it
is available.
Loading history...
46
}
47
48
/**
49
* Encode a domain name as a sequence of labels.
50
*
51
* @param string $name
52
*
53
* @return string
54
*/
55
26
public static function encodeName(string $name): string
56
{
57
26
if ('.' === $name) {
58
2
return chr(0);
59
}
60
61
24
$name = rtrim($name, '.').'.';
62
24
$res = '';
63
64
24
foreach (explode('.', $name) as $label) {
65
24
$res .= chr(strlen($label)).$label;
66
}
67
68
24
return $res;
69
}
70
71
/**
72
* @param string $string
73
* @param int $offset
74
*
75
* @return string
76
*/
77
14
public static function decodeName(string $string, int &$offset = 0): string
If you suppress an error, we recommend checking for the error condition explicitly: