Completed
Branch FET/asset-manager (433489)
by
unknown
32:42 queued 18:11
created
core/domain/values/Url.php 2 patches
Indentation   +194 added lines, -194 removed lines patch added patch discarded remove patch
@@ -17,198 +17,198 @@
 block discarded – undo
17 17
 class Url
18 18
 {
19 19
 
20
-    /**
21
-     * @var string $scheme
22
-     */
23
-    private $scheme;
24
-
25
-    /**
26
-     * @var string $host
27
-     */
28
-    private $host;
29
-
30
-    /**
31
-     * @var string $path
32
-     */
33
-    private $path;
34
-
35
-    /**
36
-     * @var string $query
37
-     */
38
-    private $query;
39
-
40
-    /**
41
-     * @var string $fragment
42
-     */
43
-    private $fragment;
44
-
45
-
46
-    /**
47
-     * Url constructor.
48
-     *
49
-     * @param $url
50
-     * @throws InvalidArgumentException
51
-     */
52
-    public function __construct($url)
53
-    {
54
-        if (! filter_var(
55
-            $url,
56
-            FILTER_VALIDATE_URL,
57
-            array(FILTER_FLAG_SCHEME_REQUIRED, FILTER_FLAG_HOST_REQUIRED)
58
-        )) {
59
-            throw new InvalidArgumentException(
60
-                esc_html__(
61
-                    'Invalid URL. Both the "Scheme" and "Host" are required.',
62
-                    'event_espresso'
63
-                )
64
-            );
65
-        }
66
-        $url = parse_url($url);
67
-        $this->setScheme($url);
68
-        $this->setHost($url);
69
-        $this->setPath($url);
70
-        $this->setQuery($url);
71
-        $this->setFragment($url);
72
-    }
73
-
74
-
75
-    /**
76
-     * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
77
-     * will return a string like: 'abc://'
78
-     *
79
-     * @return string
80
-     */
81
-    public function scheme()
82
-    {
83
-        return $this->scheme;
84
-    }
85
-
86
-
87
-    /**
88
-     * @param array $url
89
-     */
90
-    private function setScheme($url)
91
-    {
92
-        $this->scheme = $url['scheme'] . '://';
93
-    }
94
-
95
-
96
-    /**
97
-     * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
98
-     * will return a string like: 'example.com'
99
-     *
100
-     * @return string
101
-     */
102
-    public function host()
103
-    {
104
-        return $this->host;
105
-    }
106
-
107
-
108
-    /**
109
-     * @param array $url
110
-     */
111
-    private function setHost($url)
112
-    {
113
-        $this->host = $url['host'];
114
-    }
115
-
116
-
117
-    /**
118
-     * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
119
-     * will return a string like: '/path/data'
120
-     *
121
-     * @return string
122
-     */
123
-    public function path()
124
-    {
125
-        return $this->path;
126
-    }
127
-
128
-
129
-    /**
130
-     * @param array $url
131
-     */
132
-    private function setPath($url)
133
-    {
134
-        $this->path = isset($url['path']) ? $url['path'] : '';
135
-    }
136
-
137
-
138
-    /**
139
-     * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
140
-     * will return a string like: '?key=value'
141
-     *
142
-     * @return string
143
-     */
144
-    public function queryString()
145
-    {
146
-        return $this->query !== '' ? '?' . $this->query : '';
147
-    }
148
-
149
-
150
-    /**
151
-     * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
152
-     * will return an array like: array('key' => 'value')
153
-     *
154
-     * @return array
155
-     */
156
-    public function queryParams()
157
-    {
158
-        return wp_parse_args($this->query);
159
-    }
160
-
161
-
162
-    /**
163
-     * @param array $url
164
-     */
165
-    private function setQuery($url)
166
-    {
167
-        $this->query = isset($url['query']) ? $url['query'] : '';
168
-    }
169
-
170
-
171
-    /**
172
-     * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
173
-     * will return a string like: '#id'
174
-     *
175
-     * @return string
176
-     */
177
-    public function fragment()
178
-    {
179
-        return $this->fragment !== '' ? '#' . $this->fragment : '';
180
-    }
181
-
182
-
183
-    /**
184
-     * @param array $url
185
-     */
186
-    private function setFragment($url)
187
-    {
188
-        $this->fragment = isset($url['fragment']) ? $url['fragment'] : '';
189
-    }
190
-
191
-
192
-    /**
193
-     * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
194
-     * will return a string like: 'abc://example.com/path/data?key=value#id'
195
-     *
196
-     * @return string
197
-     */
198
-    public function getFullUrl()
199
-    {
200
-        return $this->scheme() . $this->host() . $this->path() . $this->queryString() . $this->fragment();
201
-    }
202
-
203
-
204
-    /**
205
-     * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
206
-     * will return a string like: 'abc://example.com/path/data?key=value#id'
207
-     *
208
-     * @return string
209
-     */
210
-    public function __toString()
211
-    {
212
-        return $this->getFullUrl();
213
-    }
20
+	/**
21
+	 * @var string $scheme
22
+	 */
23
+	private $scheme;
24
+
25
+	/**
26
+	 * @var string $host
27
+	 */
28
+	private $host;
29
+
30
+	/**
31
+	 * @var string $path
32
+	 */
33
+	private $path;
34
+
35
+	/**
36
+	 * @var string $query
37
+	 */
38
+	private $query;
39
+
40
+	/**
41
+	 * @var string $fragment
42
+	 */
43
+	private $fragment;
44
+
45
+
46
+	/**
47
+	 * Url constructor.
48
+	 *
49
+	 * @param $url
50
+	 * @throws InvalidArgumentException
51
+	 */
52
+	public function __construct($url)
53
+	{
54
+		if (! filter_var(
55
+			$url,
56
+			FILTER_VALIDATE_URL,
57
+			array(FILTER_FLAG_SCHEME_REQUIRED, FILTER_FLAG_HOST_REQUIRED)
58
+		)) {
59
+			throw new InvalidArgumentException(
60
+				esc_html__(
61
+					'Invalid URL. Both the "Scheme" and "Host" are required.',
62
+					'event_espresso'
63
+				)
64
+			);
65
+		}
66
+		$url = parse_url($url);
67
+		$this->setScheme($url);
68
+		$this->setHost($url);
69
+		$this->setPath($url);
70
+		$this->setQuery($url);
71
+		$this->setFragment($url);
72
+	}
73
+
74
+
75
+	/**
76
+	 * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
77
+	 * will return a string like: 'abc://'
78
+	 *
79
+	 * @return string
80
+	 */
81
+	public function scheme()
82
+	{
83
+		return $this->scheme;
84
+	}
85
+
86
+
87
+	/**
88
+	 * @param array $url
89
+	 */
90
+	private function setScheme($url)
91
+	{
92
+		$this->scheme = $url['scheme'] . '://';
93
+	}
94
+
95
+
96
+	/**
97
+	 * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
98
+	 * will return a string like: 'example.com'
99
+	 *
100
+	 * @return string
101
+	 */
102
+	public function host()
103
+	{
104
+		return $this->host;
105
+	}
106
+
107
+
108
+	/**
109
+	 * @param array $url
110
+	 */
111
+	private function setHost($url)
112
+	{
113
+		$this->host = $url['host'];
114
+	}
115
+
116
+
117
+	/**
118
+	 * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
119
+	 * will return a string like: '/path/data'
120
+	 *
121
+	 * @return string
122
+	 */
123
+	public function path()
124
+	{
125
+		return $this->path;
126
+	}
127
+
128
+
129
+	/**
130
+	 * @param array $url
131
+	 */
132
+	private function setPath($url)
133
+	{
134
+		$this->path = isset($url['path']) ? $url['path'] : '';
135
+	}
136
+
137
+
138
+	/**
139
+	 * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
140
+	 * will return a string like: '?key=value'
141
+	 *
142
+	 * @return string
143
+	 */
144
+	public function queryString()
145
+	{
146
+		return $this->query !== '' ? '?' . $this->query : '';
147
+	}
148
+
149
+
150
+	/**
151
+	 * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
152
+	 * will return an array like: array('key' => 'value')
153
+	 *
154
+	 * @return array
155
+	 */
156
+	public function queryParams()
157
+	{
158
+		return wp_parse_args($this->query);
159
+	}
160
+
161
+
162
+	/**
163
+	 * @param array $url
164
+	 */
165
+	private function setQuery($url)
166
+	{
167
+		$this->query = isset($url['query']) ? $url['query'] : '';
168
+	}
169
+
170
+
171
+	/**
172
+	 * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
173
+	 * will return a string like: '#id'
174
+	 *
175
+	 * @return string
176
+	 */
177
+	public function fragment()
178
+	{
179
+		return $this->fragment !== '' ? '#' . $this->fragment : '';
180
+	}
181
+
182
+
183
+	/**
184
+	 * @param array $url
185
+	 */
186
+	private function setFragment($url)
187
+	{
188
+		$this->fragment = isset($url['fragment']) ? $url['fragment'] : '';
189
+	}
190
+
191
+
192
+	/**
193
+	 * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
194
+	 * will return a string like: 'abc://example.com/path/data?key=value#id'
195
+	 *
196
+	 * @return string
197
+	 */
198
+	public function getFullUrl()
199
+	{
200
+		return $this->scheme() . $this->host() . $this->path() . $this->queryString() . $this->fragment();
201
+	}
202
+
203
+
204
+	/**
205
+	 * For a URL like: abc://username:[email protected]:123/path/data?key=value#id
206
+	 * will return a string like: 'abc://example.com/path/data?key=value#id'
207
+	 *
208
+	 * @return string
209
+	 */
210
+	public function __toString()
211
+	{
212
+		return $this->getFullUrl();
213
+	}
214 214
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function __construct($url)
53 53
     {
54
-        if (! filter_var(
54
+        if ( ! filter_var(
55 55
             $url,
56 56
             FILTER_VALIDATE_URL,
57 57
             array(FILTER_FLAG_SCHEME_REQUIRED, FILTER_FLAG_HOST_REQUIRED)
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
      */
90 90
     private function setScheme($url)
91 91
     {
92
-        $this->scheme = $url['scheme'] . '://';
92
+        $this->scheme = $url['scheme'].'://';
93 93
     }
94 94
 
95 95
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
      */
144 144
     public function queryString()
145 145
     {
146
-        return $this->query !== '' ? '?' . $this->query : '';
146
+        return $this->query !== '' ? '?'.$this->query : '';
147 147
     }
148 148
 
149 149
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
      */
177 177
     public function fragment()
178 178
     {
179
-        return $this->fragment !== '' ? '#' . $this->fragment : '';
179
+        return $this->fragment !== '' ? '#'.$this->fragment : '';
180 180
     }
181 181
 
182 182
 
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
      */
198 198
     public function getFullUrl()
199 199
     {
200
-        return $this->scheme() . $this->host() . $this->path() . $this->queryString() . $this->fragment();
200
+        return $this->scheme().$this->host().$this->path().$this->queryString().$this->fragment();
201 201
     }
202 202
 
203 203
 
Please login to merge, or discard this patch.
core/domain/values/session/SessionLifespan.php 1 patch
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -20,98 +20,98 @@
 block discarded – undo
20 20
 class SessionLifespan
21 21
 {
22 22
 
23
-    /**
24
-     * how long an EE session lasts in seconds
25
-     * default session lifespan of 1 hour (for not so instant IPNs)
26
-     *
27
-     * @var int $lifespan
28
-     */
29
-    private $lifespan;
30
-
31
-
32
-    /**
33
-     * SessionLifespan constructor.
34
-     *
35
-     * @param int $lifespan
36
-     * @throws DomainException
37
-     */
38
-    public function __construct($lifespan = 0)
39
-    {
40
-        $lifespan = absint($lifespan);
41
-        $lifespan = $lifespan > 0 ? $lifespan : (int) HOUR_IN_SECONDS;
42
-        $this->setLifespan($lifespan);
43
-    }
44
-
45
-
46
-    /**
47
-     * @param int $lifespan
48
-     * @throws DomainException
49
-     */
50
-    protected function setLifespan($lifespan)
51
-    {
52
-        if ($lifespan < 60) {
53
-            throw new DomainException(
54
-                esc_html__(
55
-                    'The session lifespan needs to be at least 60 seconds, and even that is extremely short',
56
-                    'event_espresso'
57
-                )
58
-            );
59
-        }
60
-        $this->lifespan = apply_filters(
61
-            'FHEE__EventEspresso_core_domain_values_session_SessionLifespan__setLifespan___lifespan',
62
-            // apply legacy filter for now but add doing it wrong notice in future
63
-            apply_filters(
64
-                'FHEE__EE_Session__construct___lifespan',
65
-                $lifespan
66
-            )
67
-        ) + 1;
68
-    }
69
-
70
-
71
-    /**
72
-     * @return int
73
-     */
74
-    public function inSeconds()
75
-    {
76
-        return $this->lifespan;
77
-    }
78
-
79
-
80
-    /**
81
-     * @param string $separator
82
-     * @return string
83
-     */
84
-    public function inHoursMinutesSeconds($separator = ':')
85
-    {
86
-        return sprintf(
87
-            '%02d%s%02d%s%02d',
88
-            floor($this->lifespan / 3600),
89
-            $separator,
90
-            ($this->lifespan / 60) % 60,
91
-            $separator,
92
-            $this->lifespan % 60
93
-        );
94
-    }
95
-
96
-
97
-    /**
98
-     * Returns a timestamp for when the session would expire based on this lifespan
99
-     *
100
-     * @param bool $utc If true, displays expiration in UTC
101
-     *                  If false, displays expiration in local time
102
-     * @return int
103
-     */
104
-    public function expiration($utc = true)
105
-    {
106
-        return (int) current_time('timestamp', $utc) - $this->lifespan;
107
-    }
108
-
109
-
110
-    /**
111
-     * @return string
112
-     */
113
-    public function __toString()
114
-    {
115
-        return (string) $this->inSeconds();
116
-    }
23
+	/**
24
+	 * how long an EE session lasts in seconds
25
+	 * default session lifespan of 1 hour (for not so instant IPNs)
26
+	 *
27
+	 * @var int $lifespan
28
+	 */
29
+	private $lifespan;
30
+
31
+
32
+	/**
33
+	 * SessionLifespan constructor.
34
+	 *
35
+	 * @param int $lifespan
36
+	 * @throws DomainException
37
+	 */
38
+	public function __construct($lifespan = 0)
39
+	{
40
+		$lifespan = absint($lifespan);
41
+		$lifespan = $lifespan > 0 ? $lifespan : (int) HOUR_IN_SECONDS;
42
+		$this->setLifespan($lifespan);
43
+	}
44
+
45
+
46
+	/**
47
+	 * @param int $lifespan
48
+	 * @throws DomainException
49
+	 */
50
+	protected function setLifespan($lifespan)
51
+	{
52
+		if ($lifespan < 60) {
53
+			throw new DomainException(
54
+				esc_html__(
55
+					'The session lifespan needs to be at least 60 seconds, and even that is extremely short',
56
+					'event_espresso'
57
+				)
58
+			);
59
+		}
60
+		$this->lifespan = apply_filters(
61
+			'FHEE__EventEspresso_core_domain_values_session_SessionLifespan__setLifespan___lifespan',
62
+			// apply legacy filter for now but add doing it wrong notice in future
63
+			apply_filters(
64
+				'FHEE__EE_Session__construct___lifespan',
65
+				$lifespan
66
+			)
67
+		) + 1;
68
+	}
69
+
70
+
71
+	/**
72
+	 * @return int
73
+	 */
74
+	public function inSeconds()
75
+	{
76
+		return $this->lifespan;
77
+	}
78
+
79
+
80
+	/**
81
+	 * @param string $separator
82
+	 * @return string
83
+	 */
84
+	public function inHoursMinutesSeconds($separator = ':')
85
+	{
86
+		return sprintf(
87
+			'%02d%s%02d%s%02d',
88
+			floor($this->lifespan / 3600),
89
+			$separator,
90
+			($this->lifespan / 60) % 60,
91
+			$separator,
92
+			$this->lifespan % 60
93
+		);
94
+	}
95
+
96
+
97
+	/**
98
+	 * Returns a timestamp for when the session would expire based on this lifespan
99
+	 *
100
+	 * @param bool $utc If true, displays expiration in UTC
101
+	 *                  If false, displays expiration in local time
102
+	 * @return int
103
+	 */
104
+	public function expiration($utc = true)
105
+	{
106
+		return (int) current_time('timestamp', $utc) - $this->lifespan;
107
+	}
108
+
109
+
110
+	/**
111
+	 * @return string
112
+	 */
113
+	public function __toString()
114
+	{
115
+		return (string) $this->inSeconds();
116
+	}
117 117
 }
Please login to merge, or discard this patch.
core/domain/values/Version.php 2 patches
Indentation   +291 added lines, -291 removed lines patch added patch discarded remove patch
@@ -16,295 +16,295 @@
 block discarded – undo
16 16
 class Version
17 17
 {
18 18
 
19
-    const RELEASE_TYPE_RC    = 'rc';
20
-
21
-    const RELEASE_TYPE_BETA  = 'beta';
22
-
23
-    const RELEASE_TYPE_DECAF = 'decaf';
24
-
25
-    const RELEASE_TYPE_PROD  = 'p';
26
-
27
-    /**
28
-     * @var int $major
29
-     */
30
-    private $major;
31
-
32
-    /**
33
-     * @var int $minor
34
-     */
35
-    private $minor;
36
-
37
-    /**
38
-     * @var int $patch
39
-     */
40
-    private $patch;
41
-
42
-    /**
43
-     * @var string $release
44
-     */
45
-    private $release;
46
-
47
-    /**
48
-     * @var int $build
49
-     */
50
-    private $build;
51
-
52
-
53
-    /**
54
-     * Version constructor.
55
-     *
56
-     * @param int    $major
57
-     * @param int    $minor
58
-     * @param int    $patch
59
-     * @param string $release
60
-     * @param int    $build
61
-     * @throws InvalidDataTypeException
62
-     * @throws InvalidArgumentException
63
-     */
64
-    public function __construct($major, $minor, $patch, $release = Version::RELEASE_TYPE_PROD, $build = 0)
65
-    {
66
-        $this->setMajor($major);
67
-        $this->setMinor($minor);
68
-        $this->setPatch($patch);
69
-        $this->setRelease($release);
70
-        $this->setBuild($build);
71
-    }
72
-
73
-
74
-    /**
75
-     * @param string $version_string
76
-     * @return Version
77
-     * @throws InvalidArgumentException
78
-     */
79
-    public static function fromString($version_string)
80
-    {
81
-        // compare incoming version string against the lowest possible valid version
82
-        if (version_compare($version_string, '0.0.1.dev.001', '<')) {
83
-            throw new InvalidArgumentException(
84
-                sprintf(
85
-                    esc_html__('"%1$s" is not a valid version string', 'event_espresso'),
86
-                    $version_string
87
-                )
88
-            );
89
-        }
90
-        // break apart incoming version string
91
-        $version_parts = explode('.', $version_string);
92
-        // verify that version string at least contains {major}.{minor}.{patch}
93
-        if (count($version_parts) < 3) {
94
-            throw new InvalidArgumentException(
95
-                sprintf(
96
-                    esc_html__(
97
-                        'At minimum, a version string needs to be in a "{major}.{minor}.{patch}" format, therefore "%1$s" is not valid',
98
-                        'event_espresso'
99
-                    ),
100
-                    $version_string
101
-                )
102
-            );
103
-        }
104
-        // add defaults for missing pieces
105
-        $version_parts += array(0,0,0,'p',0);
106
-        // reassign to individual variables
107
-        list($major, $minor, $patch, $release, $build) = $version_parts;
108
-        return new Version(
109
-            (int) $major,
110
-            (int) $minor,
111
-            (int) $patch,
112
-            $release,
113
-            (int) $build
114
-        );
115
-    }
116
-
117
-
118
-    /**
119
-     * @return int
120
-     */
121
-    public function major()
122
-    {
123
-        return $this->major;
124
-    }
125
-
126
-
127
-    /**
128
-     * @param int|string $major
129
-     * @throws InvalidDataTypeException
130
-     */
131
-    private function setMajor($major)
132
-    {
133
-        if (! is_int($major)) {
134
-            throw new InvalidDataTypeException(
135
-                '$major',
136
-                $major,
137
-                'integer'
138
-            );
139
-        }
140
-        $this->major = absint($major);
141
-    }
142
-
143
-
144
-    /**
145
-     * @return int
146
-     */
147
-    public function minor()
148
-    {
149
-        return $this->minor;
150
-    }
151
-
152
-
153
-    /**
154
-     * @param int|string $minor
155
-     * @throws InvalidDataTypeException
156
-     */
157
-    private function setMinor($minor)
158
-    {
159
-        if (! is_int($minor)) {
160
-            throw new InvalidDataTypeException(
161
-                '$minor',
162
-                $minor,
163
-                'integer'
164
-            );
165
-        }
166
-        $this->minor = absint($minor);
167
-    }
168
-
169
-
170
-    /**
171
-     * @return int
172
-     */
173
-    public function patch()
174
-    {
175
-        return $this->patch;
176
-    }
177
-
178
-
179
-    /**
180
-     * @param int|string $patch
181
-     * @throws InvalidDataTypeException
182
-     */
183
-    private function setPatch($patch)
184
-    {
185
-        if (! is_int($patch)) {
186
-            throw new InvalidDataTypeException(
187
-                '$patch',
188
-                $patch,
189
-                'integer'
190
-            );
191
-        }
192
-        $this->patch = absint($patch);
193
-    }
194
-
195
-
196
-    /**
197
-     * @return string
198
-     */
199
-    public function release()
200
-    {
201
-        return $this->release;
202
-    }
203
-
204
-
205
-    /**
206
-     * @param string $release
207
-     * @throws InvalidArgumentException
208
-     */
209
-    private function setRelease($release)
210
-    {
211
-        $valid_release_types = array(
212
-            Version::RELEASE_TYPE_RC,
213
-            Version::RELEASE_TYPE_BETA,
214
-            Version::RELEASE_TYPE_DECAF,
215
-            Version::RELEASE_TYPE_PROD,
216
-        );
217
-        if (! in_array($release, $valid_release_types, true)) {
218
-            throw new InvalidArgumentException(
219
-                sprintf(
220
-                    esc_html__(
221
-                        '"%1$s" is not a valid release type. Please use one of the following values: %2$s',
222
-                        'event_espresso'
223
-                    ),
224
-                    $release,
225
-                    implode(', ', $valid_release_types)
226
-                )
227
-            );
228
-        }
229
-        $this->release = $release;
230
-    }
231
-
232
-
233
-    /**
234
-     * @return int
235
-     */
236
-    public function build()
237
-    {
238
-        return $this->build;
239
-    }
240
-
241
-
242
-    /**
243
-     * @param int|string $build
244
-     * @throws InvalidDataTypeException
245
-     */
246
-    private function setBuild($build)
247
-    {
248
-        if (! is_int($build)) {
249
-            throw new InvalidDataTypeException(
250
-                '$build',
251
-                $build,
252
-                'integer'
253
-            );
254
-        }
255
-        $this->build = absint($build);
256
-    }
257
-
258
-
259
-    /**
260
-     * @param Version $other_version
261
-     * @return int
262
-     */
263
-    public function compare(Version $other_version)
264
-    {
265
-        return version_compare((string) $this, (string) $other_version);
266
-    }
267
-
268
-
269
-    /**
270
-     * @param Version $other_version
271
-     * @return bool
272
-     */
273
-    public function equals(Version $other_version)
274
-    {
275
-        return version_compare((string) $this, (string) $other_version, '==');
276
-    }
277
-
278
-
279
-    /**
280
-     * @param Version $other_version
281
-     * @return bool
282
-     */
283
-    public function newerThan(Version $other_version)
284
-    {
285
-        return version_compare((string) $this, (string) $other_version, '>');
286
-    }
287
-
288
-
289
-    /**
290
-     * @param Version $other_version
291
-     * @return bool
292
-     */
293
-    public function olderThan(Version $other_version)
294
-    {
295
-        return version_compare((string) $this, (string) $other_version, '<');
296
-    }
297
-
298
-
299
-    /**
300
-     * @return string
301
-     */
302
-    public function __toString()
303
-    {
304
-        $version_string = "{$this->major}.{$this->minor}.{$this->patch}.{$this->release}";
305
-        if ($this->release !== Version::RELEASE_TYPE_PROD && $this->release !== Version::RELEASE_TYPE_DECAF) {
306
-            $version_string .= '.' . str_pad($this->build, 3, '0', STR_PAD_LEFT);
307
-        }
308
-        return $version_string;
309
-    }
19
+	const RELEASE_TYPE_RC    = 'rc';
20
+
21
+	const RELEASE_TYPE_BETA  = 'beta';
22
+
23
+	const RELEASE_TYPE_DECAF = 'decaf';
24
+
25
+	const RELEASE_TYPE_PROD  = 'p';
26
+
27
+	/**
28
+	 * @var int $major
29
+	 */
30
+	private $major;
31
+
32
+	/**
33
+	 * @var int $minor
34
+	 */
35
+	private $minor;
36
+
37
+	/**
38
+	 * @var int $patch
39
+	 */
40
+	private $patch;
41
+
42
+	/**
43
+	 * @var string $release
44
+	 */
45
+	private $release;
46
+
47
+	/**
48
+	 * @var int $build
49
+	 */
50
+	private $build;
51
+
52
+
53
+	/**
54
+	 * Version constructor.
55
+	 *
56
+	 * @param int    $major
57
+	 * @param int    $minor
58
+	 * @param int    $patch
59
+	 * @param string $release
60
+	 * @param int    $build
61
+	 * @throws InvalidDataTypeException
62
+	 * @throws InvalidArgumentException
63
+	 */
64
+	public function __construct($major, $minor, $patch, $release = Version::RELEASE_TYPE_PROD, $build = 0)
65
+	{
66
+		$this->setMajor($major);
67
+		$this->setMinor($minor);
68
+		$this->setPatch($patch);
69
+		$this->setRelease($release);
70
+		$this->setBuild($build);
71
+	}
72
+
73
+
74
+	/**
75
+	 * @param string $version_string
76
+	 * @return Version
77
+	 * @throws InvalidArgumentException
78
+	 */
79
+	public static function fromString($version_string)
80
+	{
81
+		// compare incoming version string against the lowest possible valid version
82
+		if (version_compare($version_string, '0.0.1.dev.001', '<')) {
83
+			throw new InvalidArgumentException(
84
+				sprintf(
85
+					esc_html__('"%1$s" is not a valid version string', 'event_espresso'),
86
+					$version_string
87
+				)
88
+			);
89
+		}
90
+		// break apart incoming version string
91
+		$version_parts = explode('.', $version_string);
92
+		// verify that version string at least contains {major}.{minor}.{patch}
93
+		if (count($version_parts) < 3) {
94
+			throw new InvalidArgumentException(
95
+				sprintf(
96
+					esc_html__(
97
+						'At minimum, a version string needs to be in a "{major}.{minor}.{patch}" format, therefore "%1$s" is not valid',
98
+						'event_espresso'
99
+					),
100
+					$version_string
101
+				)
102
+			);
103
+		}
104
+		// add defaults for missing pieces
105
+		$version_parts += array(0,0,0,'p',0);
106
+		// reassign to individual variables
107
+		list($major, $minor, $patch, $release, $build) = $version_parts;
108
+		return new Version(
109
+			(int) $major,
110
+			(int) $minor,
111
+			(int) $patch,
112
+			$release,
113
+			(int) $build
114
+		);
115
+	}
116
+
117
+
118
+	/**
119
+	 * @return int
120
+	 */
121
+	public function major()
122
+	{
123
+		return $this->major;
124
+	}
125
+
126
+
127
+	/**
128
+	 * @param int|string $major
129
+	 * @throws InvalidDataTypeException
130
+	 */
131
+	private function setMajor($major)
132
+	{
133
+		if (! is_int($major)) {
134
+			throw new InvalidDataTypeException(
135
+				'$major',
136
+				$major,
137
+				'integer'
138
+			);
139
+		}
140
+		$this->major = absint($major);
141
+	}
142
+
143
+
144
+	/**
145
+	 * @return int
146
+	 */
147
+	public function minor()
148
+	{
149
+		return $this->minor;
150
+	}
151
+
152
+
153
+	/**
154
+	 * @param int|string $minor
155
+	 * @throws InvalidDataTypeException
156
+	 */
157
+	private function setMinor($minor)
158
+	{
159
+		if (! is_int($minor)) {
160
+			throw new InvalidDataTypeException(
161
+				'$minor',
162
+				$minor,
163
+				'integer'
164
+			);
165
+		}
166
+		$this->minor = absint($minor);
167
+	}
168
+
169
+
170
+	/**
171
+	 * @return int
172
+	 */
173
+	public function patch()
174
+	{
175
+		return $this->patch;
176
+	}
177
+
178
+
179
+	/**
180
+	 * @param int|string $patch
181
+	 * @throws InvalidDataTypeException
182
+	 */
183
+	private function setPatch($patch)
184
+	{
185
+		if (! is_int($patch)) {
186
+			throw new InvalidDataTypeException(
187
+				'$patch',
188
+				$patch,
189
+				'integer'
190
+			);
191
+		}
192
+		$this->patch = absint($patch);
193
+	}
194
+
195
+
196
+	/**
197
+	 * @return string
198
+	 */
199
+	public function release()
200
+	{
201
+		return $this->release;
202
+	}
203
+
204
+
205
+	/**
206
+	 * @param string $release
207
+	 * @throws InvalidArgumentException
208
+	 */
209
+	private function setRelease($release)
210
+	{
211
+		$valid_release_types = array(
212
+			Version::RELEASE_TYPE_RC,
213
+			Version::RELEASE_TYPE_BETA,
214
+			Version::RELEASE_TYPE_DECAF,
215
+			Version::RELEASE_TYPE_PROD,
216
+		);
217
+		if (! in_array($release, $valid_release_types, true)) {
218
+			throw new InvalidArgumentException(
219
+				sprintf(
220
+					esc_html__(
221
+						'"%1$s" is not a valid release type. Please use one of the following values: %2$s',
222
+						'event_espresso'
223
+					),
224
+					$release,
225
+					implode(', ', $valid_release_types)
226
+				)
227
+			);
228
+		}
229
+		$this->release = $release;
230
+	}
231
+
232
+
233
+	/**
234
+	 * @return int
235
+	 */
236
+	public function build()
237
+	{
238
+		return $this->build;
239
+	}
240
+
241
+
242
+	/**
243
+	 * @param int|string $build
244
+	 * @throws InvalidDataTypeException
245
+	 */
246
+	private function setBuild($build)
247
+	{
248
+		if (! is_int($build)) {
249
+			throw new InvalidDataTypeException(
250
+				'$build',
251
+				$build,
252
+				'integer'
253
+			);
254
+		}
255
+		$this->build = absint($build);
256
+	}
257
+
258
+
259
+	/**
260
+	 * @param Version $other_version
261
+	 * @return int
262
+	 */
263
+	public function compare(Version $other_version)
264
+	{
265
+		return version_compare((string) $this, (string) $other_version);
266
+	}
267
+
268
+
269
+	/**
270
+	 * @param Version $other_version
271
+	 * @return bool
272
+	 */
273
+	public function equals(Version $other_version)
274
+	{
275
+		return version_compare((string) $this, (string) $other_version, '==');
276
+	}
277
+
278
+
279
+	/**
280
+	 * @param Version $other_version
281
+	 * @return bool
282
+	 */
283
+	public function newerThan(Version $other_version)
284
+	{
285
+		return version_compare((string) $this, (string) $other_version, '>');
286
+	}
287
+
288
+
289
+	/**
290
+	 * @param Version $other_version
291
+	 * @return bool
292
+	 */
293
+	public function olderThan(Version $other_version)
294
+	{
295
+		return version_compare((string) $this, (string) $other_version, '<');
296
+	}
297
+
298
+
299
+	/**
300
+	 * @return string
301
+	 */
302
+	public function __toString()
303
+	{
304
+		$version_string = "{$this->major}.{$this->minor}.{$this->patch}.{$this->release}";
305
+		if ($this->release !== Version::RELEASE_TYPE_PROD && $this->release !== Version::RELEASE_TYPE_DECAF) {
306
+			$version_string .= '.' . str_pad($this->build, 3, '0', STR_PAD_LEFT);
307
+		}
308
+		return $version_string;
309
+	}
310 310
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
             );
103 103
         }
104 104
         // add defaults for missing pieces
105
-        $version_parts += array(0,0,0,'p',0);
105
+        $version_parts += array(0, 0, 0, 'p', 0);
106 106
         // reassign to individual variables
107 107
         list($major, $minor, $patch, $release, $build) = $version_parts;
108 108
         return new Version(
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      */
131 131
     private function setMajor($major)
132 132
     {
133
-        if (! is_int($major)) {
133
+        if ( ! is_int($major)) {
134 134
             throw new InvalidDataTypeException(
135 135
                 '$major',
136 136
                 $major,
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
      */
157 157
     private function setMinor($minor)
158 158
     {
159
-        if (! is_int($minor)) {
159
+        if ( ! is_int($minor)) {
160 160
             throw new InvalidDataTypeException(
161 161
                 '$minor',
162 162
                 $minor,
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
      */
183 183
     private function setPatch($patch)
184 184
     {
185
-        if (! is_int($patch)) {
185
+        if ( ! is_int($patch)) {
186 186
             throw new InvalidDataTypeException(
187 187
                 '$patch',
188 188
                 $patch,
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
             Version::RELEASE_TYPE_DECAF,
215 215
             Version::RELEASE_TYPE_PROD,
216 216
         );
217
-        if (! in_array($release, $valid_release_types, true)) {
217
+        if ( ! in_array($release, $valid_release_types, true)) {
218 218
             throw new InvalidArgumentException(
219 219
                 sprintf(
220 220
                     esc_html__(
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
      */
246 246
     private function setBuild($build)
247 247
     {
248
-        if (! is_int($build)) {
248
+        if ( ! is_int($build)) {
249 249
             throw new InvalidDataTypeException(
250 250
                 '$build',
251 251
                 $build,
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
     {
304 304
         $version_string = "{$this->major}.{$this->minor}.{$this->patch}.{$this->release}";
305 305
         if ($this->release !== Version::RELEASE_TYPE_PROD && $this->release !== Version::RELEASE_TYPE_DECAF) {
306
-            $version_string .= '.' . str_pad($this->build, 3, '0', STR_PAD_LEFT);
306
+            $version_string .= '.'.str_pad($this->build, 3, '0', STR_PAD_LEFT);
307 307
         }
308 308
         return $version_string;
309 309
     }
Please login to merge, or discard this patch.
core/domain/RequiresRegistryInterface.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@
 block discarded – undo
15 15
 interface RequiresRegistryInterface
16 16
 {
17 17
 
18
-    /**
19
-     * @param EE_Registry $registry
20
-     */
21
-    public function setRegistry($registry);
18
+	/**
19
+	 * @param EE_Registry $registry
20
+	 */
21
+	public function setRegistry($registry);
22 22
 }
Please login to merge, or discard this patch.
core/domain/entities/DbSafeDateTime.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
             DbSafeDateTime::db_safe_timestamp_format,
72 72
             $this->_datetime_string
73 73
         );
74
-        if (! $date instanceof DateTime) {
74
+        if ( ! $date instanceof DateTime) {
75 75
             try {
76 76
                 // we want a stack trace to determine where the malformed date came from, so...
77 77
                 throw new DomainException('');
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
             DbSafeDateTime::db_safe_timestamp_format,
119 119
             $this->_datetime_string
120 120
         );
121
-        if (! $date instanceof DateTime) {
121
+        if ( ! $date instanceof DateTime) {
122 122
             $this->writeToErrorLog(
123 123
                 sprintf(
124 124
                     __(
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
      */
161 161
     private function writeToErrorLog($message)
162 162
     {
163
-        if (! empty($this->_error_log_dir)) {
163
+        if ( ! empty($this->_error_log_dir)) {
164 164
             /** @noinspection ForgottenDebugOutputInspection */
165 165
             error_log($message, 3, $this->_error_log_dir);
166 166
         } else {
Please login to merge, or discard this patch.
Indentation   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -18,156 +18,156 @@
 block discarded – undo
18 18
 class DbSafeDateTime extends DateTime
19 19
 {
20 20
 
21
-    // phpcs:disable Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase
22
-    /**
23
-     * @type string db_safe_timestamp_format
24
-     */
25
-    const db_safe_timestamp_format = 'Y-m-d H:i:s O e';
26
-    // phpcs:enable
27
-
28
-    // phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore
29
-    /**
30
-     * DateTime object converted to a string that includes the date, time, UTC offset, and timezone identifier
31
-     *
32
-     * @type string $_datetime_string
33
-     */
34
-    protected $_datetime_string = '';
35
-
36
-    /**
37
-     * where to write the error log to
38
-     *
39
-     * @type string $_error_log_dir
40
-     */
41
-    protected $_error_log_dir = '';
42
-    // phpcs:enable
43
-
44
-
45
-    /**
46
-     * @param string $error_log_dir
47
-     */
48
-    public function setErrorLogDir($error_log_dir)
49
-    {
50
-        // if the folder path is writable, then except the path + filename, else keep empty
51
-        $this->_error_log_dir = is_writable(str_replace(basename($error_log_dir), '', $error_log_dir))
52
-            ? $error_log_dir
53
-            : '';
54
-    }
55
-
56
-
57
-    /**
58
-     * @return string
59
-     */
60
-    public function __toString()
61
-    {
62
-        return $this->format(DbSafeDateTime::db_safe_timestamp_format);
63
-    }
64
-
65
-
66
-    /**
67
-     * @return array
68
-     */
69
-    public function __sleep()
70
-    {
71
-        $this->_datetime_string = $this->format(DbSafeDateTime::db_safe_timestamp_format);
72
-        $date = DateTime::createFromFormat(
73
-            DbSafeDateTime::db_safe_timestamp_format,
74
-            $this->_datetime_string
75
-        );
76
-        if (! $date instanceof DateTime) {
77
-            try {
78
-                // we want a stack trace to determine where the malformed date came from, so...
79
-                throw new DomainException('');
80
-            } catch (DomainException $e) {
81
-                $stack_trace = $e->getTraceAsString();
82
-            }
83
-            $this->writeToErrorLog(
84
-                sprintf(
85
-                    __(
86
-                        'A valid DateTime could not be generated from "%1$s" because the following errors occurred: %2$s %3$s %2$s PHP version: %4$s %2$s Stack Trace: %5$s',
87
-                        'event_espresso'
88
-                    ),
89
-                    $this->_datetime_string,
90
-                    '<br />',
91
-                    print_r(DateTime::getLastErrors(), true),
92
-                    PHP_VERSION,
93
-                    $stack_trace
94
-                )
95
-            );
96
-        }
97
-        return array('_datetime_string');
98
-    }
99
-
100
-
101
-    /**
102
-     * if an empty or null value got saved to the db for a datetime,
103
-     * then some servers and/or PHP itself will incorrectly convert that date string
104
-     * resulting in "-0001-11-30" for the year-month-day.
105
-     * see the Notes section
106
-     *
107
-     * @link http://php.net/manual/en/datetime.formats.date.php
108
-     * We'll replace those with "0000-00-00" which will allow a valid DateTime object to be created,
109
-     * but still result in the internal date for that object being set to "-0001-11-30 10:00:00.000000".
110
-     * so we're no better off, but at least things won't go fatal on us.
111
-     */
112
-    public function __wakeup()
113
-    {
114
-        $this->_datetime_string = str_replace(
115
-            array('-0001-11-29', '-0001-11-30'),
116
-            '0000-00-00',
117
-            $this->_datetime_string
118
-        );
119
-        $date = DateTime::createFromFormat(
120
-            DbSafeDateTime::db_safe_timestamp_format,
121
-            $this->_datetime_string
122
-        );
123
-        if (! $date instanceof DateTime) {
124
-            $this->writeToErrorLog(
125
-                sprintf(
126
-                    __(
127
-                        'A valid DateTime could not be recreated from "%1$s" because the following errors occurred: %2$s %3$s %2$s PHP version: %4$s',
128
-                        'event_espresso'
129
-                    ),
130
-                    $this->_datetime_string,
131
-                    '<br />',
132
-                    print_r(DateTime::getLastErrors(), true),
133
-                    PHP_VERSION
134
-                )
135
-            );
136
-        } else {
137
-            $this->__construct(
138
-                $date->format(\EE_Datetime_Field::mysql_timestamp_format),
139
-                new DateTimeZone($date->format('e'))
140
-            );
141
-        }
142
-    }
143
-
144
-
145
-    /**
146
-     * Creates a DbSafeDateTime from ye old DateTime
147
-     *
148
-     * @param DateTime $datetime
149
-     * @return \EventEspresso\core\domain\entities\DbSafeDateTime
150
-     */
151
-    public static function createFromDateTime(DateTime $datetime)
152
-    {
153
-        return new DbSafeDateTime(
154
-            $datetime->format(\EE_Datetime_Field::mysql_timestamp_format),
155
-            new DateTimeZone($datetime->format('e'))
156
-        );
157
-    }
158
-
159
-
160
-    /**
161
-     * @param string $message
162
-     */
163
-    private function writeToErrorLog($message)
164
-    {
165
-        if (! empty($this->_error_log_dir)) {
166
-            /** @noinspection ForgottenDebugOutputInspection */
167
-            error_log($message, 3, $this->_error_log_dir);
168
-        } else {
169
-            /** @noinspection ForgottenDebugOutputInspection */
170
-            error_log($message);
171
-        }
172
-    }
21
+	// phpcs:disable Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase
22
+	/**
23
+	 * @type string db_safe_timestamp_format
24
+	 */
25
+	const db_safe_timestamp_format = 'Y-m-d H:i:s O e';
26
+	// phpcs:enable
27
+
28
+	// phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore
29
+	/**
30
+	 * DateTime object converted to a string that includes the date, time, UTC offset, and timezone identifier
31
+	 *
32
+	 * @type string $_datetime_string
33
+	 */
34
+	protected $_datetime_string = '';
35
+
36
+	/**
37
+	 * where to write the error log to
38
+	 *
39
+	 * @type string $_error_log_dir
40
+	 */
41
+	protected $_error_log_dir = '';
42
+	// phpcs:enable
43
+
44
+
45
+	/**
46
+	 * @param string $error_log_dir
47
+	 */
48
+	public function setErrorLogDir($error_log_dir)
49
+	{
50
+		// if the folder path is writable, then except the path + filename, else keep empty
51
+		$this->_error_log_dir = is_writable(str_replace(basename($error_log_dir), '', $error_log_dir))
52
+			? $error_log_dir
53
+			: '';
54
+	}
55
+
56
+
57
+	/**
58
+	 * @return string
59
+	 */
60
+	public function __toString()
61
+	{
62
+		return $this->format(DbSafeDateTime::db_safe_timestamp_format);
63
+	}
64
+
65
+
66
+	/**
67
+	 * @return array
68
+	 */
69
+	public function __sleep()
70
+	{
71
+		$this->_datetime_string = $this->format(DbSafeDateTime::db_safe_timestamp_format);
72
+		$date = DateTime::createFromFormat(
73
+			DbSafeDateTime::db_safe_timestamp_format,
74
+			$this->_datetime_string
75
+		);
76
+		if (! $date instanceof DateTime) {
77
+			try {
78
+				// we want a stack trace to determine where the malformed date came from, so...
79
+				throw new DomainException('');
80
+			} catch (DomainException $e) {
81
+				$stack_trace = $e->getTraceAsString();
82
+			}
83
+			$this->writeToErrorLog(
84
+				sprintf(
85
+					__(
86
+						'A valid DateTime could not be generated from "%1$s" because the following errors occurred: %2$s %3$s %2$s PHP version: %4$s %2$s Stack Trace: %5$s',
87
+						'event_espresso'
88
+					),
89
+					$this->_datetime_string,
90
+					'<br />',
91
+					print_r(DateTime::getLastErrors(), true),
92
+					PHP_VERSION,
93
+					$stack_trace
94
+				)
95
+			);
96
+		}
97
+		return array('_datetime_string');
98
+	}
99
+
100
+
101
+	/**
102
+	 * if an empty or null value got saved to the db for a datetime,
103
+	 * then some servers and/or PHP itself will incorrectly convert that date string
104
+	 * resulting in "-0001-11-30" for the year-month-day.
105
+	 * see the Notes section
106
+	 *
107
+	 * @link http://php.net/manual/en/datetime.formats.date.php
108
+	 * We'll replace those with "0000-00-00" which will allow a valid DateTime object to be created,
109
+	 * but still result in the internal date for that object being set to "-0001-11-30 10:00:00.000000".
110
+	 * so we're no better off, but at least things won't go fatal on us.
111
+	 */
112
+	public function __wakeup()
113
+	{
114
+		$this->_datetime_string = str_replace(
115
+			array('-0001-11-29', '-0001-11-30'),
116
+			'0000-00-00',
117
+			$this->_datetime_string
118
+		);
119
+		$date = DateTime::createFromFormat(
120
+			DbSafeDateTime::db_safe_timestamp_format,
121
+			$this->_datetime_string
122
+		);
123
+		if (! $date instanceof DateTime) {
124
+			$this->writeToErrorLog(
125
+				sprintf(
126
+					__(
127
+						'A valid DateTime could not be recreated from "%1$s" because the following errors occurred: %2$s %3$s %2$s PHP version: %4$s',
128
+						'event_espresso'
129
+					),
130
+					$this->_datetime_string,
131
+					'<br />',
132
+					print_r(DateTime::getLastErrors(), true),
133
+					PHP_VERSION
134
+				)
135
+			);
136
+		} else {
137
+			$this->__construct(
138
+				$date->format(\EE_Datetime_Field::mysql_timestamp_format),
139
+				new DateTimeZone($date->format('e'))
140
+			);
141
+		}
142
+	}
143
+
144
+
145
+	/**
146
+	 * Creates a DbSafeDateTime from ye old DateTime
147
+	 *
148
+	 * @param DateTime $datetime
149
+	 * @return \EventEspresso\core\domain\entities\DbSafeDateTime
150
+	 */
151
+	public static function createFromDateTime(DateTime $datetime)
152
+	{
153
+		return new DbSafeDateTime(
154
+			$datetime->format(\EE_Datetime_Field::mysql_timestamp_format),
155
+			new DateTimeZone($datetime->format('e'))
156
+		);
157
+	}
158
+
159
+
160
+	/**
161
+	 * @param string $message
162
+	 */
163
+	private function writeToErrorLog($message)
164
+	{
165
+		if (! empty($this->_error_log_dir)) {
166
+			/** @noinspection ForgottenDebugOutputInspection */
167
+			error_log($message, 3, $this->_error_log_dir);
168
+		} else {
169
+			/** @noinspection ForgottenDebugOutputInspection */
170
+			error_log($message);
171
+		}
172
+	}
173 173
 }
Please login to merge, or discard this patch.
core/domain/entities/notifications/PersistentAdminNotice.php 1 patch
Indentation   +311 added lines, -311 removed lines patch added patch discarded remove patch
@@ -24,315 +24,315 @@
 block discarded – undo
24 24
 class PersistentAdminNotice implements RequiresCapCheckInterface
25 25
 {
26 26
 
27
-    /**
28
-     * @var string $name
29
-     */
30
-    protected $name = '';
31
-
32
-    /**
33
-     * @var string $message
34
-     */
35
-    protected $message = '';
36
-
37
-    /**
38
-     * @var boolean $force_update
39
-     */
40
-    protected $force_update = false;
41
-
42
-    /**
43
-     * @var string $capability
44
-     */
45
-    protected $capability = 'manage_options';
46
-
47
-    /**
48
-     * @var string $cap_context
49
-     */
50
-    protected $cap_context = 'view persistent admin notice';
51
-
52
-    /**
53
-     * @var boolean $dismissed
54
-     */
55
-    protected $dismissed = false;
56
-
57
-    /**
58
-     * @var CapCheckInterface $cap_check
59
-     */
60
-    protected $cap_check;
61
-
62
-    /**
63
-     * if true, then this notice will be deleted from the database
64
-     *
65
-     * @var boolean $purge
66
-     */
67
-    protected $purge = false;
68
-
69
-    /**
70
-     * gets set to true if notice is successfully registered with the PersistentAdminNoticeManager
71
-     * if false, and WP_DEBUG is on, then an exception will be thrown in the admin footer
72
-     *
73
-     * @var boolean $registered
74
-     */
75
-    private $registered = false;
76
-
77
-
78
-    /**
79
-     * PersistentAdminNotice constructor
80
-     *
81
-     * @param string $name         [required] the name, or key of the Persistent Admin Notice to be stored
82
-     * @param string $message      [required] the message to be stored persistently until dismissed
83
-     * @param bool   $force_update enforce the reappearance of a persistent message
84
-     * @param string $capability   user capability required to view this notice
85
-     * @param string $cap_context  description for why the cap check is being performed
86
-     * @param bool   $dismissed    whether or not the user has already dismissed/viewed this notice
87
-     * @throws InvalidDataTypeException
88
-     */
89
-    public function __construct(
90
-        $name,
91
-        $message,
92
-        $force_update = false,
93
-        $capability = 'manage_options',
94
-        $cap_context = 'view persistent admin notice',
95
-        $dismissed = false
96
-    ) {
97
-        $this->setName($name);
98
-        $this->setMessage($message);
99
-        $this->setForceUpdate($force_update);
100
-        $this->setCapability($capability);
101
-        $this->setCapContext($cap_context);
102
-        $this->setDismissed($dismissed);
103
-        add_action(
104
-            'AHEE__EventEspresso_core_services_notifications_PersistentAdminNoticeManager__registerNotices',
105
-            array($this, 'registerPersistentAdminNotice')
106
-        );
107
-        add_action('shutdown', array($this, 'confirmRegistered'), 999);
108
-    }
109
-
110
-
111
-    /**
112
-     * @return string
113
-     */
114
-    public function getName()
115
-    {
116
-        return $this->name;
117
-    }
118
-
119
-
120
-    /**
121
-     * @param string $name
122
-     * @throws InvalidDataTypeException
123
-     */
124
-    private function setName($name)
125
-    {
126
-        if (! is_string($name)) {
127
-            throw new InvalidDataTypeException('$name', $name, 'string');
128
-        }
129
-        $this->name = sanitize_key($name);
130
-    }
131
-
132
-
133
-    /**
134
-     * @return string
135
-     */
136
-    public function getMessage()
137
-    {
138
-        return $this->message;
139
-    }
140
-
141
-
142
-    /**
143
-     * @param string $message
144
-     * @throws InvalidDataTypeException
145
-     */
146
-    private function setMessage($message)
147
-    {
148
-        if (! is_string($message)) {
149
-            throw new InvalidDataTypeException('$message', $message, 'string');
150
-        }
151
-        global $allowedtags;
152
-        $allowedtags['br'] = array();
153
-        $this->message = wp_kses($message, $allowedtags);
154
-    }
155
-
156
-
157
-    /**
158
-     * @return bool
159
-     */
160
-    public function getForceUpdate()
161
-    {
162
-        return $this->force_update;
163
-    }
164
-
165
-
166
-    /**
167
-     * @param bool $force_update
168
-     */
169
-    private function setForceUpdate($force_update)
170
-    {
171
-        $this->force_update = filter_var($force_update, FILTER_VALIDATE_BOOLEAN);
172
-    }
173
-
174
-
175
-    /**
176
-     * @return string
177
-     */
178
-    public function getCapability()
179
-    {
180
-        return $this->capability;
181
-    }
182
-
183
-
184
-    /**
185
-     * @param string $capability
186
-     * @throws InvalidDataTypeException
187
-     */
188
-    private function setCapability($capability)
189
-    {
190
-        if (! is_string($capability)) {
191
-            throw new InvalidDataTypeException('$capability', $capability, 'string');
192
-        }
193
-        $this->capability = ! empty($capability) ? $capability : 'manage_options';
194
-    }
195
-
196
-
197
-    /**
198
-     * @return string
199
-     */
200
-    public function getCapContext()
201
-    {
202
-        return $this->cap_context;
203
-    }
204
-
205
-
206
-    /**
207
-     * @param string $cap_context
208
-     * @throws InvalidDataTypeException
209
-     */
210
-    private function setCapContext($cap_context)
211
-    {
212
-        if (! is_string($cap_context)) {
213
-            throw new InvalidDataTypeException('$cap_context', $cap_context, 'string');
214
-        }
215
-        $this->cap_context = ! empty($cap_context) ? $cap_context : 'view persistent admin notice';
216
-    }
217
-
218
-
219
-    /**
220
-     * @return bool
221
-     */
222
-    public function getDismissed()
223
-    {
224
-        return $this->dismissed;
225
-    }
226
-
227
-
228
-    /**
229
-     * @param bool $dismissed
230
-     */
231
-    public function setDismissed($dismissed)
232
-    {
233
-        $this->dismissed = filter_var($dismissed, FILTER_VALIDATE_BOOLEAN);
234
-    }
235
-
236
-
237
-    /**
238
-     * @return CapCheckInterface
239
-     * @throws InvalidDataTypeException
240
-     */
241
-    public function getCapCheck()
242
-    {
243
-        if (! $this->cap_check instanceof CapCheckInterface) {
244
-            $this->setCapCheck(
245
-                new CapCheck(
246
-                    $this->capability,
247
-                    $this->cap_context
248
-                )
249
-            );
250
-        }
251
-        return $this->cap_check;
252
-    }
253
-
254
-
255
-    /**
256
-     * @param CapCheckInterface $cap_check
257
-     */
258
-    private function setCapCheck(CapCheckInterface $cap_check)
259
-    {
260
-        $this->cap_check = $cap_check;
261
-    }
262
-
263
-
264
-    /**
265
-     * @return bool
266
-     */
267
-    public function getPurge()
268
-    {
269
-        return $this->purge;
270
-    }
271
-
272
-
273
-    /**
274
-     * @param bool $purge
275
-     */
276
-    public function setPurge($purge)
277
-    {
278
-        $this->purge = filter_var($purge, FILTER_VALIDATE_BOOLEAN);
279
-    }
280
-
281
-
282
-    /**
283
-     * given a valid PersistentAdminNotice Collection,
284
-     * this notice will be added if it is not already found in the collection (using its name as the identifier)
285
-     * if an existing notice is found that has already been dismissed,
286
-     * but we are overriding with a forced update, then we will toggle its dismissed state,
287
-     * so that the notice is displayed again
288
-     *
289
-     * @param Collection $persistent_admin_notice_collection
290
-     * @throws InvalidEntityException
291
-     * @throws InvalidDataTypeException
292
-     */
293
-    public function registerPersistentAdminNotice(Collection $persistent_admin_notice_collection)
294
-    {
295
-        if ($this->registered) {
296
-            return;
297
-        }
298
-        // first check if this notice has already been added to the collection
299
-        if ($persistent_admin_notice_collection->has($this->name)) {
300
-            /** @var PersistentAdminNotice $existing */
301
-            $existing = $persistent_admin_notice_collection->get($this->name);
302
-            // we don't need to add it again (we can't actually)
303
-            // but if it has already been dismissed, and we are overriding with a forced update
304
-            if ($existing->getDismissed() && $this->getForceUpdate()) {
305
-                // then toggle the notice's dismissed state to true
306
-                // so that it gets displayed again
307
-                $existing->setDismissed(false);
308
-                // and make sure the message is set
309
-                $existing->setMessage($this->message);
310
-            }
311
-        } else {
312
-            $persistent_admin_notice_collection->add($this, $this->name);
313
-        }
314
-        $this->registered = true;
315
-    }
316
-
317
-
318
-    /**
319
-     * @throws Exception
320
-     */
321
-    public function confirmRegistered()
322
-    {
323
-        if (! apply_filters('PersistentAdminNoticeManager__registerAndSaveNotices__complete', false)) {
324
-            PersistentAdminNoticeManager::loadRegisterAndSaveNotices();
325
-        }
326
-        if (! $this->registered && WP_DEBUG) {
327
-            throw new DomainException(
328
-                sprintf(
329
-                    esc_html__(
330
-                        'The "%1$s" PersistentAdminNotice was not successfully registered. Please ensure that it is being created prior to either the "admin_notices" or "network_admin_notices" hooks being triggered.',
331
-                        'event_espresso'
332
-                    ),
333
-                    $this->name
334
-                )
335
-            );
336
-        }
337
-    }
27
+	/**
28
+	 * @var string $name
29
+	 */
30
+	protected $name = '';
31
+
32
+	/**
33
+	 * @var string $message
34
+	 */
35
+	protected $message = '';
36
+
37
+	/**
38
+	 * @var boolean $force_update
39
+	 */
40
+	protected $force_update = false;
41
+
42
+	/**
43
+	 * @var string $capability
44
+	 */
45
+	protected $capability = 'manage_options';
46
+
47
+	/**
48
+	 * @var string $cap_context
49
+	 */
50
+	protected $cap_context = 'view persistent admin notice';
51
+
52
+	/**
53
+	 * @var boolean $dismissed
54
+	 */
55
+	protected $dismissed = false;
56
+
57
+	/**
58
+	 * @var CapCheckInterface $cap_check
59
+	 */
60
+	protected $cap_check;
61
+
62
+	/**
63
+	 * if true, then this notice will be deleted from the database
64
+	 *
65
+	 * @var boolean $purge
66
+	 */
67
+	protected $purge = false;
68
+
69
+	/**
70
+	 * gets set to true if notice is successfully registered with the PersistentAdminNoticeManager
71
+	 * if false, and WP_DEBUG is on, then an exception will be thrown in the admin footer
72
+	 *
73
+	 * @var boolean $registered
74
+	 */
75
+	private $registered = false;
76
+
77
+
78
+	/**
79
+	 * PersistentAdminNotice constructor
80
+	 *
81
+	 * @param string $name         [required] the name, or key of the Persistent Admin Notice to be stored
82
+	 * @param string $message      [required] the message to be stored persistently until dismissed
83
+	 * @param bool   $force_update enforce the reappearance of a persistent message
84
+	 * @param string $capability   user capability required to view this notice
85
+	 * @param string $cap_context  description for why the cap check is being performed
86
+	 * @param bool   $dismissed    whether or not the user has already dismissed/viewed this notice
87
+	 * @throws InvalidDataTypeException
88
+	 */
89
+	public function __construct(
90
+		$name,
91
+		$message,
92
+		$force_update = false,
93
+		$capability = 'manage_options',
94
+		$cap_context = 'view persistent admin notice',
95
+		$dismissed = false
96
+	) {
97
+		$this->setName($name);
98
+		$this->setMessage($message);
99
+		$this->setForceUpdate($force_update);
100
+		$this->setCapability($capability);
101
+		$this->setCapContext($cap_context);
102
+		$this->setDismissed($dismissed);
103
+		add_action(
104
+			'AHEE__EventEspresso_core_services_notifications_PersistentAdminNoticeManager__registerNotices',
105
+			array($this, 'registerPersistentAdminNotice')
106
+		);
107
+		add_action('shutdown', array($this, 'confirmRegistered'), 999);
108
+	}
109
+
110
+
111
+	/**
112
+	 * @return string
113
+	 */
114
+	public function getName()
115
+	{
116
+		return $this->name;
117
+	}
118
+
119
+
120
+	/**
121
+	 * @param string $name
122
+	 * @throws InvalidDataTypeException
123
+	 */
124
+	private function setName($name)
125
+	{
126
+		if (! is_string($name)) {
127
+			throw new InvalidDataTypeException('$name', $name, 'string');
128
+		}
129
+		$this->name = sanitize_key($name);
130
+	}
131
+
132
+
133
+	/**
134
+	 * @return string
135
+	 */
136
+	public function getMessage()
137
+	{
138
+		return $this->message;
139
+	}
140
+
141
+
142
+	/**
143
+	 * @param string $message
144
+	 * @throws InvalidDataTypeException
145
+	 */
146
+	private function setMessage($message)
147
+	{
148
+		if (! is_string($message)) {
149
+			throw new InvalidDataTypeException('$message', $message, 'string');
150
+		}
151
+		global $allowedtags;
152
+		$allowedtags['br'] = array();
153
+		$this->message = wp_kses($message, $allowedtags);
154
+	}
155
+
156
+
157
+	/**
158
+	 * @return bool
159
+	 */
160
+	public function getForceUpdate()
161
+	{
162
+		return $this->force_update;
163
+	}
164
+
165
+
166
+	/**
167
+	 * @param bool $force_update
168
+	 */
169
+	private function setForceUpdate($force_update)
170
+	{
171
+		$this->force_update = filter_var($force_update, FILTER_VALIDATE_BOOLEAN);
172
+	}
173
+
174
+
175
+	/**
176
+	 * @return string
177
+	 */
178
+	public function getCapability()
179
+	{
180
+		return $this->capability;
181
+	}
182
+
183
+
184
+	/**
185
+	 * @param string $capability
186
+	 * @throws InvalidDataTypeException
187
+	 */
188
+	private function setCapability($capability)
189
+	{
190
+		if (! is_string($capability)) {
191
+			throw new InvalidDataTypeException('$capability', $capability, 'string');
192
+		}
193
+		$this->capability = ! empty($capability) ? $capability : 'manage_options';
194
+	}
195
+
196
+
197
+	/**
198
+	 * @return string
199
+	 */
200
+	public function getCapContext()
201
+	{
202
+		return $this->cap_context;
203
+	}
204
+
205
+
206
+	/**
207
+	 * @param string $cap_context
208
+	 * @throws InvalidDataTypeException
209
+	 */
210
+	private function setCapContext($cap_context)
211
+	{
212
+		if (! is_string($cap_context)) {
213
+			throw new InvalidDataTypeException('$cap_context', $cap_context, 'string');
214
+		}
215
+		$this->cap_context = ! empty($cap_context) ? $cap_context : 'view persistent admin notice';
216
+	}
217
+
218
+
219
+	/**
220
+	 * @return bool
221
+	 */
222
+	public function getDismissed()
223
+	{
224
+		return $this->dismissed;
225
+	}
226
+
227
+
228
+	/**
229
+	 * @param bool $dismissed
230
+	 */
231
+	public function setDismissed($dismissed)
232
+	{
233
+		$this->dismissed = filter_var($dismissed, FILTER_VALIDATE_BOOLEAN);
234
+	}
235
+
236
+
237
+	/**
238
+	 * @return CapCheckInterface
239
+	 * @throws InvalidDataTypeException
240
+	 */
241
+	public function getCapCheck()
242
+	{
243
+		if (! $this->cap_check instanceof CapCheckInterface) {
244
+			$this->setCapCheck(
245
+				new CapCheck(
246
+					$this->capability,
247
+					$this->cap_context
248
+				)
249
+			);
250
+		}
251
+		return $this->cap_check;
252
+	}
253
+
254
+
255
+	/**
256
+	 * @param CapCheckInterface $cap_check
257
+	 */
258
+	private function setCapCheck(CapCheckInterface $cap_check)
259
+	{
260
+		$this->cap_check = $cap_check;
261
+	}
262
+
263
+
264
+	/**
265
+	 * @return bool
266
+	 */
267
+	public function getPurge()
268
+	{
269
+		return $this->purge;
270
+	}
271
+
272
+
273
+	/**
274
+	 * @param bool $purge
275
+	 */
276
+	public function setPurge($purge)
277
+	{
278
+		$this->purge = filter_var($purge, FILTER_VALIDATE_BOOLEAN);
279
+	}
280
+
281
+
282
+	/**
283
+	 * given a valid PersistentAdminNotice Collection,
284
+	 * this notice will be added if it is not already found in the collection (using its name as the identifier)
285
+	 * if an existing notice is found that has already been dismissed,
286
+	 * but we are overriding with a forced update, then we will toggle its dismissed state,
287
+	 * so that the notice is displayed again
288
+	 *
289
+	 * @param Collection $persistent_admin_notice_collection
290
+	 * @throws InvalidEntityException
291
+	 * @throws InvalidDataTypeException
292
+	 */
293
+	public function registerPersistentAdminNotice(Collection $persistent_admin_notice_collection)
294
+	{
295
+		if ($this->registered) {
296
+			return;
297
+		}
298
+		// first check if this notice has already been added to the collection
299
+		if ($persistent_admin_notice_collection->has($this->name)) {
300
+			/** @var PersistentAdminNotice $existing */
301
+			$existing = $persistent_admin_notice_collection->get($this->name);
302
+			// we don't need to add it again (we can't actually)
303
+			// but if it has already been dismissed, and we are overriding with a forced update
304
+			if ($existing->getDismissed() && $this->getForceUpdate()) {
305
+				// then toggle the notice's dismissed state to true
306
+				// so that it gets displayed again
307
+				$existing->setDismissed(false);
308
+				// and make sure the message is set
309
+				$existing->setMessage($this->message);
310
+			}
311
+		} else {
312
+			$persistent_admin_notice_collection->add($this, $this->name);
313
+		}
314
+		$this->registered = true;
315
+	}
316
+
317
+
318
+	/**
319
+	 * @throws Exception
320
+	 */
321
+	public function confirmRegistered()
322
+	{
323
+		if (! apply_filters('PersistentAdminNoticeManager__registerAndSaveNotices__complete', false)) {
324
+			PersistentAdminNoticeManager::loadRegisterAndSaveNotices();
325
+		}
326
+		if (! $this->registered && WP_DEBUG) {
327
+			throw new DomainException(
328
+				sprintf(
329
+					esc_html__(
330
+						'The "%1$s" PersistentAdminNotice was not successfully registered. Please ensure that it is being created prior to either the "admin_notices" or "network_admin_notices" hooks being triggered.',
331
+						'event_espresso'
332
+					),
333
+					$this->name
334
+				)
335
+			);
336
+		}
337
+	}
338 338
 }
Please login to merge, or discard this patch.
core/domain/entities/contexts/RequestTypeContext.php 1 patch
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -16,137 +16,137 @@
 block discarded – undo
16 16
 class RequestTypeContext extends Context
17 17
 {
18 18
 
19
-    /**
20
-     * indicates that the current request involves some form of activation
21
-     */
22
-    const ACTIVATION = 'activation-request';
23
-
24
-    /**
25
-     * indicates that the current request is for the admin but is not being made via AJAX
26
-     */
27
-    const ADMIN = 'non-ajax-admin-request';
28
-
29
-    /**
30
-     * indicates that the current request is for the admin AND is being made via AJAX
31
-     */
32
-    const AJAX_ADMIN = 'admin-ajax-request';
33
-
34
-    /**
35
-     * indicates that the current request is for the frontend AND is being made via AJAX
36
-     */
37
-    const AJAX_FRONT = 'frontend-ajax-request';
38
-
39
-    /**
40
-     * indicates that the current request is being made via AJAX, but is NOT for EE
41
-     */
42
-    const AJAX_OTHER = 'other-ajax-request';
43
-
44
-    /**
45
-     * indicates that the current request is for the EE REST API
46
-     */
47
-    const API = 'rest-api';
48
-
49
-    /**
50
-     * indicates that the current request is from the command line
51
-     */
52
-    const CLI = 'command-line';
53
-
54
-    /**
55
-     * indicates that the current request is for a WP_Cron
56
-     */
57
-    const CRON = 'wp-cron';
58
-
59
-    /**
60
-     * indicates that the current request is for a feed (ie: RSS)
61
-     */
62
-    const FEED = 'feed-request';
63
-
64
-    /**
65
-     * indicates that the current request is for the frontend but is not being made via AJAX
66
-     */
67
-    const FRONTEND = 'non-ajax-frontend-request';
68
-
69
-    /**
70
-     * indicates that the current request is for content that is to be displayed within an iframe
71
-     */
72
-    const IFRAME = 'iframe-request';
73
-
74
-    /**
75
-     * @var boolean $is_activation
76
-     */
77
-    private $is_activation = false;
78
-
79
-    /**
80
-     * @var array $valid_request_types
81
-     */
82
-    private $valid_request_types = array();
83
-
84
-
85
-    /**
86
-     * RequestTypeContext constructor.
87
-     *
88
-     * @param string $slug
89
-     * @param string $description
90
-     * @throws InvalidArgumentException
91
-     */
92
-    public function __construct($slug, $description)
93
-    {
94
-        parent::__construct($slug, $description);
95
-        if (! in_array($this->slug(), $this->validRequestTypes(), true)) {
96
-            throw new InvalidArgumentException(
97
-                sprintf(
98
-                    esc_html__(
99
-                        'The RequestTypeContext slug must be one of the following values: %1$s %2$s',
100
-                        'event_espresso'
101
-                    ),
102
-                    var_export($this->validRequestTypes(), true)
103
-                )
104
-            );
105
-        }
106
-    }
107
-
108
-
109
-    /**
110
-     * @return array
111
-     */
112
-    public function validRequestTypes()
113
-    {
114
-        if (empty($this->valid_request_types)) {
115
-            $this->valid_request_types = apply_filters(
116
-                'FHEE__EventEspresso_core_domain_entities_contexts_RequestTypeContext__validRequestTypes',
117
-                array(
118
-                    RequestTypeContext::ACTIVATION,
119
-                    RequestTypeContext::ADMIN,
120
-                    RequestTypeContext::AJAX_ADMIN,
121
-                    RequestTypeContext::AJAX_FRONT,
122
-                    RequestTypeContext::AJAX_OTHER,
123
-                    RequestTypeContext::API,
124
-                    RequestTypeContext::CLI,
125
-                    RequestTypeContext::CRON,
126
-                    RequestTypeContext::FEED,
127
-                    RequestTypeContext::FRONTEND,
128
-                    RequestTypeContext::IFRAME,
129
-                )
130
-            );
131
-        }
132
-        return $this->valid_request_types;
133
-    }
134
-
135
-
136
-    /**
137
-     * @return bool
138
-     */
139
-    public function isActivation()
140
-    {
141
-        return $this->is_activation;
142
-    }
143
-
144
-
145
-    /**
146
-     * @param bool $is_activation
147
-     */
148
-    public function setIsActivation($is_activation)
149
-    {
150
-        $this->is_activation = filter_var($is_activation, FILTER_VALIDATE_BOOLEAN);
151
-    }
19
+	/**
20
+	 * indicates that the current request involves some form of activation
21
+	 */
22
+	const ACTIVATION = 'activation-request';
23
+
24
+	/**
25
+	 * indicates that the current request is for the admin but is not being made via AJAX
26
+	 */
27
+	const ADMIN = 'non-ajax-admin-request';
28
+
29
+	/**
30
+	 * indicates that the current request is for the admin AND is being made via AJAX
31
+	 */
32
+	const AJAX_ADMIN = 'admin-ajax-request';
33
+
34
+	/**
35
+	 * indicates that the current request is for the frontend AND is being made via AJAX
36
+	 */
37
+	const AJAX_FRONT = 'frontend-ajax-request';
38
+
39
+	/**
40
+	 * indicates that the current request is being made via AJAX, but is NOT for EE
41
+	 */
42
+	const AJAX_OTHER = 'other-ajax-request';
43
+
44
+	/**
45
+	 * indicates that the current request is for the EE REST API
46
+	 */
47
+	const API = 'rest-api';
48
+
49
+	/**
50
+	 * indicates that the current request is from the command line
51
+	 */
52
+	const CLI = 'command-line';
53
+
54
+	/**
55
+	 * indicates that the current request is for a WP_Cron
56
+	 */
57
+	const CRON = 'wp-cron';
58
+
59
+	/**
60
+	 * indicates that the current request is for a feed (ie: RSS)
61
+	 */
62
+	const FEED = 'feed-request';
63
+
64
+	/**
65
+	 * indicates that the current request is for the frontend but is not being made via AJAX
66
+	 */
67
+	const FRONTEND = 'non-ajax-frontend-request';
68
+
69
+	/**
70
+	 * indicates that the current request is for content that is to be displayed within an iframe
71
+	 */
72
+	const IFRAME = 'iframe-request';
73
+
74
+	/**
75
+	 * @var boolean $is_activation
76
+	 */
77
+	private $is_activation = false;
78
+
79
+	/**
80
+	 * @var array $valid_request_types
81
+	 */
82
+	private $valid_request_types = array();
83
+
84
+
85
+	/**
86
+	 * RequestTypeContext constructor.
87
+	 *
88
+	 * @param string $slug
89
+	 * @param string $description
90
+	 * @throws InvalidArgumentException
91
+	 */
92
+	public function __construct($slug, $description)
93
+	{
94
+		parent::__construct($slug, $description);
95
+		if (! in_array($this->slug(), $this->validRequestTypes(), true)) {
96
+			throw new InvalidArgumentException(
97
+				sprintf(
98
+					esc_html__(
99
+						'The RequestTypeContext slug must be one of the following values: %1$s %2$s',
100
+						'event_espresso'
101
+					),
102
+					var_export($this->validRequestTypes(), true)
103
+				)
104
+			);
105
+		}
106
+	}
107
+
108
+
109
+	/**
110
+	 * @return array
111
+	 */
112
+	public function validRequestTypes()
113
+	{
114
+		if (empty($this->valid_request_types)) {
115
+			$this->valid_request_types = apply_filters(
116
+				'FHEE__EventEspresso_core_domain_entities_contexts_RequestTypeContext__validRequestTypes',
117
+				array(
118
+					RequestTypeContext::ACTIVATION,
119
+					RequestTypeContext::ADMIN,
120
+					RequestTypeContext::AJAX_ADMIN,
121
+					RequestTypeContext::AJAX_FRONT,
122
+					RequestTypeContext::AJAX_OTHER,
123
+					RequestTypeContext::API,
124
+					RequestTypeContext::CLI,
125
+					RequestTypeContext::CRON,
126
+					RequestTypeContext::FEED,
127
+					RequestTypeContext::FRONTEND,
128
+					RequestTypeContext::IFRAME,
129
+				)
130
+			);
131
+		}
132
+		return $this->valid_request_types;
133
+	}
134
+
135
+
136
+	/**
137
+	 * @return bool
138
+	 */
139
+	public function isActivation()
140
+	{
141
+		return $this->is_activation;
142
+	}
143
+
144
+
145
+	/**
146
+	 * @param bool $is_activation
147
+	 */
148
+	public function setIsActivation($is_activation)
149
+	{
150
+		$this->is_activation = filter_var($is_activation, FILTER_VALIDATE_BOOLEAN);
151
+	}
152 152
 }
Please login to merge, or discard this patch.
core/domain/entities/contexts/Context.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -14,62 +14,62 @@
 block discarded – undo
14 14
 class Context implements ContextInterface
15 15
 {
16 16
 
17
-    /**
18
-     * @var string $slug
19
-     */
20
-    private $slug;
17
+	/**
18
+	 * @var string $slug
19
+	 */
20
+	private $slug;
21 21
 
22
-    /**
23
-     * @var string $description
24
-     */
25
-    private $description;
22
+	/**
23
+	 * @var string $description
24
+	 */
25
+	private $description;
26 26
 
27 27
 
28
-    /**
29
-     * Context constructor.
30
-     *
31
-     * @param string $slug
32
-     * @param string $description
33
-     */
34
-    public function __construct($slug, $description)
35
-    {
36
-        $this->setSlug($slug);
37
-        $this->setDescription($description);
38
-    }
28
+	/**
29
+	 * Context constructor.
30
+	 *
31
+	 * @param string $slug
32
+	 * @param string $description
33
+	 */
34
+	public function __construct($slug, $description)
35
+	{
36
+		$this->setSlug($slug);
37
+		$this->setDescription($description);
38
+	}
39 39
 
40 40
 
41
-    /**
42
-     * @return string
43
-     */
44
-    public function slug()
45
-    {
46
-        return $this->slug;
47
-    }
41
+	/**
42
+	 * @return string
43
+	 */
44
+	public function slug()
45
+	{
46
+		return $this->slug;
47
+	}
48 48
 
49 49
 
50
-    /**
51
-     * @param string $slug
52
-     */
53
-    private function setSlug($slug)
54
-    {
55
-        $this->slug = sanitize_key($slug);
56
-    }
50
+	/**
51
+	 * @param string $slug
52
+	 */
53
+	private function setSlug($slug)
54
+	{
55
+		$this->slug = sanitize_key($slug);
56
+	}
57 57
 
58 58
 
59
-    /**
60
-     * @return string
61
-     */
62
-    public function description()
63
-    {
64
-        return $this->description;
65
-    }
59
+	/**
60
+	 * @return string
61
+	 */
62
+	public function description()
63
+	{
64
+		return $this->description;
65
+	}
66 66
 
67 67
 
68
-    /**
69
-     * @param string $description
70
-     */
71
-    private function setDescription($description)
72
-    {
73
-        $this->description = sanitize_text_field($description);
74
-    }
68
+	/**
69
+	 * @param string $description
70
+	 */
71
+	private function setDescription($description)
72
+	{
73
+		$this->description = sanitize_text_field($description);
74
+	}
75 75
 }
Please login to merge, or discard this patch.
core/domain/entities/custom_post_types/CustomTaxonomyTerm.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -13,60 +13,60 @@
 block discarded – undo
13 13
 class CustomTaxonomyTerm
14 14
 {
15 15
 
16
-    /**
17
-     * @var string $taxonomy_slug
18
-     */
19
-    public $taxonomy_slug;
16
+	/**
17
+	 * @var string $taxonomy_slug
18
+	 */
19
+	public $taxonomy_slug;
20 20
 
21
-    /**
22
-     * @var string $term_slug
23
-     */
24
-    public $term_slug;
21
+	/**
22
+	 * @var string $term_slug
23
+	 */
24
+	public $term_slug;
25 25
 
26
-    /**
27
-     * @var array $custom_post_type_slugs
28
-     */
29
-    public $custom_post_type_slugs;
26
+	/**
27
+	 * @var array $custom_post_type_slugs
28
+	 */
29
+	public $custom_post_type_slugs;
30 30
 
31 31
 
32
-    /**
33
-     * CustomTaxonomyTerm constructor.
34
-     *
35
-     * @param string $taxonomy_slug
36
-     * @param string $term_slug
37
-     * @param array  $custom_post_type_slugs
38
-     */
39
-    public function __construct($taxonomy_slug, $term_slug, array $custom_post_type_slugs = array())
40
-    {
41
-        $this->taxonomy_slug = $taxonomy_slug;
42
-        $this->term_slug = $term_slug;
43
-        $this->custom_post_type_slugs = $custom_post_type_slugs;
44
-    }
32
+	/**
33
+	 * CustomTaxonomyTerm constructor.
34
+	 *
35
+	 * @param string $taxonomy_slug
36
+	 * @param string $term_slug
37
+	 * @param array  $custom_post_type_slugs
38
+	 */
39
+	public function __construct($taxonomy_slug, $term_slug, array $custom_post_type_slugs = array())
40
+	{
41
+		$this->taxonomy_slug = $taxonomy_slug;
42
+		$this->term_slug = $term_slug;
43
+		$this->custom_post_type_slugs = $custom_post_type_slugs;
44
+	}
45 45
 
46 46
 
47
-    /**
48
-     * @return string
49
-     */
50
-    public function taxonomySlug()
51
-    {
52
-        return $this->taxonomy_slug;
53
-    }
47
+	/**
48
+	 * @return string
49
+	 */
50
+	public function taxonomySlug()
51
+	{
52
+		return $this->taxonomy_slug;
53
+	}
54 54
 
55 55
 
56
-    /**
57
-     * @return string
58
-     */
59
-    public function termSlug()
60
-    {
61
-        return $this->term_slug;
62
-    }
56
+	/**
57
+	 * @return string
58
+	 */
59
+	public function termSlug()
60
+	{
61
+		return $this->term_slug;
62
+	}
63 63
 
64 64
 
65
-    /**
66
-     * @return array
67
-     */
68
-    public function customPostTypeSlugs()
69
-    {
70
-        return $this->custom_post_type_slugs;
71
-    }
65
+	/**
66
+	 * @return array
67
+	 */
68
+	public function customPostTypeSlugs()
69
+	{
70
+		return $this->custom_post_type_slugs;
71
+	}
72 72
 }
Please login to merge, or discard this patch.