@@ -102,7 +102,7 @@ public function __construct(array $rules)
102
102
*/
103
103
public function getPublicSuffix (string $ domain = null , string $ section = self ::ALL_DOMAINS ): PublicSuffix
104
104
{
105
- if (!$ this ->isMatchable ($ domain )) {
105
+ if (null === $ domain || !$ this ->isMatchable ($ domain )) {
106
106
throw new Exception (sprintf ('The submitted domain `%s` is invalid or malformed ' , $ domain ));
107
107
}
108
108
$ this ->validateSection ($ section );
@@ -121,7 +121,7 @@ public function getPublicSuffix(string $domain = null, string $section = self::A
121
121
public function resolve (string $ domain = null , string $ section = self ::ALL_DOMAINS ): Domain
122
122
{
123
123
$ this ->validateSection ($ section );
124
- if (!$ this ->isMatchable ($ domain )) {
124
+ if (null === $ domain || !$ this ->isMatchable ($ domain )) {
125
125
return new Domain ();
126
126
}
127
127
@@ -135,14 +135,13 @@ public function resolve(string $domain = null, string $section = self::ALL_DOMAI
135
135
/**
136
136
* Tells whether the given domain can be resolved.
137
137
*
138
- * @param string|null $domain
138
+ * @param string $domain
139
139
*
140
140
* @return bool
141
141
*/
142
142
private function isMatchable ($ domain ): bool
143
143
{
144
- return null !== $ domain
145
- && strpos ($ domain , '. ' ) > 0
144
+ return strpos ($ domain , '. ' ) > 0
146
145
&& strlen ($ domain ) === strcspn ($ domain , '][ ' )
147
146
&& !filter_var ($ domain , FILTER_VALIDATE_IP );
148
147
}
0 commit comments