Completed
Branch models-cleanup/model-relations (db5ca7)
by
unknown
13:03 queued 08:35
created
core/domain/CapabilitiesActionRestrictionInterface.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -14,34 +14,34 @@
 block discarded – undo
14 14
  */
15 15
 interface CapabilitiesActionRestrictionInterface
16 16
 {
17
-    /**
18
-     * Return whether the item can be edited for the given context.
19
-     * @param Context $context
20
-     * @return bool
21
-     */
22
-    public function canEdit(Context $context);
23
-
24
-
25
-    /**
26
-     * Return whether the item can be read for the given context.
27
-     * @param Context $context
28
-     * @return bool
29
-     */
30
-    public function canRead(Context $context);
31
-
32
-
33
-    /**
34
-     * Return whether the item can be deleted for the given context.
35
-     * @param Context $context
36
-     * @return bool
37
-     */
38
-    public function canDelete(Context $context);
39
-
40
-
41
-    /**
42
-     * Return whether the item can be created for the given context
43
-     * @param Context $context
44
-     * @return bool
45
-     */
46
-    public function canCreate(Context $context);
17
+	/**
18
+	 * Return whether the item can be edited for the given context.
19
+	 * @param Context $context
20
+	 * @return bool
21
+	 */
22
+	public function canEdit(Context $context);
23
+
24
+
25
+	/**
26
+	 * Return whether the item can be read for the given context.
27
+	 * @param Context $context
28
+	 * @return bool
29
+	 */
30
+	public function canRead(Context $context);
31
+
32
+
33
+	/**
34
+	 * Return whether the item can be deleted for the given context.
35
+	 * @param Context $context
36
+	 * @return bool
37
+	 */
38
+	public function canDelete(Context $context);
39
+
40
+
41
+	/**
42
+	 * Return whether the item can be created for the given context
43
+	 * @param Context $context
44
+	 * @return bool
45
+	 */
46
+	public function canCreate(Context $context);
47 47
 }
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   +190 added lines, -190 removed lines patch added patch discarded remove patch
@@ -20,194 +20,194 @@
 block discarded – undo
20 20
 class DbSafeDateTime extends DateTime
