1 | <?php |
||
31 | 1 | final class CookieSettings |
|
32 | { |
||
33 | /** |
||
34 | * Implement nette smart magic |
||
35 | */ |
||
36 | 1 | use Nette\SmartObject; |
|
37 | |||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | private $name; |
||
42 | |||
43 | /** |
||
44 | * @var string|NULL |
||
45 | */ |
||
46 | private $domain; |
||
47 | |||
48 | /** |
||
49 | * @var string |
||
50 | */ |
||
51 | private $expire; |
||
52 | |||
53 | /** |
||
54 | * @var string |
||
55 | */ |
||
56 | private $path; |
||
57 | |||
58 | /** |
||
59 | * @var bool |
||
60 | */ |
||
61 | private $secure; |
||
62 | |||
63 | /** |
||
64 | * @var bool |
||
65 | */ |
||
66 | private $httpOnly; |
||
67 | |||
68 | /** |
||
69 | * @param string $name The name of the cookie |
||
70 | * @param string $expireAfter The time the cookie expires |
||
71 | * @param string $path The path on the server in which the cookie will be available on |
||
72 | * @param string $domain The domain that the cookie is available to |
||
73 | * @param bool $secure Whether the cookie should only be transmitted over a secure HTTPS connection from the client |
||
74 | * @param bool $httpOnly Whether the cookie will be made accessible only through the HTTP protocol |
||
75 | * |
||
76 | * @throws Exceptions\InvalidArgumentException |
||
77 | */ |
||
78 | public function __construct(string $name, ?string $domain = null, ?string $expireAfter = null, string $path = '/', bool $secure = false, bool $httpOnly = true) |
||
102 | |||
103 | /** |
||
104 | * Gets the name of the cookie |
||
105 | * |
||
106 | * @return string |
||
107 | */ |
||
108 | public function getName() : string |
||
112 | |||
113 | /** |
||
114 | * Gets the domain that the cookie is available to |
||
115 | * |
||
116 | * @return string|NULL |
||
117 | */ |
||
118 | public function getDomain() : ?string |
||
122 | |||
123 | /** |
||
124 | * Gets the time the cookie expires |
||
125 | * |
||
126 | * @return int |
||
127 | */ |
||
128 | public function getExpiresTime() : int |
||
132 | |||
133 | /** |
||
134 | * Gets the path on the server in which the cookie will be available on |
||
135 | * |
||
136 | * @return string |
||
137 | */ |
||
138 | public function getPath() : string |
||
142 | |||
143 | /** |
||
144 | * Checks whether the cookie should only be transmitted over a secure HTTPS connection from the client |
||
145 | * |
||
146 | * @return bool |
||
147 | */ |
||
148 | public function isSecure() : bool |
||
152 | |||
153 | /** |
||
154 | * Checks whether the cookie will be made accessible only through the HTTP protocol |
||
155 | * |
||
156 | * @return bool |
||
157 | */ |
||
158 | public function isHttpOnly() : bool |
||
162 | } |
||
163 |
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.