Session::destroy()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 * This file is part of product_management
4
 * User: Sinan TURGUT <[email protected]>
5
 * Date: 24.06.2019
6
 * php version 7.2
7
 *
8
 * @category Assessment
9
 * @package  ProductManagement
10
 * @author   Sinan TURGUT <[email protected]>
11
 * @license  See LICENSE file
12
 * @link     https://dev.sinanturgut.com.tr
13
 */
14
namespace App\Utility;
15
16
/**
17
 * Class Session
18
 * @package App\Utility
19
 */
20
class Session
21
{
22
23
    /**
24
     * @param $key
25
     * @return bool
26
     */
27
    public static function delete($key)
28
    {
29
        if (self::exists($key)) {
30
            unset($_SESSION[$key]);
31
            return true;
32
        }
33
        return false;
34
    }
35
36
    /**
37
     *
38
     */
39
    public static function destroy()
40
    {
41
        session_destroy();
42
    }
43
44
    /**
45
     * @param $key
46
     * @return bool
47
     */
48
    public static function exists($key)
49
    {
50
        return(isset($_SESSION[$key]));
51
    }
52
53
    /**
54
     * @param $key
55
     * @return mixed
56
     */
57
    public static function get($key)
58
    {
59
        if (self::exists($key)) {
60
            return($_SESSION[$key]);
61
        }
62
    }
63
64
    /**
65
     *
66
     */
67
    public static function init()
68
    {
69
70
        if (session_id() == "") {
71
            session_start();
72
        }
73
    }
74
75
    /**
76
     * @param $key
77
     * @param $value
78
     * @return mixed
79
     */
80
    public static function put($key, $value)
81
    {
82
        return($_SESSION[$key] = $value);
83
    }
84
}
85
86