1111 */
1212namespace Hyperf \HttpMessage \Cookie ;
1313
14+ use DateTimeInterface ;
15+ use InvalidArgumentException ;
1416use Stringable ;
1517
1618class Cookie implements Stringable
@@ -30,15 +32,15 @@ class Cookie implements Stringable
3032 /**
3133 * @param string $name The name of the cookie
3234 * @param string $value The value of the cookie
33- * @param \ DateTimeInterface|int|string $expire The time the cookie expires
35+ * @param DateTimeInterface|int|string $expire The time the cookie expires
3436 * @param string $path The path on the server in which the cookie will be available on
3537 * @param string $domain The domain that the cookie is available to
3638 * @param bool $secure Whether the cookie should only be transmitted over a secure HTTPS connection from the client
3739 * @param bool $httpOnly Whether the cookie will be made accessible only through the HTTP protocol
3840 * @param bool $raw Whether the cookie value should be sent with no url encoding
3941 * @param null|string $sameSite Whether the cookie will be available for cross-site requests
4042 *
41- * @throws \ InvalidArgumentException
43+ * @throws InvalidArgumentException
4244 */
4345 public function __construct (
4446 protected string $ name ,
@@ -53,21 +55,21 @@ public function __construct(
5355 ) {
5456 // from PHP source code
5557 if (preg_match ("/[=,; \t\r\n\013\014]/ " , $ name )) {
56- throw new \ InvalidArgumentException (sprintf ('The cookie name "%s" contains invalid characters. ' , $ name ));
58+ throw new InvalidArgumentException (sprintf ('The cookie name "%s" contains invalid characters. ' , $ name ));
5759 }
5860
5961 if (empty ($ name )) {
60- throw new \ InvalidArgumentException ('The cookie name cannot be empty. ' );
62+ throw new InvalidArgumentException ('The cookie name cannot be empty. ' );
6163 }
6264
6365 // convert expiration time to a Unix timestamp
64- if ($ expire instanceof \ DateTimeInterface) {
66+ if ($ expire instanceof DateTimeInterface) {
6567 $ expire = $ expire ->format ('U ' );
6668 } elseif (! is_numeric ($ expire )) {
6769 $ expire = strtotime ($ expire );
6870
6971 if ($ expire === false ) {
70- throw new \ InvalidArgumentException ('The cookie expiration time is not valid. ' );
72+ throw new InvalidArgumentException ('The cookie expiration time is not valid. ' );
7173 }
7274 }
7375
@@ -79,7 +81,7 @@ public function __construct(
7981 }
8082
8183 if (! in_array ($ sameSite , [self ::SAMESITE_LAX , self ::SAMESITE_STRICT , self ::SAMESITE_NONE , null ], true )) {
82- throw new \ InvalidArgumentException ('The "sameSite" parameter value is not valid. ' );
84+ throw new InvalidArgumentException ('The "sameSite" parameter value is not valid. ' );
8385 }
8486
8587 $ this ->sameSite = $ sameSite ;
0 commit comments