@@ -35,12 +35,13 @@ public function __construct(
3535 $ this ->secure = $ secure ;
3636 $ this ->httpOnly = $ httpOnly ;
3737 }
38-
38+
3939 /**
4040 * Set cookie allowed path
4141 * @param string $path URI Path
42+ * @return self
4243 */
43- public function setPath (string $ path )
44+ public function setPath (string $ path ): self
4445 {
4546 $ this ->path = $ path ;
4647 return $ this ;
@@ -49,18 +50,20 @@ public function setPath(string $path)
4950 /**
5051 * Set cookie allowed domain
5152 * @param string $domain URI Path
53+ * @return self
5254 */
53- public function setDomain (string $ domain )
55+ public function setDomain (string $ domain ): self
5456 {
5557 $ this ->domain = $ domain ;
5658 return $ this ;
5759 }
5860
5961 /**
6062 * Set cookie secure flag (HTTPS only: true)
61- * @param string $secure URI Path
63+ * @param bool $secure URI Path true/false
64+ * @return self
6265 */
63- public function setSecure (bool $ secure )
66+ public function setSecure (bool $ secure ): self
6467 {
6568 $ this ->secure = $ secure ;
6669 return $ this ;
@@ -70,19 +73,21 @@ public function setSecure(bool $secure)
7073 * Set cookie http only flag. Cookie won't be accessible by scripting languages, such as JavaScript if true.
7174 * Can effectively help to reduce identity theft through XSS attacks, Not supported in all browsers tho
7275 * @param bool $httpOnly enable http only flag
76+ * @return self
7377 */
74- public function sethttpOnly (bool $ httpOnly )
78+ public function sethttpOnly (bool $ httpOnly ): self
7579 {
7680 $ this ->httpOnly = $ httpOnly ;
7781 return $ this ;
7882 }
7983
8084
8185 /**
82- * Set same site (Requires PHP version >= 7.3.0)
86+ * Set same site
8387 * @param string $samesite
88+ * @return self
8489 */
85- public function setSameSite (string $ samesite )
90+ public function setSameSite (string $ samesite ): self
8691 {
8792 $ samesite = ucfirst (strtolower ($ samesite ));
8893 if ($ samesite !== "None " && $ samesite !== "Lax " && $ samesite !== "Strict " ) {
@@ -97,6 +102,7 @@ public function setSameSite(string $samesite)
97102 * @param string $name
98103 * @param mixed $value
99104 * @param int $expires
105+ * @return void
100106 */
101107 public function set (string $ name , string $ value , int $ expires , bool $ force = false ): void
102108 {
@@ -113,11 +119,11 @@ public function set(string $name, string $value, int $expires, bool $force = fal
113119 /**
114120 * Check is cookie exists
115121 * @param string $name
116- * @return boolean
122+ * @return bool
117123 */
118124 public function has (string $ name ): bool
119125 {
120- return (bool )( isset ($ _COOKIE [$ name ]));
126+ return (isset ($ _COOKIE [$ name ]));
121127 }
122128
123129 /**
@@ -147,11 +153,11 @@ public function delete(string $name): void
147153 /**
148154 * Check if cookies settings in this instance has great enough security to save e.g. CSRF token.
149155 * Can not be read or set in: frontend, cross domain or in http (only https)
150- * @return boolean
156+ * @return bool
151157 */
152158 public function isSecure (): bool
153159 {
154- return (bool )( $ this ->samesite === "Strict " && $ this ->secure && $ this ->httpOnly );
160+ return ($ this ->samesite === "Strict " && $ this ->secure && $ this ->httpOnly );
155161 }
156162
157163 /**
0 commit comments