/var/www/html_nl/wp-content/plugins/wp-smtp/vendor/stellarwp/telemetry/src/Telemetry/Config.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<?php
/**
 * A helper class to provide configuration options for the library.
 *
 * @since 1.0.0
 *
 * @package StellarWP\Telemetry
 */

namespace StellarWP\Telemetry;

use 
StellarWP\ContainerContract\ContainerInterface;

/**
 * A configuration class to help set up the library.
 *
 * @since 1.0.0
 *
 * @package StellarWP\Telemetry
 */
class Config {

    
/**
     * Container object.
     *
     * @since 1.0.0
     *
     * @var ?\StellarWP\ContainerContract\ContainerInterface
     */
    
protected static $container;

    
/**
     * Prefix for hook names.
     *
     * @since 1.0.0
     *
     * @var string
     */
    
protected static $hook_prefix '';

    
/**
     * Unique ID for the stellarwp slug.
     *
     * @since 1.0.0
     *
     * @var string
     */
    
protected static $stellar_slug '';

    
/**
     * Unique IDs and optional plugin slugs for StellarWP slugs.
     *
     * @since 2.0.0
     *
     * @var array
     */
    
protected static $stellar_slugs = [];

    
/**
     * The url of the telemetry server.
     *
     * @since 1.0.0
     *
     * @var string
     */
    
protected static $server_url 'https://telemetry.stellarwp.com/api/v1';

    
/**
     * Get the container.
     *
     * @since 1.0.0
     *
     * @throws \RuntimeException Throws exception if container is not set.
     *
     * @return \StellarWP\ContainerContract\ContainerInterface
     */
    
public static function get_container() {
        if ( 
null === self::$container ) {
            throw new 
\RuntimeException'You must provide a container via StellarWP\Telemetry\Config::set_container() before attempting to fetch it.' );
        }

        return 
self::$container;
    }

    
/**
     * Gets the hook prefix.
     *
     * @since 1.0.0
     *
     * @return string
     */
    
public static function get_hook_prefix() {
        return static::
$hook_prefix;
    }

    
/**
     * Gets the telemetry server url.
     *
     * @since 1.0.0
     *
     * @return string
     */
    
public static function get_server_url() {
        return static::
$server_url;
    }

    
/**
     * Gets the stellar slug.
     *
     * @since 1.0.0
     *
     * @return string
     */
    
public static function get_stellar_slug() {
        return static::
$stellar_slug;
    }

    
/**
     * Gets the registered stellar slugs.
     *
     * @since 2.0.0
     *
     * @return array<string,string>
     */
    
public static function get_all_stellar_slugs() {
        return static::
$stellar_slugs;
    }

    
/**
     * Returns whether the container has been set.
     *
     * @since 1.0.0
     *
     * @return bool
     */
    
public static function has_container() {
        return 
null !== self::$container;
    }

    
/**
     * Resets this class back to the defaults.
     *
     * @since 1.0.0
     *
     * @return void
     */
    
public static function reset() {
        static::
$hook_prefix  '';
        static::
$server_url   'https://telemetry.stellarwp.com/api/v1';
        static::
$stellar_slug '';
        static::
$container    null;
    }

    
/**
     * Set the container object.
     *
     * @since 1.0.0
     *
     * @param \StellarWP\ContainerContract\ContainerInterface $container Container object.
     *
     * @return void
     */
    
public static function set_containerContainerInterface $container ) {
        
self::$container $container;
    }

    
/**
     * Sets the hook prefix.
     *
     * @since 1.0.0
     *
     * @param string $prefix The prefix to use for hooks.
     *
     * @return void
     */
    
public static function set_hook_prefixstring $prefix ) {
        
// Make sure the prefix always ends with a separator.
        
if ( substr$prefix, -) !== '/' ) {
            
$prefix $prefix '/';
        }

        static::
$hook_prefix $prefix;
    }

    
/**
     * Sets the stellar slug.
     *
     * @since 1.0.0
     *
     * @param string $stellar_slug The unique slug to identify the plugin with the server.
     *
     * @return void
     */
    
public static function set_stellar_slugstring $stellar_slug ) {
        static::
$stellar_slug $stellar_slug;

        
// Also add the stellar slug to the array of all registered stellar slugs.
        
static::$stellar_slugs$stellar_slug ] = '';
    }

    
/**
     * Adds a new stellar slug to the stellar slugs array.
     *
     * Utilizing an array of stellar slugs, the library can be tailored for use in a single plugin
     * or use within a shared library for several plugins. Each stellar slug registered will
     * generate unique filters and hooks that give further customization for each slug
     *
     * @since 2.0.0
     *
     * @param string $stellar_slug A unique slug to add to the config.
     * @param string $wp_slug      The plugin's basename (used for capturing deactivation "Exit Interview" info).
     *
     * @return void
     */
    
public static function add_stellar_slugstring $stellar_slugstring $wp_slug '' ) {
        static::
$stellar_slugs$stellar_slug ] = $wp_slug;
    }

    
/**
     * Sets the telemetry server url.
     *
     * @since 1.0.0
     *
     * @param string $url The url of the telemetry server.
     *
     * @return void
     */
    
public static function set_server_urlstring $url ) {
        static::
$server_url $url;
    }
}