/var/www/html_uk/wp-content/plugins/automatewoo/includes/Temporary_Data.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
// phpcs:ignoreFile

namespace AutomateWoo;

/**
 * @class Temporary_Data
 * @since 2.9
 */
class Temporary_Data {

    
/** @var array  */
    
static $data = [];


    
/**
     * @param string $type
     * @param $key
     * @param mixed $value
     */
    
static function set$type$key$value ) {
        
self::setup_type$type );
        
self::$data$type ][ (string) $key ] = $value;
    }


    
/**
     * @param $type
     * @param $key
     */
    
static function delete$type$key ) {
        
self::setup_type$type );
        unset( 
self::$data$type ][ (string) $key ] );
    }


    
/**
     * @param string $type
     * @param $key
     * @return bool
     */
    
static function exists$type$key ) {
        
self::setup_type$type );
        return isset( 
self::$data$type ][ (string) $key ] );
    }


    
/**
     * @param string $type
     * @param $key
     * @return mixed
     */
    
static function get$type$key ) {
        
self::setup_type$type );

        if ( isset( 
self::$data$type ][ (string) $key ] ) ) {
            return 
self::$data$type ][ (string) $key ];
        }

        return 
false;
    }


    
/**
     * @param $type
     */
    
static function setup_type$type ) {
        if ( ! isset( 
self::$data$type ] ) ) {
            
self::$data$type ] = [];
        }
    }


    
/**
     * Remove all data and reset
     */
    
static function reset() {
        
self::$data = [];
    }

}