Completed
Push — master ( 1d1f79...85914a )
by Harald
06:13 queued 02:42
created

Cookies::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
  * osCommerce Online Merchant
4
  *
5
  * @copyright (c) 2016 osCommerce; https://www.oscommerce.com
6
  * @license GPL; https://www.oscommerce.com/gpllicense.txt
7
  */
8
9
namespace OSC\OM;
10
11
use OSC\OM\OSCOM;
12
13
class Cookies
14
{
15
    protected $domain;
16
    protected $path;
17
18
    public function __construct()
19
    {
20
        $this->domain = OSCOM::getConfig('http_cookie_domain');
21
        $this->path = OSCOM::getConfig('http_cookie_path');
22
    }
23
24
    public function set($name, $value = '', $expire = 0, $path = null, $domain = null, $secure = true, $httponly = true)
25
    {
26
        return setcookie($name, $value, $expire, isset($path) ? $path : $this->path, isset($domain) ? $domain : $this->domain, $secure, $httponly);
27
    }
28
29
    public function del($name, $path = null, $domain = null, $secure = true, $httponly = true)
30
    {
31
        if ($this->set($name, '', time() - 3600, $path, $domain, $secure, $httponly)) {
32
            if (isset($_COOKIE[$name])) {
33
                unset($_COOKIE[$name]);
34
            }
35
36
            return true;
37
        }
38
39
        return false;
40
    }
41
42
    public function getDomain()
43
    {
44
        return $this->domain;
45
    }
46
47
    public function getPath()
48
    {
49
        return $this->path;
50
    }
51
52
    public function setDomain($domain)
53
    {
54
        $this->domain = $domain;
55
    }
56
57
    public function setPath($path)
58
    {
59
        $this->path = $path;
60
    }
61
}
62