Passed
Push — master ( c0a3a7...3b84a4 )
by Jeroen
58:51
created

ElggCookie::__get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 0
cts 3
cp 0
crap 6
1
<?php
2
/**
3
 * A simple object model for an HTTP cookie
4
 *
5
 * @package    Elgg.Core
6
 * @subpackage Http
7
 * @see        elgg_set_cookie()
8
 * @see        http://php.net/manual/en/function.setcookie.php
9
 * @see        http://php.net/manual/en/function.session-set-cookie-params.php
10
 * @since      1.9.0
11
 *
12
 * @property-read string $name Name of the cookie
13
 */
14
class ElggCookie {
15
	/** @var string */
16
	private $name;
17
	
18
	/** @var string */
19
	public $value = "";
20
	
21
	/** @var int */
22
	public $expire = 0;
23
	
24
	/** @var string */
25
	public $path = "/";
26
	
27
	/** @var string */
28
	public $domain = "";
29
	
30
	/** @var bool */
31
	public $secure = false;
32
	
33
	/** @var bool */
34
	public $httpOnly = false;
35
	
36
	/**
37
	 * Constructor
38
	 *
39
	 * @param string $name The name of the cookie.
40
	 */
41 7
	public function __construct($name) {
42 7
		$this->name = $name;
1 ignored issue
show
Bug introduced by Cash Costello
The property name is declared read-only in ElggCookie.
Loading history...
43 7
	}
44
45
	/**
46
	 * Get an attribute
47
	 *
48
	 * @param string $name Attribute name
49
	 * @return mixed
50
	 */
51
	public function __get($name) {
52
		// allow reading the private name attribute
53
		if ($name === 'name') {
54
			return $this->name;
55
		}
56
	}
57
58
	/**
59
	 * Set the time the cookie expires
60
	 *
61
	 * Example: $cookie->setExpiresTime("+30 days");
62
	 *
63
	 * @param string $time A time string appropriate for strtotime()
64
	 * @return void
65
	 */
66
	public function setExpiresTime($time) {
67
		$this->expire = strtotime($time);
68
	}
69
}
70