21 21
 {
22 22
 
23
-    // phpcs:disable Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase
24
-    /**
25
-     * @type string db_safe_timestamp_format
26
-     */
27
-    const db_safe_timestamp_format = 'Y-m-d H:i:s O e';
28
-
29
-    // phpcs:enable
30
-
31
-    // phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore
32
-    /**
33
-     * DateTime object converted to a string that includes the date, time, UTC offset, and timezone identifier
34
-     *
35
-     * @type string $_datetime_string
36
-     */
37
-    protected $_datetime_string = '';
38
-
39
-    /**
40
-     * where to write the error log to
41
-     *
42
-     * @type string $_error_log_dir
43
-     */
44
-    protected $_error_log_dir = '';
45
-
46
-    // phpcs:enable
47
-
48
-
49
-    /**
50
-     * @param string $error_log_dir
51
-     */
52
-    public function setErrorLogDir($error_log_dir)
53
-    {
54
-        // if the folder path is writable, then except the path + filename, else keep empty
55
-        $this->_error_log_dir = is_writable(str_replace(basename($error_log_dir), '', $error_log_dir))
56
-            ? $error_log_dir
57
-            : '';
58
-    }
59
-
60
-
61
-    /**
62
-     * @return string
63
-     */
64
-    public function __toString()
65
-    {
66
-        return $this->format(DbSafeDateTime::db_safe_timestamp_format);
67
-    }
68
-
69
-
70
-    /**
71
-     * @return array
72
-     */
73
-    public function __sleep()
74
-    {
75
-        $this->_datetime_string = $this->format(DbSafeDateTime::db_safe_timestamp_format);
76
-        $date                   = DateTime::createFromFormat(
77
-            DbSafeDateTime::db_safe_timestamp_format,
78
-            $this->_datetime_string
79
-        );
80
-        if (! $date instanceof DateTime) {
81
-            try {
82
-                // we want a stack trace to determine where the malformed date came from, so...
83
-                throw new DomainException('');
84
-            } catch (DomainException $e) {
85
-                $stack_trace = $e->getTraceAsString();
86
-            }
87
-            $this->writeToErrorLog(
88
-                sprintf(
89
-                    __(
90
-                        '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',
91
-                        'event_espresso'
92
-                    ),
93
-                    $this->_datetime_string,
94
-                    '<br />',
95
-                    print_r(DateTime::getLastErrors(), true),
96
-                    PHP_VERSION,
97
-                    $stack_trace
98
-                )
99
-            );
100
-        }
101
-        return ['_datetime_string'];
102
-    }
103
-
104
-
105
-    /**
106
-     * if an empty or null value got saved to the db for a datetime,
107
-     * then some servers and/or PHP itself will incorrectly convert that date string
108
-     * resulting in "-0001-11-30" for the year-month-day.
109
-     * see the Notes section
110
-     *
111
-     * @throws Exception
112
-     * @link http://php.net/manual/en/datetime.formats.date.php
113
-     * We'll replace those with "0000-00-00" which will allow a valid DateTime object to be created,
114
-     * but still result in the internal date for that object being set to "-0001-11-30 10:00:00.000000".
115
-     * so we're no better off, but at least things won't go fatal on us.
116
-     */
117
-    public function __wakeup()
118
-    {
119
-        $date = self::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
-     * Normalizes incoming date string so that it is a bit more stable for use.
147
-     *
148
-     * @param string $date_string
149
-     * @return string
150
-     */
151
-    public static function normalizeInvalidDate($date_string)
152
-    {
153
-        return str_replace(
154
-            ['-0001-11-29', '-0001-11-30', '0000-00-00'],
155
-            '0000-01-03',
156
-            $date_string
157
-        );
158
-    }
159
-
160
-
161
-    /**
162
-     * Creates a DbSafeDateTime from ye old DateTime
163
-     *
164
-     * @param DateTime $datetime
165
-     * @return DbSafeDateTime
166
-     * @throws Exception
167
-     */
168
-    public static function createFromDateTime(DateTime $datetime)
169
-    {
170
-        return new DbSafeDateTime(
171
-            $datetime->format(EE_Datetime_Field::mysql_timestamp_format),
172
-            new DateTimeZone($datetime->format('e'))
173
-        );
174
-    }
175
-
176
-
177
-    /**
178
-     * Parse a string into a new DateTime object according to the specified format
179
-     *
180
-     * @param string            $format   Format accepted by date().
181
-     * @param string            $time     String representing the time.
182
-     * @param DateTimeZone|null $timezone A DateTimeZone object representing the desired time zone.
183
-     * @return DbSafeDateTime|boolean
184
-     * @throws Exception
185
-     * @link https://php.net/manual/en/datetime.createfromformat.php
186
-     */
187
-    public static function createFromFormat($format, $time, DateTimeZone $timezone = null)
188
-    {
189
-        $time = self::normalizeInvalidDate($time);
190
-        // Various php versions handle the third argument differently.  This conditional accounts for that.
191
-        $DateTime = $timezone instanceof DateTimeZone
192
-            ? parent::createFromFormat($format, $time, $timezone)
193
-            : parent::createFromFormat($format, $time);
194
-        return $DateTime instanceof DateTime
195
-            ? self::createFromDateTime($DateTime)
196
-            : $DateTime;
197
-    }
198
-
199
-
200
-    /**
201
-     * @param string $message
202
-     */
203
-    private function writeToErrorLog($message)
204
-    {
205
-        if (! empty($this->_error_log_dir)) {
206
-            /** @noinspection ForgottenDebugOutputInspection */
207
-            error_log($message, 3, $this->_error_log_dir);
208
-        } else {
209
-            /** @noinspection ForgottenDebugOutputInspection */
210
-            error_log($message);
211
-        }
212
-    }
23
+	// phpcs:disable Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase
24
+	/**
25
+	 * @type string db_safe_timestamp_format
26
+	 */
27
+	const db_safe_timestamp_format = 'Y-m-d H:i:s O e';
28
+
29
+	// phpcs:enable
30
+
31
+	// phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore
32
+	/**
33
+	 * DateTime object converted to a string that includes the date, time, UTC offset, and timezone identifier
34
+	 *
35
+	 * @type string $_datetime_string
36
+	 */
37
+	protected $_datetime_string = '';
38
+
39
+	/**
40
+	 * where to write the error log to
41
+	 *
42
+	 * @type string $_error_log_dir
43
+	 */
44
+	protected $_error_log_dir = '';
45
+
46
+	// phpcs:enable
47
+
48
+
49
+	/**
50
+	 * @param string $error_log_dir
51
+	 */
52
+	public function setErrorLogDir($error_log_dir)
53
+	{
54
+		// if the folder path is writable, then except the path + filename, else keep empty
55
+		$this->_error_log_dir = is_writable(str_replace(basename($error_log_dir), '', $error_log_dir))
56
+			? $error_log_dir
57
+			: '';
58
+	}
59
+
60
+
61
+	/**
62
+	 * @return string
63
+	 */
64
+	public function __toString()
65
+	{
66
+		return $this->format(DbSafeDateTime::db_safe_timestamp_format);
67
+	}
68
+
69
+
70
+	/**
71
+	 * @return array
72
+	 */
73
+	public function __sleep()
74
+	{
75
+		$this->_datetime_string = $this->format(DbSafeDateTime::db_safe_timestamp_format);
76
+		$date                   = DateTime::createFromFormat(
77
+			DbSafeDateTime::db_safe_timestamp_format,
78
+			$this->_datetime_string
79
+		);
80
+		if (! $date instanceof DateTime) {
81
+			try {
82
+				// we want a stack trace to determine where the malformed date came from, so...
83
+				throw new DomainException('');
84
+			} catch (DomainException $e) {
85
+				$stack_trace = $e->getTraceAsString();
86
+			}
87
+			$this->writeToErrorLog(
88
+				sprintf(
89
+					__(
90
+						'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',
91
+						'event_espresso'
92
+					),
93
+					$this->_datetime_string,
94
+					'<br />',
95
+					print_r(DateTime::getLastErrors(), true),
96
+					PHP_VERSION,
97
+					$stack_trace
98
+				)
99
+			);
100
+		}
101
+		return ['_datetime_string'];
102
+	}
103
+
104
+
105
+	/**
106
+	 * if an empty or null value got saved to the db for a datetime,
107
+	 * then some servers and/or PHP itself will incorrectly convert that date string
108
+	 * resulting in "-0001-11-30" for the year-month-day.
109
+	 * see the Notes section
110
+	 *
111
+	 * @throws Exception
112
+	 * @link http://php.net/manual/en/datetime.formats.date.php
113
+	 * We'll replace those with "0000-00-00" which will allow a valid DateTime object to be created,
114
+	 * but still result in the internal date for that object being set to "-0001-11-30 10:00:00.000000".
115
+	 * so we're no better off, but at least things won't go fatal on us.
116
+	 */
117
+	public function __wakeup()
118
+	{
119
+		$date = self::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
+	 * Normalizes incoming date string so that it is a bit more stable for use.
147
+	 *
148
+	 * @param string $date_string
149
+	 * @return string
150
+	 */
151
+	public static function normalizeInvalidDate($date_string)
152
+	{
153
+		return str_replace(
154
+			['-0001-11-29', '-0001-11-30', '0000-00-00'],
155
+			'0000-01-03',
156
+			$date_string
157
+		);
158
+	}
159
+
160
+
161
+	/**
162
+	 * Creates a DbSafeDateTime from ye old DateTime
163
+	 *
164
+	 * @param DateTime $datetime
165
+	 * @return DbSafeDateTime
166
+	 * @throws Exception
167
+	 */
168
+	public static function createFromDateTime(DateTime $datetime)
169
+	{
170
+		return new DbSafeDateTime(
171
+			$datetime->format(EE_Datetime_Field::mysql_timestamp_format),
172
+			new DateTimeZone($datetime->format('e'))
173
+		);
174
+	}
175
+
176
+
177
+	/**
178
+	 * Parse a string into a new DateTime object according to the specified format
179
+	 *
180
+	 * @param string            $format   Format accepted by date().
181
+	 * @param string            $time     String representing the time.
182
+	 * @param DateTimeZone|null $timezone A DateTimeZone object representing the desired time zone.
183
+	 * @return DbSafeDateTime|boolean
184
+	 * @throws Exception
185
+	 * @link https://php.net/manual/en/datetime.createfromformat.php
186
+	 */
187
+	public static function createFromFormat($format, $time, DateTimeZone $timezone = null)
188
+	{
189
+		$time = self::normalizeInvalidDate($time);
190
+		// Various php versions handle the third argument differently.  This conditional accounts for that.
191
+		$DateTime = $timezone instanceof DateTimeZone
192
+			? parent::createFromFormat($format, $time, $timezone)
193
+			: parent::createFromFormat($format, $time);
194
+		return $DateTime instanceof DateTime
195
+			? self::createFromDateTime($DateTime)
196
+			: $DateTime;
197
+	}
198
+
199
+
200
+	/**
201
+	 * @param string $message
202
+	 */
203
+	private function writeToErrorLog($message)
204
+	{
205
+		if (! empty($this->_error_log_dir)) {
206
+			/** @noinspection ForgottenDebugOutputInspection */
207
+			error_log($message, 3, $this->_error_log_dir);
208
+		} else {
209
+			/** @noinspection ForgottenDebugOutputInspection */
210
+			error_log($message);
211
+		}
212
+	}
213 213
 }
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.
core/domain/entities/RegCode.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -14,49 +14,49 @@
 block discarded – undo
14 14
 {
15 15
 
16 16
 
17
-    /*
17
+	/*
18 18
      * @var string $reg_code
19 19
      */
20
-    private $reg_code;
21
-
22
-
23
-    /**
24
-     * RegCode constructor.
25
-     *
26
-     * @param RegUrlLink      $reg_url_link
27
-     * @param \EE_Transaction $transaction
28
-     * @param \EE_Ticket      $ticket
29
-     */
30
-    public function __construct(
31
-        RegUrlLink $reg_url_link,
32
-        \EE_Transaction $transaction,
33
-        \EE_Ticket $ticket
34
-    ) {
35
-        // figure out where to start parsing the reg code
36
-        $chars = strpos($reg_url_link, '-') + 5;
37
-        // TXN_ID + TKT_ID + first 3 and last 3 chars of reg_url_link
38
-        $this->reg_code = array(
39
-            $transaction->ID(),
40
-            $ticket->ID(),
41
-            substr($reg_url_link, 0, $chars),
42
-        );
43
-        // now put it all together
44
-        $this->reg_code = apply_filters(
45
-            'FHEE__Create__regCode__new_reg_code',
46
-            implode('-', $this->reg_code),
47
-            $transaction,
48
-            $ticket
49
-        );
50
-    }
51
-
52
-
53
-    /**
54
-     * Return the object as a string
55
-     *
56
-     * @return string
57
-     */
58
-    public function __toString()
59
-    {
60
-        return $this->reg_code;
61
-    }
20
+	private $reg_code;
21
+
22
+
23
+	/**
24
+	 * RegCode constructor.
25
+	 *
26
+	 * @param RegUrlLink      $reg_url_link
27
+	 * @param \EE_Transaction $transaction
28
+	 * @param \EE_Ticket      $ticket
29
+	 */
30
+	public function __construct(
31
+		RegUrlLink $reg_url_link,
32
+		\EE_Transaction $transaction,
33
+		\EE_Ticket $ticket
34
+	) {
35
+		// figure out where to start parsing the reg code
36
+		$chars = strpos($reg_url_link, '-') + 5;
37
+		// TXN_ID + TKT_ID + first 3 and last 3 chars of reg_url_link
38
+		$this->reg_code = array(
39
+			$transaction->ID(),
40
+			$ticket->ID(),
41
+			substr($reg_url_link, 0, $chars),
42
+		);
43
+		// now put it all together
44
+		$this->reg_code = apply_filters(
45
+			'FHEE__Create__regCode__new_reg_code',
46
+			implode('-', $this->reg_code),
47
+			$transaction,
48
+			$ticket
49
+		);
50
+	}
51
+
52
+
53
+	/**
54
+	 * Return the object as a string
55
+	 *
56
+	 * @return string
57
+	 */
58
+	public function __toString()
59
+	{
60
+		return $this->reg_code;
61
+	}
62 62
 }
Please login to merge, or discard this patch.
core/domain/entities/shortcodes/EspressoThankYou.php 2 patches
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -16,71 +16,71 @@
 block discarded – undo
16 16
 class EspressoThankYou extends EspressoShortcode
17 17
 {
18 18
 
19
-    /**
20
-     * @var boolean $is_thank_you_page
21
-     */
22
-    private $is_thank_you_page = false;
19
+	/**
20
+	 * @var boolean $is_thank_you_page
21
+	 */
22
+	private $is_thank_you_page = false;
23 23
 
24
-    /**
25
-     * the actual shortcode tag that gets registered with WordPress
26
-     *
27
-     * @return string
28
-     */
29
-    public function getTag()
30
-    {
31
-        return 'ESPRESSO_THANK_YOU';
32
-    }
24
+	/**
25
+	 * the actual shortcode tag that gets registered with WordPress
26
+	 *
27
+	 * @return string
28
+	 */
29
+	public function getTag()
30
+	{
31
+		return 'ESPRESSO_THANK_YOU';
32
+	}
33 33
 
34 34
 
35
-    /**
36
-     * the time in seconds to cache the results of the processShortcode() method
37
-     * 0 means the processShortcode() results will NOT be cached at all
38
-     *
39
-     * @return int
40
-     */
41
-    public function cacheExpiration()
42
-    {
43
-        return 0;
44
-    }
35
+	/**
36
+	 * the time in seconds to cache the results of the processShortcode() method
37
+	 * 0 means the processShortcode() results will NOT be cached at all
38
+	 *
39
+	 * @return int
40
+	 */
41
+	public function cacheExpiration()
42
+	{
43
+		return 0;
44
+	}
45 45
 
46 46
 
47
-    /**
48
-     * a place for adding any initialization code that needs to run prior to wp_header().
49
-     * this may be required for shortcodes that utilize a corresponding module,
50
-     * and need to enqueue assets for that module
51
-     *
52
-     * @return void
53
-     * @throws \EE_Error
54
-     */
55
-    public function initializeShortcode()
56
-    {
57
-        global $wp_query;
58
-        if (empty($wp_query->posts) || count($wp_query->posts) > 1) {
59
-            return;
60
-        }
61
-        $post = reset($wp_query->posts);
62
-        if (! $post instanceof WP_Post || $post->ID !== EE_Registry::instance()->CFG->core->thank_you_page_id) {
63
-            return;
64
-        }
65
-        $this->is_thank_you_page = true;
66
-        \EED_Thank_You_Page::instance()->load_resources();
67
-        $this->shortcodeHasBeenInitialized();
68
-    }
47
+	/**
48
+	 * a place for adding any initialization code that needs to run prior to wp_header().
49
+	 * this may be required for shortcodes that utilize a corresponding module,
50
+	 * and need to enqueue assets for that module
51
+	 *
52
+	 * @return void
53
+	 * @throws \EE_Error
54
+	 */
55
+	public function initializeShortcode()
56
+	{
57
+		global $wp_query;
58
+		if (empty($wp_query->posts) || count($wp_query->posts) > 1) {
59
+			return;
60
+		}
61
+		$post = reset($wp_query->posts);
62
+		if (! $post instanceof WP_Post || $post->ID !== EE_Registry::instance()->CFG->core->thank_you_page_id) {
63
+			return;
64
+		}
65
+		$this->is_thank_you_page = true;
66
+		\EED_Thank_You_Page::instance()->load_resources();
67
+		$this->shortcodeHasBeenInitialized();
68
+	}
69 69
 
70 70
 
71
-    /**
72
-     * callback that runs when the shortcode is encountered in post content.
73
-     * IMPORTANT !!!
74
-     * remember that shortcode content should be RETURNED and NOT echoed out
75
-     *
76
-     * @param array $attributes
77
-     * @return string
78
-     * @throws \EE_Error
79
-     */
80
-    public function processShortcode($attributes = array())
81
-    {
82
-        return $this->is_thank_you_page
83
-            ? \EED_Thank_You_Page::instance()->thank_you_page_results()
84
-            : '';
85
-    }
71
+	/**
72
+	 * callback that runs when the shortcode is encountered in post content.
73
+	 * IMPORTANT !!!
74
+	 * remember that shortcode content should be RETURNED and NOT echoed out
75
+	 *
76
+	 * @param array $attributes
77
+	 * @return string
78
+	 * @throws \EE_Error
79
+	 */
80
+	public function processShortcode($attributes = array())
81
+	{
82
+		return $this->is_thank_you_page
83
+			? \EED_Thank_You_Page::instance()->thank_you_page_results()
84
+			: '';
85
+	}
86 86
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@
 block discarded – undo
59 59
             return;
60 60
         }
61 61
         $post = reset($wp_query->posts);
62
-        if (! $post instanceof WP_Post || $post->ID !== EE_Registry::instance()->CFG->core->thank_you_page_id) {
62
+        if ( ! $post instanceof WP_Post || $post->ID !== EE_Registry::instance()->CFG->core->thank_you_page_id) {
63 63
             return;
64 64
         }
65 65
         $this->is_thank_you_page = true;
Please login to merge, or discard this patch.