1 | <?php |
||
32 | 1 | final class CookieSettings |
|
33 | { |
||
34 | /** |
||
35 | * Implement nette smart magic |
||
36 | */ |
||
37 | 1 | use Nette\SmartObject; |
|
38 | |||
39 | /** |
||
40 | * @var string |
||
41 | */ |
||
42 | private $name; |
||
43 | |||
44 | /** |
||
45 | * @var string|NULL |
||
46 | */ |
||
47 | private $domain; |
||
48 | |||
49 | /** |
||
50 | * @var string |
||
51 | */ |
||
52 | private $expire; |
||
53 | |||
54 | /** |
||
55 | * @var string |
||
56 | */ |
||
57 | private $path; |
||
58 | |||
59 | /** |
||
60 | * @var bool |
||
61 | */ |
||
62 | private $secure; |
||
63 | |||
64 | /** |
||
65 | * @var bool |
||
66 | */ |
||
67 | private $httpOnly; |
||
68 | |||
69 | /** |
||
70 | * @param string $name The name of the cookie |
||
71 | * @param string $expireAfter The time the cookie expires |
||
72 | * @param string $path The path on the server in which the cookie will be available on |
||
73 | * @param string $domain The domain that the cookie is available to |
||
74 | * @param bool $secure Whether the cookie should only be transmitted over a secure HTTPS connection from the client |
||
75 | * @param bool $httpOnly Whether the cookie will be made accessible only through the HTTP protocol |
||
76 | * |
||
77 | * @throws Exceptions\InvalidArgumentException |
||
78 | */ |
||
79 | public function __construct(string $name, string $domain = NULL, string $expireAfter = NULL, string $path = '/', bool $secure = FALSE, bool $httpOnly = TRUE) |
||
103 | |||
104 | /** |
||
105 | * Gets the name of the cookie |
||
106 | * |
||
107 | * @return string |
||
108 | */ |
||
109 | public function getName() : string |
||
113 | |||
114 | /** |
||
115 | * Gets the domain that the cookie is available to |
||
116 | * |
||
117 | * @return string|NULL |
||
118 | */ |
||
119 | public function getDomain() |
||
123 | |||
124 | /** |
||
125 | * Gets the time the cookie expires |
||
126 | * |
||
127 | * @return int |
||
128 | */ |
||
129 | public function getExpiresTime() : int |
||
133 | |||
134 | /** |
||
135 | * Gets the path on the server in which the cookie will be available on |
||
136 | * |
||
137 | * @return string |
||
138 | */ |
||
139 | public function getPath() : string |
||
143 | |||
144 | /** |
||
145 | * Checks whether the cookie should only be transmitted over a secure HTTPS connection from the client |
||
146 | * |
||
147 | * @return bool |
||
148 | */ |
||
149 | public function isSecure() : bool |
||
153 | |||
154 | /** |
||
155 | * Checks whether the cookie will be made accessible only through the HTTP protocol |
||
156 | * |
||
157 | * @return bool |
||
158 | */ |
||
159 | public function isHttpOnly() : bool |
||
163 | } |
||
164 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.