Completed
Push — remove-yii-autoloader ( 560d61...5f8600 )
by Alexander
27:04 queued 23:12
created

Cookie   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 51
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 4 1
1
<?php
2
/**
3
 * @link http://www.yiiframework.com/
4
 * @copyright Copyright (c) 2008 Yii Software LLC
5
 * @license http://www.yiiframework.com/license/
6
 */
7
8
namespace yii\http;
9
10
/**
11
 * Cookie represents information related with a cookie, such as [[name]], [[value]], [[domain]], etc.
12
 *
13
 * For more details and usage information on Cookie, see the [guide article on handling cookies](guide:runtime-sessions-cookies).
14
 *
15
 * @author Qiang Xue <[email protected]>
16
 * @since 2.0
17
 */
18
class Cookie extends \yii\base\BaseObject
19
{
20
    /**
21
     * @var string name of the cookie
22
     */
23
    public $name;
24
    /**
25
     * @var string value of the cookie
26
     */
27
    public $value = '';
28
    /**
29
     * @var string domain of the cookie
30
     */
31
    public $domain = '';
32
    /**
33
     * @var int the timestamp at which the cookie expires. This is the server timestamp.
34
     * Defaults to 0, meaning "until the browser is closed".
35
     */
36
    public $expire = 0;
37
    /**
38
     * @var string the path on the server in which the cookie will be available on. The default is '/'.
39
     */
40
    public $path = '/';
41
    /**
42
     * @var bool whether cookie should be sent via secure connection
43
     */
44
    public $secure = false;
45
    /**
46
     * @var bool whether the cookie should be accessible only through the HTTP protocol.
47
     * By setting this property to true, the cookie will not be accessible by scripting languages,
48
     * such as JavaScript, which can effectively help to reduce identity theft through XSS attacks.
49
     */
50
    public $httpOnly = true;
51
52
53
    /**
54
     * Magic method to turn a cookie object into a string without having to explicitly access [[value]].
55
     *
56
     * ```php
57
     * if (isset($request->cookies['name'])) {
58
     *     $value = (string) $request->cookies['name'];
59
     * }
60
     * ```
61
     *
62
     * @return string The value of the cookie. If the value property is null, an empty string will be returned.
63
     */
64
    public function __toString()
65
    {
66
        return (string) $this->value;
67
    }
68
}
69