Completed
Branch models-cleanup/model-relations (db5ca7)
by
unknown
13:03 queued 08:35
created
core/services/container/CoffeeMakerInterface.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -11,31 +11,31 @@
 block discarded – undo
11 11
 interface CoffeeMakerInterface
12 12
 {
13 13
 
14
-    /**
15
-     * @return array
16
-     */
17
-    public static function getTypes();
14
+	/**
15
+	 * @return array
16
+	 */
17
+	public static function getTypes();
18 18
 
19 19
 
20 20
 
21
-    /**
22
-     * @param $type
23
-     */
24
-    public static function validateType($type);
21
+	/**
22
+	 * @param $type
23
+	 */
24
+	public static function validateType($type);
25 25
 
26 26
 
27 27
 
28
-    /**
29
-     * @param RecipeInterface $recipe
30
-     * @param array           $arguments
31
-     * @return mixed
32
-     */
33
-    public function brew(RecipeInterface $recipe, $arguments = array());
28
+	/**
29
+	 * @param RecipeInterface $recipe
30
+	 * @param array           $arguments
31
+	 * @return mixed
32
+	 */
33
+	public function brew(RecipeInterface $recipe, $arguments = array());
34 34
 
35 35
 
36 36
 
37
-    /**
38
-     * @return string
39
-     */
40
-    public function type();
37
+	/**
38
+	 * @return string
39
+	 */
40
+	public function type();
41 41
 }
Please login to merge, or discard this patch.
core/services/helpers/datetime/PhpCompatLessFiveSixHelper.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@
 block discarded – undo
59 59
         // although we don't know the TZ abbreviation, we know the UTC offset
60 60
         $timezone_string = timezone_name_from_abbr(null, $gmt_offset);
61 61
         // only use this timezone_string IF it's current offset matches the given offset
62
-        if (! empty($timezone_string)) {
62
+        if ( ! empty($timezone_string)) {
63 63
             $offset = null;
64 64
             try {
65 65
                 $offset = $this->getTimezoneOffset(new DateTimeZone($timezone_string));
Please login to merge, or discard this patch.
Indentation   +213 added lines, -213 removed lines patch added patch discarded remove patch
@@ -19,222 +19,222 @@
 block discarded – undo
19 19
 class PhpCompatLessFiveSixHelper extends AbstractHelper
20 20
 {
21 21
 
22
-    /**
23
-     * PhpCompatLessFiveSixHelper constructor.
24
-     *
25
-     * @throws DomainException
26
-     */
27
-    public function __construct()
28
-    {
29
-        if (PHP_VERSION_ID >= 50600) {
30
-            throw new DomainException(
31
-                sprintf(
32
-                    esc_html__(
33
-                        'The %1$s is only usable on php versions less than 5.6.  You\'ll want to use %2$s instead.',
34
-                        'event_espresso'
35
-                    ),
36
-                    __CLASS__,
37
-                    'EventEspresso\core\services\helpers\datetime\PhpCompatGreaterFiveSixHelper'
38
-                )
39
-            );
40
-        }
41
-        parent::__construct();
42
-    }
22
+	/**
23
+	 * PhpCompatLessFiveSixHelper constructor.
24
+	 *
25
+	 * @throws DomainException
26
+	 */
27
+	public function __construct()
28
+	{
29
+		if (PHP_VERSION_ID >= 50600) {
30
+			throw new DomainException(
31
+				sprintf(
32
+					esc_html__(
33
+						'The %1$s is only usable on php versions less than 5.6.  You\'ll want to use %2$s instead.',
34
+						'event_espresso'
35
+					),
36
+					__CLASS__,
37
+					'EventEspresso\core\services\helpers\datetime\PhpCompatGreaterFiveSixHelper'
38
+				)
39
+			);
40
+		}
41
+		parent::__construct();
42
+	}
43 43
 
44
-    /**
45
-     * Returns a timezone string for the provided gmt_offset.
46
-     *
47
-     * @param float|string $gmt_offset
48
-     * @return string
49
-     * @throws EE_Error
50
-     */
51
-    public function getTimezoneStringFromGmtOffset($gmt_offset = '')
52
-    {
53
-        $gmt_offset_or_timezone_string = $this->sanitizeInitialIncomingGmtOffsetForGettingTimezoneString($gmt_offset);
54
-        if (is_string($gmt_offset_or_timezone_string)) {
55
-            return $gmt_offset_or_timezone_string;
56
-        }
57
-        // well we know its a float, so let's roll with it.
58
-        $gmt_offset = $gmt_offset_or_timezone_string;
59
-        // convert GMT offset to seconds
60
-        $gmt_offset *= HOUR_IN_SECONDS;
61
-        // although we don't know the TZ abbreviation, we know the UTC offset
62
-        $timezone_string = timezone_name_from_abbr(null, $gmt_offset);
63
-        // only use this timezone_string IF it's current offset matches the given offset
64
-        if (! empty($timezone_string)) {
65
-            $offset = null;
66
-            try {
67
-                $offset = $this->getTimezoneOffset(new DateTimeZone($timezone_string));
68
-                if ($offset !== $gmt_offset) {
69
-                    $timezone_string = false;
70
-                }
71
-            } catch (Exception $e) {
72
-                $timezone_string = false;
73
-            }
74
-        }
75
-        // better have a valid timezone string by now, but if not, sigh... loop thru  the timezone_abbreviations_list()
76
-        // ...
77
-        $timezone_string = $timezone_string !== false
78
-            ? $timezone_string
79
-            : $this->getTimezoneStringFromAbbreviationsList($gmt_offset);
80
-        return $timezone_string;
81
-    }
44
+	/**
45
+	 * Returns a timezone string for the provided gmt_offset.
46
+	 *
47
+	 * @param float|string $gmt_offset
48
+	 * @return string
49
+	 * @throws EE_Error
50
+	 */
51
+	public function getTimezoneStringFromGmtOffset($gmt_offset = '')
52
+	{
53
+		$gmt_offset_or_timezone_string = $this->sanitizeInitialIncomingGmtOffsetForGettingTimezoneString($gmt_offset);
54
+		if (is_string($gmt_offset_or_timezone_string)) {
55
+			return $gmt_offset_or_timezone_string;
56
+		}
57
+		// well we know its a float, so let's roll with it.
58
+		$gmt_offset = $gmt_offset_or_timezone_string;
59
+		// convert GMT offset to seconds
60
+		$gmt_offset *= HOUR_IN_SECONDS;
61
+		// although we don't know the TZ abbreviation, we know the UTC offset
62
+		$timezone_string = timezone_name_from_abbr(null, $gmt_offset);
63
+		// only use this timezone_string IF it's current offset matches the given offset
64
+		if (! empty($timezone_string)) {
65
+			$offset = null;
66
+			try {
67
+				$offset = $this->getTimezoneOffset(new DateTimeZone($timezone_string));
68
+				if ($offset !== $gmt_offset) {
69
+					$timezone_string = false;
70
+				}
71
+			} catch (Exception $e) {
72
+				$timezone_string = false;
73
+			}
74
+		}
75
+		// better have a valid timezone string by now, but if not, sigh... loop thru  the timezone_abbreviations_list()
76
+		// ...
77
+		$timezone_string = $timezone_string !== false
78
+			? $timezone_string
79
+			: $this->getTimezoneStringFromAbbreviationsList($gmt_offset);
80
+		return $timezone_string;
81
+	}
82 82
 
83 83
 
84
-    /**
85
-     * @param int  $gmt_offset
86
-     * @param bool $coerce If true, we attempt to coerce with our adjustment table
87
-     * @see self::adjustInvalidGmtOffset
88
-     * @return string
89
-     * @throws EE_Error
90
-     */
91
-    protected function getTimezoneStringFromAbbreviationsList($gmt_offset = 0, $coerce = true)
92
-    {
93
-        $gmt_offset = (int) $gmt_offset;
94
-        /** @var array[] $abbreviations */
95
-        $abbreviations = DateTimeZone::listAbbreviations();
96
-        foreach ($abbreviations as $abbreviation) {
97
-            foreach ($abbreviation as $timezone) {
98
-                if ((int) $timezone['offset'] === $gmt_offset && (bool) $timezone['dst'] === false) {
99
-                    try {
100
-                        $offset = $this->getTimezoneOffset(new DateTimeZone($timezone['timezone_id']));
101
-                        if ($offset !== $gmt_offset) {
102
-                            continue;
103
-                        }
104
-                        return $timezone['timezone_id'];
105
-                    } catch (Exception $e) {
106
-                        continue;
107
-                    }
108
-                }
109
-            }
110
-        }
111
-        // if $coerce is true, let's see if we can get a timezone string after the offset is adjusted
112
-        if ($coerce === true) {
113
-            $timezone_string = $this->getTimezoneStringFromAbbreviationsList(
114
-                $this->adjustInvalidGmtOffsets($gmt_offset),
115
-                false
116
-            );
117
-            if ($timezone_string) {
118
-                return $timezone_string;
119
-            }
120
-        }
121
-        throw new EE_Error(
122
-            sprintf(
123
-                esc_html__(
124
-                    'The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used',
125
-                    'event_espresso'
126
-                ),
127
-                $gmt_offset / HOUR_IN_SECONDS,
128
-                '<a href="http://www.php.net/manual/en/timezones.php">',
129
-                '</a>'
130
-            )
131
-        );
132
-    }
84
+	/**
85
+	 * @param int  $gmt_offset
86
+	 * @param bool $coerce If true, we attempt to coerce with our adjustment table
87
+	 * @see self::adjustInvalidGmtOffset
88
+	 * @return string
89
+	 * @throws EE_Error
90
+	 */
91
+	protected function getTimezoneStringFromAbbreviationsList($gmt_offset = 0, $coerce = true)
92
+	{
93
+		$gmt_offset = (int) $gmt_offset;
94
+		/** @var array[] $abbreviations */
95
+		$abbreviations = DateTimeZone::listAbbreviations();
96
+		foreach ($abbreviations as $abbreviation) {
97
+			foreach ($abbreviation as $timezone) {
98
+				if ((int) $timezone['offset'] === $gmt_offset && (bool) $timezone['dst'] === false) {
99
+					try {
100
+						$offset = $this->getTimezoneOffset(new DateTimeZone($timezone['timezone_id']));
101
+						if ($offset !== $gmt_offset) {
102
+							continue;
103
+						}
104
+						return $timezone['timezone_id'];
105
+					} catch (Exception $e) {
106
+						continue;
107
+					}
108
+				}
109
+			}
110
+		}
111
+		// if $coerce is true, let's see if we can get a timezone string after the offset is adjusted
112
+		if ($coerce === true) {
113
+			$timezone_string = $this->getTimezoneStringFromAbbreviationsList(
114
+				$this->adjustInvalidGmtOffsets($gmt_offset),
115
+				false
116
+			);
117
+			if ($timezone_string) {
118
+				return $timezone_string;
119
+			}
120
+		}
121
+		throw new EE_Error(
122
+			sprintf(
123
+				esc_html__(
124
+					'The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used',
125
+					'event_espresso'
126
+				),
127
+				$gmt_offset / HOUR_IN_SECONDS,
128
+				'<a href="http://www.php.net/manual/en/timezones.php">',
129
+				'</a>'
130
+			)
131
+		);
132
+	}
133 133
 
134 134
 
135
-    /**
136
-     * Depending on PHP version,
137
-     * there might not be valid current timezone strings to match these gmt_offsets in its timezone tables.
138
-     * To get around that, for these fringe timezones we bump them to a known valid offset.
139
-     * This method should ONLY be called after first verifying an timezone_string cannot be retrieved for the offset.
140
-     *
141
-     * @param int $gmt_offset
142
-     * @return int
143
-     */
144
-    public function adjustInvalidGmtOffsets($gmt_offset = 0)
145
-    {
146
-        // make sure $gmt_offset is int
147
-        $gmt_offset = (int) $gmt_offset;
148
-        switch ($gmt_offset) {
149
-            // -12
150
-            case -43200:
151
-                $gmt_offset = -39600;
152
-                break;
153
-            // -11.5
154
-            case -41400:
155
-                $gmt_offset = -39600;
156
-                break;
157
-            // -10.5
158
-            case -37800:
159
-                $gmt_offset = -39600;
160
-                break;
161
-            // -8.5
162
-            case -30600:
163
-                $gmt_offset = -28800;
164
-                break;
165
-            // -7.5
166
-            case -27000:
167
-                $gmt_offset = -25200;
168
-                break;
169
-            // -6.5
170
-            case -23400:
171
-                $gmt_offset = -21600;
172
-                break;
173
-            // -5.5
174
-            case -19800:
175
-                $gmt_offset = -18000;
176
-                break;
177
-            // -4.5
178
-            case -16200:
179
-                $gmt_offset = -14400;
180
-                break;
181
-            // -3.5
182
-            case -12600:
183
-                $gmt_offset = -10800;
184
-                break;
185
-            // -2.5
186
-            case -9000:
187
-                $gmt_offset = -7200;
188
-                break;
189
-            // -1.5
190
-            case -5400:
191
-                $gmt_offset = -3600;
192
-                break;
193
-            // -0.5
194
-            case -1800:
195
-                $gmt_offset = 0;
196
-                break;
197
-            // .5
198
-            case 1800:
199
-                $gmt_offset = 3600;
200
-                break;
201
-            // 1.5
202
-            case 5400:
203
-                $gmt_offset = 7200;
204
-                break;
205
-            // 2.5
206
-            case 9000:
207
-                $gmt_offset = 10800;
208
-                break;
209
-            // 3.5
210
-            case 12600:
211
-                $gmt_offset = 14400;
212
-                break;
213
-            // 7.5
214
-            case 27000:
215
-                $gmt_offset = 28800;
216
-                break;
217
-            // 8.5
218
-            case 30600:
219
-                $gmt_offset = 31500;
220
-                break;
221
-            // 10.5
222
-            case 37800:
223
-                $gmt_offset = 39600;
224
-                break;
225
-            // 11.5
226
-            case 41400:
227
-                $gmt_offset = 43200;
228
-                break;
229
-            // 12.75
230
-            case 45900:
231
-                $gmt_offset = 46800;
232
-                break;
233
-            // 13.75
234
-            case 49500:
235
-                $gmt_offset = 50400;
236
-                break;
237
-        }
238
-        return $gmt_offset;
239
-    }
135
+	/**
136
+	 * Depending on PHP version,
137
+	 * there might not be valid current timezone strings to match these gmt_offsets in its timezone tables.
138
+	 * To get around that, for these fringe timezones we bump them to a known valid offset.
139
+	 * This method should ONLY be called after first verifying an timezone_string cannot be retrieved for the offset.
140
+	 *
141
+	 * @param int $gmt_offset
142
+	 * @return int
143
+	 */
144
+	public function adjustInvalidGmtOffsets($gmt_offset = 0)
145
+	{
146
+		// make sure $gmt_offset is int
147
+		$gmt_offset = (int) $gmt_offset;
148
+		switch ($gmt_offset) {
149
+			// -12
150
+			case -43200:
151
+				$gmt_offset = -39600;
152
+				break;
153
+			// -11.5
154
+			case -41400:
155
+				$gmt_offset = -39600;
156
+				break;
157
+			// -10.5
158
+			case -37800:
159
+				$gmt_offset = -39600;
160
+				break;
161
+			// -8.5
162
+			case -30600:
163
+				$gmt_offset = -28800;
164
+				break;
165
+			// -7.5
166
+			case -27000:
167
+				$gmt_offset = -25200;
168
+				break;
169
+			// -6.5
170
+			case -23400:
171
+				$gmt_offset = -21600;
172
+				break;
173
+			// -5.5
174
+			case -19800:
175
+				$gmt_offset = -18000;
176
+				break;
177
+			// -4.5
178
+			case -16200:
179
+				$gmt_offset = -14400;
180
+				break;
181
+			// -3.5
182
+			case -12600:
183
+				$gmt_offset = -10800;
184
+				break;
185
+			// -2.5
186
+			case -9000:
187
+				$gmt_offset = -7200;
188
+				break;
189
+			// -1.5
190
+			case -5400:
191
+				$gmt_offset = -3600;
192
+				break;
193
+			// -0.5
194
+			case -1800:
195
+				$gmt_offset = 0;
196
+				break;
197
+			// .5
198
+			case 1800:
199
+				$gmt_offset = 3600;
200
+				break;
201
+			// 1.5
202
+			case 5400:
203
+				$gmt_offset = 7200;
204
+				break;
205
+			// 2.5
206
+			case 9000:
207
+				$gmt_offset = 10800;
208
+				break;
209
+			// 3.5
210
+			case 12600:
211
+				$gmt_offset = 14400;
212
+				break;
213
+			// 7.5
214
+			case 27000:
215
+				$gmt_offset = 28800;
216
+				break;
217
+			// 8.5
218
+			case 30600:
219
+				$gmt_offset = 31500;
220
+				break;
221
+			// 10.5
222
+			case 37800:
223
+				$gmt_offset = 39600;
224
+				break;
225
+			// 11.5
226
+			case 41400:
227
+				$gmt_offset = 43200;
228
+				break;
229
+			// 12.75
230
+			case 45900:
231
+				$gmt_offset = 46800;
232
+				break;
233
+			// 13.75
234
+			case 49500:
235
+				$gmt_offset = 50400;
236
+				break;
237
+		}
238
+		return $gmt_offset;
239
+	}
240 240
 }
Please login to merge, or discard this patch.
core/services/helpers/datetime/PhpCompatGreaterFiveSixHelper.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         }
64 64
         $gmt_offset = $this->convertToTimeFraction($gmt_offset);
65 65
         // return something like -1300, -0200 or +1300, +0200
66
-        return $is_negative ? '-' . $gmt_offset : '+' . $gmt_offset;
66
+        return $is_negative ? '-'.$gmt_offset : '+'.$gmt_offset;
67 67
     }
68 68
 
69 69
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
         $first_part = substr($offset, 0, 2);
79 79
         $second_part = substr($offset, 2, 2);
80 80
         $second_part = str_replace(array('25', '50', '75'), array('15', '30', '45'), $second_part);
81
-        return $first_part . $second_part;
81
+        return $first_part.$second_part;
82 82
     }
83 83
 
84 84
 
@@ -93,6 +93,6 @@  discard block
 block discarded – undo
93 93
     {
94 94
         $time = is_int($time) || $time === null ? $time : (int) strtotime($time);
95 95
         $time = preg_match(EE_Datetime_Field::unix_timestamp_regex, $time) ? $time : time();
96
-        return $date_time_zone->getOffset(new DateTime('@' . $time));
96
+        return $date_time_zone->getOffset(new DateTime('@'.$time));
97 97
     }
98 98
 }
Please login to merge, or discard this patch.
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -9,92 +9,92 @@
 block discarded – undo
9 9
 
10 10
 class PhpCompatGreaterFiveSixHelper extends AbstractHelper
11 11
 {
12
-    /**
13
-     * PhpCompatLessFiveSixHelper constructor.
14
-     *
15
-     * @throws DomainException
16
-     */
17
-    public function __construct()
18
-    {
19
-        if (PHP_VERSION_ID < 50600) {
20
-            throw new DomainException(
21
-                sprintf(
22
-                    esc_html__(
23
-                        'The %1$s is only usable on php versions greater than 5.6.  You\'ll want to use %2$s instead.',
24
-                        'event_espresso'
25
-                    ),
26
-                    __CLASS__,
27
-                    'EventEspresso\core\services\helpers\datetime\PhpCompatLessFiveSixHelper'
28
-                )
29
-            );
30
-        }
31
-        parent::__construct();
32
-    }
12
+	/**
13
+	 * PhpCompatLessFiveSixHelper constructor.
14
+	 *
15
+	 * @throws DomainException
16
+	 */
17
+	public function __construct()
18
+	{
19
+		if (PHP_VERSION_ID < 50600) {
20
+			throw new DomainException(
21
+				sprintf(
22
+					esc_html__(
23
+						'The %1$s is only usable on php versions greater than 5.6.  You\'ll want to use %2$s instead.',
24
+						'event_espresso'
25
+					),
26
+					__CLASS__,
27
+					'EventEspresso\core\services\helpers\datetime\PhpCompatLessFiveSixHelper'
28
+				)
29
+			);
30
+		}
31
+		parent::__construct();
32
+	}
33 33
 
34
-    /**
35
-     * Returns a timezone string for the provided gmt_offset.
36
-     * This is a valid timezone string that can be sent into DateTimeZone
37
-     *
38
-     * @param float|string $gmt_offset
39
-     * @return string
40
-     */
41
-    public function getTimezoneStringFromGmtOffset($gmt_offset = '')
42
-    {
43
-        $gmt_offset_or_timezone_string = $this->sanitizeInitialIncomingGmtOffsetForGettingTimezoneString($gmt_offset);
44
-        return is_float($gmt_offset_or_timezone_string)
45
-            ? $this->convertWpGmtOffsetForDateTimeZone($gmt_offset_or_timezone_string)
46
-            : $gmt_offset_or_timezone_string;
47
-    }
34
+	/**
35
+	 * Returns a timezone string for the provided gmt_offset.
36
+	 * This is a valid timezone string that can be sent into DateTimeZone
37
+	 *
38
+	 * @param float|string $gmt_offset
39
+	 * @return string
40
+	 */
41
+	public function getTimezoneStringFromGmtOffset($gmt_offset = '')
42
+	{
43
+		$gmt_offset_or_timezone_string = $this->sanitizeInitialIncomingGmtOffsetForGettingTimezoneString($gmt_offset);
44
+		return is_float($gmt_offset_or_timezone_string)
45
+			? $this->convertWpGmtOffsetForDateTimeZone($gmt_offset_or_timezone_string)
46
+			: $gmt_offset_or_timezone_string;
47
+	}
48 48
 
49 49
 
50 50
 
51
-    /**
52
-     * Returns a formatted offset for use as an argument for constructing DateTimeZone
53
-     * @param float $gmt_offset This should be a float representing the gmt_offset.
54
-     * @return string
55
-     */
56
-    protected function convertWpGmtOffsetForDateTimeZone($gmt_offset)
57
-    {
58
-        $gmt_offset = (float) $gmt_offset;
59
-        $is_negative = $gmt_offset < 0;
60
-        $gmt_offset *= 100;
61
-        $gmt_offset = absint($gmt_offset);
62
-        // negative and need zero padding?
63
-        if (strlen($gmt_offset) < 4) {
64
-            $gmt_offset = str_pad($gmt_offset, 4, '0', STR_PAD_LEFT);
65
-        }
66
-        $gmt_offset = $this->convertToTimeFraction($gmt_offset);
67
-        // return something like -1300, -0200 or +1300, +0200
68
-        return $is_negative ? '-' . $gmt_offset : '+' . $gmt_offset;
69
-    }
51
+	/**
52
+	 * Returns a formatted offset for use as an argument for constructing DateTimeZone
53
+	 * @param float $gmt_offset This should be a float representing the gmt_offset.
54
+	 * @return string
55
+	 */
56
+	protected function convertWpGmtOffsetForDateTimeZone($gmt_offset)
57
+	{
58
+		$gmt_offset = (float) $gmt_offset;
59
+		$is_negative = $gmt_offset < 0;
60
+		$gmt_offset *= 100;
61
+		$gmt_offset = absint($gmt_offset);
62
+		// negative and need zero padding?
63
+		if (strlen($gmt_offset) < 4) {
64
+			$gmt_offset = str_pad($gmt_offset, 4, '0', STR_PAD_LEFT);
65
+		}
66
+		$gmt_offset = $this->convertToTimeFraction($gmt_offset);
67
+		// return something like -1300, -0200 or +1300, +0200
68
+		return $is_negative ? '-' . $gmt_offset : '+' . $gmt_offset;
69
+	}
70 70
 
71 71
 
72
-    /**
73
-     * Converts something like `1550` to `1530` or `0275` to `0245`
74
-     * Incoming offset should be a positive value, this will mutate negative values. Be aware!
75
-     * @param int $offset
76
-     * @return mixed
77
-     */
78
-    protected function convertToTimeFraction($offset)
79
-    {
80
-        $first_part = substr($offset, 0, 2);
81
-        $second_part = substr($offset, 2, 2);
82
-        $second_part = str_replace(array('25', '50', '75'), array('15', '30', '45'), $second_part);
83
-        return $first_part . $second_part;
84
-    }
72
+	/**
73
+	 * Converts something like `1550` to `1530` or `0275` to `0245`
74
+	 * Incoming offset should be a positive value, this will mutate negative values. Be aware!
75
+	 * @param int $offset
76
+	 * @return mixed
77
+	 */
78
+	protected function convertToTimeFraction($offset)
79
+	{
80
+		$first_part = substr($offset, 0, 2);
81
+		$second_part = substr($offset, 2, 2);
82
+		$second_part = str_replace(array('25', '50', '75'), array('15', '30', '45'), $second_part);
83
+		return $first_part . $second_part;
84
+	}
85 85
 
86 86
 
87
-    /**
88
-     * Get Timezone offset for given timezone object
89
-     *
90
-     * @param DateTimeZone $date_time_zone
91
-     * @param null|int     $time
92
-     * @return int
93
-     */
94
-    public function getTimezoneOffset(DateTimezone $date_time_zone, $time = null)
95
-    {
96
-        $time = is_int($time) || $time === null ? $time : (int) strtotime($time);
97
-        $time = preg_match(EE_Datetime_Field::unix_timestamp_regex, $time) ? $time : time();
98
-        return $date_time_zone->getOffset(new DateTime('@' . $time));
99
-    }
87
+	/**
88
+	 * Get Timezone offset for given timezone object
89
+	 *
90
+	 * @param DateTimeZone $date_time_zone
91
+	 * @param null|int     $time
92
+	 * @return int
93
+	 */
94
+	public function getTimezoneOffset(DateTimezone $date_time_zone, $time = null)
95
+	{
96
+		$time = is_int($time) || $time === null ? $time : (int) strtotime($time);
97
+		$time = preg_match(EE_Datetime_Field::unix_timestamp_regex, $time) ? $time : time();
98
+		return $date_time_zone->getOffset(new DateTime('@' . $time));
99
+	}
100 100
 }
Please login to merge, or discard this patch.
core/EE_Load_Espresso_Core.core.php 1 patch
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -27,114 +27,114 @@
 block discarded – undo
27 27
 class EE_Load_Espresso_Core implements RequestDecoratorInterface, RequestStackCoreAppInterface
28 28
 {
29 29
 
30
-    /**
31
-     * @var RequestInterface $request
32
-     */
33
-    protected $request;
34
-
35
-    /**
36
-     * @var ResponseInterface $response
37
-     */
38
-    protected $response;
39
-
40
-    /**
41
-     * @var EE_Dependency_Map $dependency_map
42
-     */
43
-    protected $dependency_map;
44
-
45
-    /**
46
-     * @var EE_Registry $registry
47
-     */
48
-    protected $registry;
49
-
50
-
51
-    /**
52
-     * EE_Load_Espresso_Core constructor
53
-     *
54
-     * @param EE_Registry       $registry
55
-     * @param EE_Dependency_Map $dependency_map
56
-     * @throws EE_Error
57
-     */
58
-    public function __construct(EE_Registry $registry, EE_Dependency_Map $dependency_map)
59
-    {
60
-        EE_Error::doing_it_wrong(
61
-            __METHOD__,
62
-            sprintf(
63
-                esc_html__(
64
-                    'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
65
-                    'event_espresso'
66
-                ),
67
-                'EventEspresso\core\services\request\RequestStackCoreApp',
68
-                '\core\services\request',
69
-                'EventEspresso\core\services\request'
70
-            ),
71
-            '4.9.53'
72
-        );
73
-    }
74
-
75
-
76
-    /**
77
-     * handle
78
-     * sets hooks for running rest of system
79
-     * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
80
-     * starting EE Addons from any other point may lead to problems
81
-     *
82
-     * @param RequestInterface  $request
83
-     * @param ResponseInterface $response
84
-     * @return ResponseInterface
85
-     * @throws EE_Error
86
-     * @throws InvalidDataTypeException
87
-     * @throws InvalidInterfaceException
88
-     * @throws InvalidArgumentException
89
-     * @throws DomainException
90
-     */
91
-    public function handleRequest(RequestInterface $request, ResponseInterface $response)
92
-    {
93
-    }
94
-
95
-
96
-    /**
97
-     * @return RequestInterface
98
-     */
99
-    public function request()
100
-    {
101
-    }
102
-
103
-
104
-    /**
105
-     * @return ResponseInterface
106
-     */
107
-    public function response()
108
-    {
109
-    }
110
-
111
-
112
-    /**
113
-     * @return EE_Dependency_Map
114
-     * @throws EE_Error
115
-     */
116
-    public function dependency_map()
117
-    {
118
-    }
119
-
120
-
121
-    /**
122
-     * @return EE_Registry
123
-     * @throws EE_Error
124
-     */
125
-    public function registry()
126
-    {
127
-    }
128
-
129
-
130
-    /**
131
-     * called after the request stack has been fully processed
132
-     * if any of the middleware apps has requested the plugin be deactivated, then we do that now
133
-     *
134
-     * @param RequestInterface  $request
135
-     * @param ResponseInterface $response
136
-     */
137
-    public function handleResponse(RequestInterface $request, ResponseInterface $response)
138
-    {
139
-    }
30
+	/**
31
+	 * @var RequestInterface $request
32
+	 */
33
+	protected $request;
34
+
35
+	/**
36
+	 * @var ResponseInterface $response
37
+	 */
38
+	protected $response;
39
+
40
+	/**
41
+	 * @var EE_Dependency_Map $dependency_map
42
+	 */
43
+	protected $dependency_map;
44
+
45
+	/**
46
+	 * @var EE_Registry $registry
47
+	 */
48
+	protected $registry;
49
+
50
+
51
+	/**
52
+	 * EE_Load_Espresso_Core constructor
53
+	 *
54
+	 * @param EE_Registry       $registry
55
+	 * @param EE_Dependency_Map $dependency_map
56
+	 * @throws EE_Error
57
+	 */
58
+	public function __construct(EE_Registry $registry, EE_Dependency_Map $dependency_map)
59
+	{
60
+		EE_Error::doing_it_wrong(
61
+			__METHOD__,
62
+			sprintf(
63
+				esc_html__(
64
+					'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
65
+					'event_espresso'
66
+				),
67
+				'EventEspresso\core\services\request\RequestStackCoreApp',
68
+				'\core\services\request',
69
+				'EventEspresso\core\services\request'
70
+			),
71
+			'4.9.53'
72
+		);
73
+	}
74
+
75
+
76
+	/**
77
+	 * handle
78
+	 * sets hooks for running rest of system
79
+	 * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
80
+	 * starting EE Addons from any other point may lead to problems
81
+	 *
82
+	 * @param RequestInterface  $request
83
+	 * @param ResponseInterface $response
84
+	 * @return ResponseInterface
85
+	 * @throws EE_Error
86
+	 * @throws InvalidDataTypeException
87
+	 * @throws InvalidInterfaceException
88
+	 * @throws InvalidArgumentException
89
+	 * @throws DomainException
90
+	 */
91
+	public function handleRequest(RequestInterface $request, ResponseInterface $response)
92
+	{
93
+	}
94
+
95
+
96
+	/**
97
+	 * @return RequestInterface
98
+	 */
99
+	public function request()
100
+	{
101
+	}
102
+
103
+
104
+	/**
105
+	 * @return ResponseInterface
106
+	 */
107
+	public function response()
108
+	{
109
+	}
110
+
111
+
112
+	/**
113
+	 * @return EE_Dependency_Map
114
+	 * @throws EE_Error
115
+	 */
116
+	public function dependency_map()
117
+	{
118
+	}
119
+
120
+
121
+	/**
122
+	 * @return EE_Registry
123
+	 * @throws EE_Error
124
+	 */
125
+	public function registry()
126
+	{
127
+	}
128
+
129
+
130
+	/**
131
+	 * called after the request stack has been fully processed
132
+	 * if any of the middleware apps has requested the plugin be deactivated, then we do that now
133
+	 *
134
+	 * @param RequestInterface  $request
135
+	 * @param ResponseInterface $response
136
+	 */
137
+	public function handleResponse(RequestInterface $request, ResponseInterface $response)
138
+	{
139
+	}
140 140
 }
Please login to merge, or discard this patch.
core/EE_Object_Collection.core.php 2 patches
Indentation   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -16,160 +16,160 @@
 block discarded – undo
16 16
 abstract class EE_Object_Collection extends SplObjectStorage implements EEI_Collection
17 17
 {
18 18
 
19
-    /**
20
-     * an interface (or class) name to be used for restricting the type of objects added to the storage
21
-     * this should be set from within the child class constructor
22
-     *
23
-     * @type string $interface
24
-     */
25
-    protected $interface;
26
-
27
-
28
-    /**
29
-     * add
30
-     *
31
-     * attaches an object to the Collection
32
-     * and sets any supplied data associated with the current iterator entry
33
-     * by calling EE_Object_Collection::set_info()
34
-     *
35
-     * @access public
36
-     * @param object $object
37
-     * @param mixed  $info
38
-     * @return bool
39
-     */
40
-    public function add($object, $info = null)
41
-    {
42
-        $class = $this->interface;
43
-        if (! $object instanceof $class) {
44
-            return false;
45
-        }
46
-        $this->attach($object);
47
-        $this->set_info($object, $info);
48
-        return $this->contains($object);
49
-    }
50
-
51
-
52
-    /**
53
-     * set_info
54
-     *
55
-     * Sets the data associated with an object in the Collection
56
-     * if no $info is supplied, then the spl_object_hash() is used
57
-     *
58
-     * @access public
59
-     * @param object $object
60
-     * @param mixed  $info
61
-     * @return bool
62
-     */
63
-    public function set_info($object, $info = null)
64
-    {
65
-        $info = ! empty($info) ? $info : spl_object_hash($object);
66
-        $this->rewind();
67
-        while ($this->valid()) {
68
-            if ($object == $this->current()) {
69
-                $this->setInfo($info);
70
-                $this->rewind();
71
-                return true;
72
-            }
73
-            $this->next();
74
-        }
75
-        return false;
76
-    }
77
-
78
-
79
-    /**
80
-     * get_by_info
81
-     *
82
-     * finds and returns an object in the Collection based on the info that was set using addObject()
83
-     * PLZ NOTE: the pointer is reset to the beginning of the collection before returning
84
-     *
85
-     * @access public
86
-     * @param mixed
87
-     * @return null | object
88
-     */
89
-    public function get_by_info($info)
90
-    {
91
-        $this->rewind();
92
-        while ($this->valid()) {
93
-            if ($info === $this->getInfo()) {
94
-                $object = $this->current();
95
-                $this->rewind();
96
-                return $object;
97
-            }
98
-            $this->next();
99
-        }
100
-        return null;
101
-    }
102
-
103
-
104
-    /**
105
-     * has
106
-     *
107
-     * returns TRUE or FALSE depending on whether the supplied object is within the Collection
108
-     *
109
-     * @access public
110
-     * @param object $object
111
-     * @return bool
112
-     */
113
-    public function has($object)
114
-    {
115
-        return $this->contains($object);
116
-    }
117
-
118
-
119
-    /**
120
-     * remove
121
-     *
122
-     * detaches an object from the Collection
123
-     *
124
-     * @access public
125
-     * @param $object
126
-     * @return bool
127
-     */
128
-    public function remove($object)
129
-    {
130
-        $this->detach($object);
131
-        return true;
132
-    }
133
-
134
-
135
-    /**
136
-     * set_current
137
-     *
138
-     * advances pointer to the provided object
139
-     *
140
-     * @access public
141
-     * @param $object
142
-     * @return void
143
-     */
144
-    public function set_current($object)
145
-    {
146
-        $this->rewind();
147
-        while ($this->valid()) {
148
-            if ($this->current() === $object) {
149
-                break;
150
-            }
151
-            $this->next();
152
-        }
153
-    }
154
-
155
-
156
-    /**
157
-     * set_current_by_info
158
-     *
159
-     * advances pointer to the object whose info matches that which was provided
160
-     *
161
-     * @access public
162
-     * @param $info
163
-     * @return void
164
-     */
165
-    public function set_current_by_info($info)
166
-    {
167
-        $this->rewind();
168
-        while ($this->valid()) {
169
-            if ($info === $this->getInfo()) {
170
-                break;
171
-            }
172
-            $this->next();
173
-        }
174
-    }
19
+	/**
20
+	 * an interface (or class) name to be used for restricting the type of objects added to the storage
21
+	 * this should be set from within the child class constructor
22
+	 *
23
+	 * @type string $interface
24
+	 */
25
+	protected $interface;
26
+
27
+
28
+	/**
29
+	 * add
30
+	 *
31
+	 * attaches an object to the Collection
32
+	 * and sets any supplied data associated with the current iterator entry
33
+	 * by calling EE_Object_Collection::set_info()
34
+	 *
35
+	 * @access public
36
+	 * @param object $object
37
+	 * @param mixed  $info
38
+	 * @return bool
39
+	 */
40
+	public function add($object, $info = null)
41
+	{
42
+		$class = $this->interface;
43
+		if (! $object instanceof $class) {
44
+			return false;
45
+		}
46
+		$this->attach($object);
47
+		$this->set_info($object, $info);
48
+		return $this->contains($object);
49
+	}
50
+
51
+
52
+	/**
53
+	 * set_info
54
+	 *
55
+	 * Sets the data associated with an object in the Collection
56
+	 * if no $info is supplied, then the spl_object_hash() is used
57
+	 *
58
+	 * @access public
59
+	 * @param object $object
60
+	 * @param mixed  $info
61
+	 * @return bool
62
+	 */
63
+	public function set_info($object, $info = null)
64
+	{
65
+		$info = ! empty($info) ? $info : spl_object_hash($object);
66
+		$this->rewind();
67
+		while ($this->valid()) {
68
+			if ($object == $this->current()) {
69
+				$this->setInfo($info);
70
+				$this->rewind();
71
+				return true;
72
+			}
73
+			$this->next();
74
+		}
75
+		return false;
76
+	}
77
+
78
+
79
+	/**
80
+	 * get_by_info
81
+	 *
82
+	 * finds and returns an object in the Collection based on the info that was set using addObject()
83
+	 * PLZ NOTE: the pointer is reset to the beginning of the collection before returning
84
+	 *
85
+	 * @access public
86
+	 * @param mixed
87
+	 * @return null | object
88
+	 */
89
+	public function get_by_info($info)
90
+	{
91
+		$this->rewind();
92
+		while ($this->valid()) {
93
+			if ($info === $this->getInfo()) {
94
+				$object = $this->current();
95
+				$this->rewind();
96
+				return $object;
97
+			}
98
+			$this->next();
99
+		}
100
+		return null;
101
+	}
102
+
103
+
104
+	/**
105
+	 * has
106
+	 *
107
+	 * returns TRUE or FALSE depending on whether the supplied object is within the Collection
108
+	 *
109
+	 * @access public
110
+	 * @param object $object
111
+	 * @return bool
112
+	 */
113
+	public function has($object)
114
+	{
115
+		return $this->contains($object);
116
+	}
117
+
118
+
119
+	/**
120
+	 * remove
121
+	 *
122
+	 * detaches an object from the Collection
123
+	 *
124
+	 * @access public
125
+	 * @param $object
126
+	 * @return bool
127
+	 */
128
+	public function remove($object)
129
+	{
130
+		$this->detach($object);
131
+		return true;
132
+	}
133
+
134
+
135
+	/**
136
+	 * set_current
137
+	 *
138
+	 * advances pointer to the provided object
139
+	 *
140
+	 * @access public
141
+	 * @param $object
142
+	 * @return void
143
+	 */
144
+	public function set_current($object)
145
+	{
146
+		$this->rewind();
147
+		while ($this->valid()) {
148
+			if ($this->current() === $object) {
149
+				break;
150
+			}
151
+			$this->next();
152
+		}
153
+	}
154
+
155
+
156
+	/**
157
+	 * set_current_by_info
158
+	 *
159
+	 * advances pointer to the object whose info matches that which was provided
160
+	 *
161
+	 * @access public
162
+	 * @param $info
163
+	 * @return void
164
+	 */
165
+	public function set_current_by_info($info)
166
+	{
167
+		$this->rewind();
168
+		while ($this->valid()) {
169
+			if ($info === $this->getInfo()) {
170
+				break;
171
+			}
172
+			$this->next();
173
+		}
174
+	}
175 175
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
     public function add($object, $info = null)
41 41
     {
42 42
         $class = $this->interface;
43
-        if (! $object instanceof $class) {
43
+        if ( ! $object instanceof $class) {
44 44
             return false;
45 45
         }
46 46
         $this->attach($object);
Please login to merge, or discard this patch.
core/data_migration_scripts/4_6_0_stages/EE_DMS_4_6_0_payments.dmsstage.php 2 patches
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -11,44 +11,44 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class EE_DMS_4_6_0_payments extends EE_Data_Migration_Script_Stage_Table
13 13
 {
14
-    protected $_payment_method_table;
15
-    public function __construct()
16
-    {
17
-        global $wpdb;
18
-        $this->_old_table = $wpdb->prefix . 'esp_payment';
19
-        $this->_payment_method_table = $wpdb->prefix . 'esp_payment_method';
20
-        $this->_pretty_name = __('Payment-Payment Method Relations', 'event_espresso');
21
-        parent::__construct();
22
-    }
23
-    protected function _migrate_old_row($payment_row)
24
-    {
25
-        global $wpdb;
26
-        // get the payment method's ID
27
-        $PMD_ID = apply_filters('FHEE__EE_DMS_4_6_0_payments__migrate_old_row__PMD_ID', $this->_get_payment_method_id_by_gateway_name($payment_row['PAY_gateway'], $payment_row['PAY_method']));
28
-        if (! $PMD_ID) {
29
-            $this->add_error(sprintf(__('Could not find payment method with PMD_type = \'%1$s\' when migrating payment row %2$s so just assigned it an unknown payment method', 'event_espresso'), $payment_row['PAY_gateway'], $this->_json_encode($payment_row)));
30
-            $PMD_ID = 0;
31
-        }
32
-        $new_values = array(
33
-            'PMD_ID' => $PMD_ID,
34
-            'PAY_source' => ( $payment_row['PAY_via_admin'] ? 'ADMIN' : 'CART' ) );
35
-        $wheres = array( 'PAY_ID' => $payment_row['PAY_ID'] );
36
-        $new_value_datatypes = array( '%d', '%s' );
37
-        $where_datatypes = array( '%d' );
38
-        $success = $wpdb->update(
39
-            $this->_old_table,
40
-            $new_values,
41
-            $wheres,
42
-            $new_value_datatypes,
43
-            $where_datatypes
44
-        );
45
-        if (! $success) {
46
-            $this->add_error(sprintf(__('Couldnt set %1$s row in table %2$s where %3$s', 'event_espresso'), $this->_json_encode($new_values), $this->_old_table, $this->_json_encode($wheres)));
47
-        }
48
-    }
49
-    /**
50
-     *
51
-     *  array(
14
+	protected $_payment_method_table;
15
+	public function __construct()
16
+	{
17
+		global $wpdb;
18
+		$this->_old_table = $wpdb->prefix . 'esp_payment';
19
+		$this->_payment_method_table = $wpdb->prefix . 'esp_payment_method';
20
+		$this->_pretty_name = __('Payment-Payment Method Relations', 'event_espresso');
21
+		parent::__construct();
22
+	}
23
+	protected function _migrate_old_row($payment_row)
24
+	{
25
+		global $wpdb;
26
+		// get the payment method's ID
27
+		$PMD_ID = apply_filters('FHEE__EE_DMS_4_6_0_payments__migrate_old_row__PMD_ID', $this->_get_payment_method_id_by_gateway_name($payment_row['PAY_gateway'], $payment_row['PAY_method']));
28
+		if (! $PMD_ID) {
29
+			$this->add_error(sprintf(__('Could not find payment method with PMD_type = \'%1$s\' when migrating payment row %2$s so just assigned it an unknown payment method', 'event_espresso'), $payment_row['PAY_gateway'], $this->_json_encode($payment_row)));
30
+			$PMD_ID = 0;
31
+		}
32
+		$new_values = array(
33
+			'PMD_ID' => $PMD_ID,
34
+			'PAY_source' => ( $payment_row['PAY_via_admin'] ? 'ADMIN' : 'CART' ) );
35
+		$wheres = array( 'PAY_ID' => $payment_row['PAY_ID'] );
36
+		$new_value_datatypes = array( '%d', '%s' );
37
+		$where_datatypes = array( '%d' );
38
+		$success = $wpdb->update(
39
+			$this->_old_table,
40
+			$new_values,
41
+			$wheres,
42
+			$new_value_datatypes,
43
+			$where_datatypes
44
+		);
45
+		if (! $success) {
46
+			$this->add_error(sprintf(__('Couldnt set %1$s row in table %2$s where %3$s', 'event_espresso'), $this->_json_encode($new_values), $this->_old_table, $this->_json_encode($wheres)));
47
+		}
48
+	}
49
+	/**
50
+	 *
51
+	 *  array(
52 52
             'PP' => __( 'PayPal', 'event_espresso' ),
53 53
             'CC' => __( 'Credit Card', 'event_espresso' ),
54 54
             'DB'=>  __("Debit Card", 'event_espresso'),
@@ -57,44 +57,44 @@  discard block
 block discarded – undo
57 57
             'BK'=>  __("Bank", 'event_espresso'),
58 58
             'IV'=>  __("Invoice", 'event_espresso'),
59 59
             'MO'=>  __("Money Order", 'event_espresso'),
60
-     * @global type $wpdb
61
-     * @param int $id
62
-     * @return string
63
-     */
64
-    protected function _get_payment_method_id_by_gateway_name($gateway_name, $old_pay_method_column)
65
-    {
66
-        global $wpdb;
67
-        // convert from old known PAY_method values to their corresponding
68
-        // PMD_type or default PMD_name
69
-        switch ($old_pay_method_column) {
70
-            case 'PP':
71
-                $pmd_type = 'Paypal_Standard';
72
-                break;
73
-            case 'CC':
74
-                $pmd_type = 'Credit_Card';
75
-                break;
76
-            case 'DB':
77
-                $pmd_type = 'Debit_Card';
78
-                break;
79
-            case 'CHQ':
80
-                $pmd_type = 'Check';
81
-                break;
82
-            case 'CSH':
83
-                $pmd_type = 'Cash';
84
-                break;
85
-            case 'BK':
86
-                $pmd_type = 'Bank';
87
-                break;
88
-            case 'IV':
89
-                $pmd_type = 'Invoice';
90
-                break;
91
-            case 'MO':
92
-                $pmd_type = 'Money_Order';
93
-                break;
94
-            default:
95
-                $pmd_type = $gateway_name;
96
-        }
97
-        $pmd_name = str_replace("_", " ", $pmd_type);
98
-        return $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM " . $wpdb->prefix . "esp_payment_method WHERE PMD_type = %s OR PMD_name = %s", $pmd_type, $pmd_name));
99
-    }
60
+	 * @global type $wpdb
61
+	 * @param int $id
62
+	 * @return string
63
+	 */
64
+	protected function _get_payment_method_id_by_gateway_name($gateway_name, $old_pay_method_column)
65
+	{
66
+		global $wpdb;
67
+		// convert from old known PAY_method values to their corresponding
68
+		// PMD_type or default PMD_name
69
+		switch ($old_pay_method_column) {
70
+			case 'PP':
71
+				$pmd_type = 'Paypal_Standard';
72
+				break;
73
+			case 'CC':
74
+				$pmd_type = 'Credit_Card';
75
+				break;
76
+			case 'DB':
77
+				$pmd_type = 'Debit_Card';
78
+				break;
79
+			case 'CHQ':
80
+				$pmd_type = 'Check';
81
+				break;
82
+			case 'CSH':
83
+				$pmd_type = 'Cash';
84
+				break;
85
+			case 'BK':
86
+				$pmd_type = 'Bank';
87
+				break;
88
+			case 'IV':
89
+				$pmd_type = 'Invoice';
90
+				break;
91
+			case 'MO':
92
+				$pmd_type = 'Money_Order';
93
+				break;
94
+			default:
95
+				$pmd_type = $gateway_name;
96
+		}
97
+		$pmd_name = str_replace("_", " ", $pmd_type);
98
+		return $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM " . $wpdb->prefix . "esp_payment_method WHERE PMD_type = %s OR PMD_name = %s", $pmd_type, $pmd_name));
99
+	}
100 100
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
     public function __construct()
16 16
     {
17 17
         global $wpdb;
18
-        $this->_old_table = $wpdb->prefix . 'esp_payment';
19
-        $this->_payment_method_table = $wpdb->prefix . 'esp_payment_method';
18
+        $this->_old_table = $wpdb->prefix.'esp_payment';
19
+        $this->_payment_method_table = $wpdb->prefix.'esp_payment_method';
20 20
         $this->_pretty_name = __('Payment-Payment Method Relations', 'event_espresso');
21 21
         parent::__construct();
22 22
     }
@@ -25,16 +25,16 @@  discard block
 block discarded – undo
25 25
         global $wpdb;
26 26
         // get the payment method's ID
27 27
         $PMD_ID = apply_filters('FHEE__EE_DMS_4_6_0_payments__migrate_old_row__PMD_ID', $this->_get_payment_method_id_by_gateway_name($payment_row['PAY_gateway'], $payment_row['PAY_method']));
28
-        if (! $PMD_ID) {
28
+        if ( ! $PMD_ID) {
29 29
             $this->add_error(sprintf(__('Could not find payment method with PMD_type = \'%1$s\' when migrating payment row %2$s so just assigned it an unknown payment method', 'event_espresso'), $payment_row['PAY_gateway'], $this->_json_encode($payment_row)));
30 30
             $PMD_ID = 0;
31 31
         }
32 32
         $new_values = array(
33 33
             'PMD_ID' => $PMD_ID,
34
-            'PAY_source' => ( $payment_row['PAY_via_admin'] ? 'ADMIN' : 'CART' ) );
35
-        $wheres = array( 'PAY_ID' => $payment_row['PAY_ID'] );
36
-        $new_value_datatypes = array( '%d', '%s' );
37
-        $where_datatypes = array( '%d' );
34
+            'PAY_source' => ($payment_row['PAY_via_admin'] ? 'ADMIN' : 'CART') );
35
+        $wheres = array('PAY_ID' => $payment_row['PAY_ID']);
36
+        $new_value_datatypes = array('%d', '%s');
37
+        $where_datatypes = array('%d');
38 38
         $success = $wpdb->update(
39 39
             $this->_old_table,
40 40
             $new_values,
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
             $new_value_datatypes,
43 43
             $where_datatypes
44 44
         );
45
-        if (! $success) {
45
+        if ( ! $success) {
46 46
             $this->add_error(sprintf(__('Couldnt set %1$s row in table %2$s where %3$s', 'event_espresso'), $this->_json_encode($new_values), $this->_old_table, $this->_json_encode($wheres)));
47 47
         }
48 48
     }
@@ -95,6 +95,6 @@  discard block
 block discarded – undo
95 95
                 $pmd_type = $gateway_name;
96 96
         }
97 97
         $pmd_name = str_replace("_", " ", $pmd_type);
98
-        return $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM " . $wpdb->prefix . "esp_payment_method WHERE PMD_type = %s OR PMD_name = %s", $pmd_type, $pmd_name));
98
+        return $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM ".$wpdb->prefix."esp_payment_method WHERE PMD_type = %s OR PMD_name = %s", $pmd_type, $pmd_name));
99 99
     }
100 100
 }
Please login to merge, or discard this patch.
data_migration_scripts/4_6_0_stages/EE_DMS_4_6_0_transactions.dmsstage.php 2 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -11,51 +11,51 @@
 block discarded – undo
11 11
  */
12 12
 class EE_DMS_4_6_0_transactions extends EE_Data_Migration_Script_Stage_Table
13 13
 {
14
-    protected $_transaction_table;
15
-    protected $_payment_method_table;
16
-    public function __construct()
17
-    {
18
-        global $wpdb;
19
-        $this->_old_table = $wpdb->prefix . 'esp_extra_meta';
20
-        $this->_transaction_table = $wpdb->prefix . 'esp_transaction';
21
-        $this->_payment_method_table = $wpdb->prefix . 'esp_payment_method';
22
-        $this->_pretty_name = __('Transaction Payment Method Relations', 'event_espresso');
23
-        $this->_extra_where_sql = "WHERE EXM_key = 'gateway' AND EXM_type = 'Transaction'";
24
-        parent::__construct();
25
-    }
26
-    protected function _migrate_old_row($extra_meta_row)
27
-    {
28
-        global $wpdb;
29
-        // get the payment method's ID
30
-        $PMD_ID = $this->_get_payment_method_id_by_gateway_name($extra_meta_row['EXM_value']);
31
-        if (! $PMD_ID) {
32
-            $this->add_error(sprintf(__('Could not find payment method with PMD_type = \'%1$s\' when migrating extra meta row %2$s', 'event_espresso'), $extra_meta_row['EXM_value'], $this->_json_encode($extra_meta_row)));
33
-            return;
34
-        }
35
-        $new_values = array( 'PMD_ID' => $PMD_ID );
36
-        $wheres = array( 'TXN_ID' => $extra_meta_row['OBJ_ID'] );
37
-        $new_value_datatypes = array( '%d' );
38
-        $where_datatypes = array( '%d' );
39
-        $success = $wpdb->update(
40
-            $this->_transaction_table,
41
-            $new_values,
42
-            $wheres,
43
-            $new_value_datatypes,
44
-            $where_datatypes
45
-        );
46
-        if (! $success) {
47
-            $this->add_error(sprintf(__('Couldnt set %1$s row in table %2$s where %3$s', 'event_espresso'), $this->_json_encode($new_values), $this->_transaction_table, $this->_json_encode($wheres)));
48
-        }
49
-    }
50
-    /**
51
-     *
52
-     * @global type $wpdb
53
-     * @param int $id
54
-     * @return string
55
-     */
56
-    protected function _get_payment_method_id_by_gateway_name($gateway_name)
57
-    {
58
-        global $wpdb;
59
-        return $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM " . $wpdb->prefix . "esp_payment_method WHERE PMD_type = %s", $gateway_name));
60
-    }
14
+	protected $_transaction_table;
15
+	protected $_payment_method_table;
16
+	public function __construct()
17
+	{
18
+		global $wpdb;
19
+		$this->_old_table = $wpdb->prefix . 'esp_extra_meta';
20
+		$this->_transaction_table = $wpdb->prefix . 'esp_transaction';
21
+		$this->_payment_method_table = $wpdb->prefix . 'esp_payment_method';
22
+		$this->_pretty_name = __('Transaction Payment Method Relations', 'event_espresso');
23
+		$this->_extra_where_sql = "WHERE EXM_key = 'gateway' AND EXM_type = 'Transaction'";
24
+		parent::__construct();
25
+	}
26
+	protected function _migrate_old_row($extra_meta_row)
27
+	{
28
+		global $wpdb;
29
+		// get the payment method's ID
30
+		$PMD_ID = $this->_get_payment_method_id_by_gateway_name($extra_meta_row['EXM_value']);
31
+		if (! $PMD_ID) {
32
+			$this->add_error(sprintf(__('Could not find payment method with PMD_type = \'%1$s\' when migrating extra meta row %2$s', 'event_espresso'), $extra_meta_row['EXM_value'], $this->_json_encode($extra_meta_row)));
33
+			return;
34
+		}
35
+		$new_values = array( 'PMD_ID' => $PMD_ID );
36
+		$wheres = array( 'TXN_ID' => $extra_meta_row['OBJ_ID'] );
37
+		$new_value_datatypes = array( '%d' );
38
+		$where_datatypes = array( '%d' );
39
+		$success = $wpdb->update(
40
+			$this->_transaction_table,
41
+			$new_values,
42
+			$wheres,
43
+			$new_value_datatypes,
44
+			$where_datatypes
45
+		);
46
+		if (! $success) {
47
+			$this->add_error(sprintf(__('Couldnt set %1$s row in table %2$s where %3$s', 'event_espresso'), $this->_json_encode($new_values), $this->_transaction_table, $this->_json_encode($wheres)));
48
+		}
49
+	}
50
+	/**
51
+	 *
52
+	 * @global type $wpdb
53
+	 * @param int $id
54
+	 * @return string
55
+	 */
56
+	protected function _get_payment_method_id_by_gateway_name($gateway_name)
57
+	{
58
+		global $wpdb;
59
+		return $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM " . $wpdb->prefix . "esp_payment_method WHERE PMD_type = %s", $gateway_name));
60
+	}
61 61
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@  discard block
 block discarded – undo
16 16
     public function __construct()
17 17
     {
18 18
         global $wpdb;
19
-        $this->_old_table = $wpdb->prefix . 'esp_extra_meta';
20
-        $this->_transaction_table = $wpdb->prefix . 'esp_transaction';
21
-        $this->_payment_method_table = $wpdb->prefix . 'esp_payment_method';
19
+        $this->_old_table = $wpdb->prefix.'esp_extra_meta';
20
+        $this->_transaction_table = $wpdb->prefix.'esp_transaction';
21
+        $this->_payment_method_table = $wpdb->prefix.'esp_payment_method';
22 22
         $this->_pretty_name = __('Transaction Payment Method Relations', 'event_espresso');
23 23
         $this->_extra_where_sql = "WHERE EXM_key = 'gateway' AND EXM_type = 'Transaction'";
24 24
         parent::__construct();
@@ -28,14 +28,14 @@  discard block
 block discarded – undo
28 28
         global $wpdb;
29 29
         // get the payment method's ID
30 30
         $PMD_ID = $this->_get_payment_method_id_by_gateway_name($extra_meta_row['EXM_value']);
31
-        if (! $PMD_ID) {
31
+        if ( ! $PMD_ID) {
32 32
             $this->add_error(sprintf(__('Could not find payment method with PMD_type = \'%1$s\' when migrating extra meta row %2$s', 'event_espresso'), $extra_meta_row['EXM_value'], $this->_json_encode($extra_meta_row)));
33 33
             return;
34 34
         }
35
-        $new_values = array( 'PMD_ID' => $PMD_ID );
36
-        $wheres = array( 'TXN_ID' => $extra_meta_row['OBJ_ID'] );
37
-        $new_value_datatypes = array( '%d' );
38
-        $where_datatypes = array( '%d' );
35
+        $new_values = array('PMD_ID' => $PMD_ID);
36
+        $wheres = array('TXN_ID' => $extra_meta_row['OBJ_ID']);
37
+        $new_value_datatypes = array('%d');
38
+        $where_datatypes = array('%d');
39 39
         $success = $wpdb->update(
40 40
             $this->_transaction_table,
41 41
             $new_values,
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
             $new_value_datatypes,
44 44
             $where_datatypes
45 45
         );
46
-        if (! $success) {
46
+        if ( ! $success) {
47 47
             $this->add_error(sprintf(__('Couldnt set %1$s row in table %2$s where %3$s', 'event_espresso'), $this->_json_encode($new_values), $this->_transaction_table, $this->_json_encode($wheres)));
48 48
         }
49 49
     }
@@ -56,6 +56,6 @@  discard block
 block discarded – undo
56 56
     protected function _get_payment_method_id_by_gateway_name($gateway_name)
57 57
     {
58 58
         global $wpdb;
59
-        return $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM " . $wpdb->prefix . "esp_payment_method WHERE PMD_type = %s", $gateway_name));
59
+        return $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM ".$wpdb->prefix."esp_payment_method WHERE PMD_type = %s", $gateway_name));
60 60
     }
61 61
 }
Please login to merge, or discard this patch.
data_migration_scripts/4_6_0_stages/EE_DMS_4_6_0_billing_info.dmsstage.php 2 patches
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -11,69 +11,69 @@
 block discarded – undo
11 11
  */
12 12
 class EE_DMS_4_6_0_billing_info extends EE_Data_Migration_Script_Stage_Table
13 13
 {
14
-    public function __construct()
15
-    {
16
-        global $wpdb;
17
-        $this->_old_table = $wpdb->postmeta;
18
-        $this->_pretty_name = __('Billing Info', 'event_espresso');
19
-        $this->_extra_where_sql = "WHERE meta_key LIKE 'billing_info_%'";
20
-        parent::__construct();
21
-    }
22
-    protected function _migrate_old_row($old_row)
23
-    {
24
-        $new_billing_info = array();
25
-        $old_billing_info = maybe_unserialize($old_row['meta_value']);
26
-        $gateway_name = str_replace("billing_info_", '', $old_row['meta_key']);
27
-        $repetitive_prefix = '_reg-page-billing-';
28
-        $repetitive_suffix = "-" . $gateway_name;
29
-        foreach ($old_billing_info as $old_input_name => $input_value) {
30
-            $old_input_name_important_part = str_replace(array( $repetitive_prefix, $repetitive_suffix ), array( '', ''), $old_input_name);
14
+	public function __construct()
15
+	{
16
+		global $wpdb;
17
+		$this->_old_table = $wpdb->postmeta;
18
+		$this->_pretty_name = __('Billing Info', 'event_espresso');
19
+		$this->_extra_where_sql = "WHERE meta_key LIKE 'billing_info_%'";
20
+		parent::__construct();
21
+	}
22
+	protected function _migrate_old_row($old_row)
23
+	{
24
+		$new_billing_info = array();
25
+		$old_billing_info = maybe_unserialize($old_row['meta_value']);
26
+		$gateway_name = str_replace("billing_info_", '', $old_row['meta_key']);
27
+		$repetitive_prefix = '_reg-page-billing-';
28
+		$repetitive_suffix = "-" . $gateway_name;
29
+		foreach ($old_billing_info as $old_input_name => $input_value) {
30
+			$old_input_name_important_part = str_replace(array( $repetitive_prefix, $repetitive_suffix ), array( '', ''), $old_input_name);
31 31
 
32
-            switch ($old_input_name_important_part) {
33
-                case 'fname':
34
-                    $new_input_name = 'first_name';
35
-                    break;
36
-                case 'lname':
37
-                    $new_input_name = 'last_name';
38
-                    break;
39
-                case 'state':
40
-                    // we used to store the state's id ,but now we just store the name
41
-                    $new_input_name = $old_input_name_important_part;
42
-                    $input_value = $this->_get_state_name_by_ID($input_value);
43
-                    break;
44
-                case 'card-nmbr':
45
-                    $new_input_name = 'credit_card';
46
-                    break;
47
-                case 'card-type':// paypal pro only
48
-                    $new_input_name = 'credit_card_type';
49
-                    break;
50
-                case 'card-exp-date-mnth':
51
-                    $new_input_name = 'exp_month';
52
-                    $input_value = '';
53
-                    break;
54
-                case 'card-exp-date-year':
55
-                    $new_input_name = 'exp_year';
56
-                    $input_value = 0;
57
-                    break;
58
-                case 'ccv-code':
59
-                    $new_input_name = 'cvv';
60
-                    break;
61
-                default:
62
-                    $new_input_name = $old_input_name_important_part;
63
-            }
64
-            $new_billing_info[ $new_input_name ] = $input_value;
65
-        }
66
-        update_post_meta($old_row['post_id'], $old_row['meta_key'], $new_billing_info);
67
-    }
68
-    /**
69
-     *
70
-     * @global type $wpdb
71
-     * @param int $id
72
-     * @return string
73
-     */
74
-    protected function _get_state_name_by_ID($id)
75
-    {
76
-        global $wpdb;
77
-        return $wpdb->get_var($wpdb->prepare("SELECT STA_name FROM " . $wpdb->prefix . "esp_state WHERE STA_ID = %d", $id));
78
-    }
32
+			switch ($old_input_name_important_part) {
33
+				case 'fname':
34
+					$new_input_name = 'first_name';
35
+					break;
36
+				case 'lname':
37
+					$new_input_name = 'last_name';
38
+					break;
39
+				case 'state':
40
+					// we used to store the state's id ,but now we just store the name
41
+					$new_input_name = $old_input_name_important_part;
42
+					$input_value = $this->_get_state_name_by_ID($input_value);
43
+					break;
44
+				case 'card-nmbr':
45
+					$new_input_name = 'credit_card';
46
+					break;
47
+				case 'card-type':// paypal pro only
48
+					$new_input_name = 'credit_card_type';
49
+					break;
50
+				case 'card-exp-date-mnth':
51
+					$new_input_name = 'exp_month';
52
+					$input_value = '';
53
+					break;
54
+				case 'card-exp-date-year':
55
+					$new_input_name = 'exp_year';
56
+					$input_value = 0;
57
+					break;
58
+				case 'ccv-code':
59
+					$new_input_name = 'cvv';
60
+					break;
61
+				default:
62
+					$new_input_name = $old_input_name_important_part;
63
+			}
64
+			$new_billing_info[ $new_input_name ] = $input_value;
65
+		}
66
+		update_post_meta($old_row['post_id'], $old_row['meta_key'], $new_billing_info);
67
+	}
68
+	/**
69
+	 *
70
+	 * @global type $wpdb
71
+	 * @param int $id
72
+	 * @return string
73
+	 */
74
+	protected function _get_state_name_by_ID($id)
75
+	{
76
+		global $wpdb;
77
+		return $wpdb->get_var($wpdb->prepare("SELECT STA_name FROM " . $wpdb->prefix . "esp_state WHERE STA_ID = %d", $id));
78
+	}
79 79
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
         $old_billing_info = maybe_unserialize($old_row['meta_value']);
26 26
         $gateway_name = str_replace("billing_info_", '', $old_row['meta_key']);
27 27
         $repetitive_prefix = '_reg-page-billing-';
28
-        $repetitive_suffix = "-" . $gateway_name;
28
+        $repetitive_suffix = "-".$gateway_name;
29 29
         foreach ($old_billing_info as $old_input_name => $input_value) {
30
-            $old_input_name_important_part = str_replace(array( $repetitive_prefix, $repetitive_suffix ), array( '', ''), $old_input_name);
30
+            $old_input_name_important_part = str_replace(array($repetitive_prefix, $repetitive_suffix), array('', ''), $old_input_name);
31 31
 
32 32
             switch ($old_input_name_important_part) {
33 33
                 case 'fname':
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
                 default:
62 62
                     $new_input_name = $old_input_name_important_part;
63 63
             }
64
-            $new_billing_info[ $new_input_name ] = $input_value;
64
+            $new_billing_info[$new_input_name] = $input_value;
65 65
         }
66 66
         update_post_meta($old_row['post_id'], $old_row['meta_key'], $new_billing_info);
67 67
     }
@@ -74,6 +74,6 @@  discard block
 block discarded – undo
74 74
     protected function _get_state_name_by_ID($id)
75 75
     {
76 76
         global $wpdb;
77
-        return $wpdb->get_var($wpdb->prepare("SELECT STA_name FROM " . $wpdb->prefix . "esp_state WHERE STA_ID = %d", $id));
77
+        return $wpdb->get_var($wpdb->prepare("SELECT STA_name FROM ".$wpdb->prefix."esp_state WHERE STA_ID = %d", $id));
78 78
     }
79 79
 }
Please login to merge, or discard this patch.
4_7_0_stages/EE_DMS_4_7_0_Registration_Payments.dmsstage.php 2 patches
Indentation   +221 added lines, -221 removed lines patch added patch discarded remove patch
@@ -12,225 +12,225 @@
 block discarded – undo
12 12
 class EE_DMS_4_7_0_Registration_Payments extends EE_Data_Migration_Script_Stage_Table
13 13
 {
14 14
 
15
-    protected $_payment_table;
16
-
17
-    protected $_registration_table;
18
-
19
-    protected $_registration_payment_table;
20
-
21
-    public function __construct()
22
-    {
23
-        /** @type WPDB $wpdb */
24
-        global $wpdb;
25
-        $this->_pretty_name = __('Registration Payment Record Generation', 'event_espresso');
26
-        // define tables
27
-        $this->_old_table                                   = $wpdb->prefix . 'esp_transaction';
28
-        $this->_payment_table                       = $wpdb->prefix . 'esp_payment';
29
-        $this->_registration_table                  = $wpdb->prefix . 'esp_registration';
30
-        $this->_registration_payment_table  = $wpdb->prefix . 'esp_registration_payment';
31
-        // build SQL WHERE clauses
32
-        $this->_extra_where_sql = "WHERE STS_ID IN ( 'TIN', 'TCM' ) AND TXN_Total != '0.000'";
33
-        parent::__construct();
34
-    }
35
-
36
-
37
-
38
-    /**
39
-     * @param array $transaction
40
-     * @return void
41
-     */
42
-    protected function _migrate_old_row($transaction)
43
-    {
44
-        /** @type WPDB $wpdb */
45
-        global $wpdb;
46
-        $TXN_ID = absint($transaction['TXN_ID']);
47
-        if (! $TXN_ID) {
48
-            $this->add_error(
49
-                sprintf(
50
-                    __('Invalid transaction with ID=%1$d. Error: "%2$s"', 'event_espresso'),
51
-                    $TXN_ID,
52
-                    $wpdb->last_error
53
-                )
54
-            );
55
-            return;
56
-        }
57
-        // get all payments for the TXN
58
-        $payments = $this->_get_payments($TXN_ID);
59
-        if (empty($payments)) {
60
-            return;
61
-        }
62
-        // then the registrants
63
-        $registrations = $this->_get_registrations($TXN_ID);
64
-        if (empty($registrations)) {
65
-            return;
66
-        }
67
-        // now loop thru each payment and apply it to each of the registrations
68
-        foreach ($payments as $PAY_ID => $payment) {
69
-            if ($payment->STS_ID === 'PAP' && $payment->PAY_amount > 0) {
70
-                $this->_process_registration_payments($payment, $registrations);
71
-            }
72
-        }
73
-    }
74
-
75
-
76
-
77
-    /**
78
-     * _get_registrations
79
-     *
80
-     * @param int $TXN_ID
81
-     * @return array
82
-     */
83
-    protected function _get_registrations($TXN_ID)
84
-    {
85
-        /** @type WPDB $wpdb */
86
-        global $wpdb;
87
-        $SQL = "SELECT * FROM {$this->_registration_table} WHERE TXN_ID = %d AND STS_ID IN ( 'RPP', 'RAP' )";
88
-        return $wpdb->get_results($wpdb->prepare($SQL, $TXN_ID), OBJECT_K);
89
-    }
90
-
91
-
92
-
93
-    /**
94
-     * _get_payments
95
-     *
96
-     * @param int $TXN_ID
97
-     * @return array
98
-     */
99
-    protected function _get_payments($TXN_ID)
100
-    {
101
-        /** @type WPDB $wpdb */
102
-        global $wpdb;
103
-        return $wpdb->get_results($wpdb->prepare("SELECT * FROM {$this->_payment_table} WHERE TXN_ID = %d", $TXN_ID), OBJECT_K);
104
-    }
105
-
106
-
107
-
108
-    /**
109
-     * _get_possibly_updated_REG_paid
110
-     *
111
-     * @param int $REG_ID
112
-     * @return array
113
-     */
114
-    protected function _get_possibly_updated_REG_paid($REG_ID)
115
-    {
116
-        /** @type WPDB $wpdb */
117
-        global $wpdb;
118
-        return $wpdb->get_var($wpdb->prepare("SELECT REG_paid FROM {$this->_registration_table} WHERE REG_ID = %d", $REG_ID));
119
-    }
120
-
121
-
122
-
123
-    /**
124
-     * _process_registration_payments
125
-     *
126
-     * basically a copy of the "Sequential Registration Payment Application Strategy"  logic
127
-     * currently in EE_Payment_Processor::process_registration_payments()
128
-     *
129
-     * @param stdClass $payment
130
-     * @param array $registrations
131
-     * @return bool
132
-     */
133
-    protected function _process_registration_payments($payment, $registrations = array())
134
-    {
135
-        // how much is available to apply to registrations?
136
-        $available_payment_amount = $payment->PAY_amount;
137
-        foreach ($registrations as $REG_ID => $registration) {
138
-            // nothing left, then we are done here?
139
-            if (! $available_payment_amount > 0) {
140
-                break;
141
-            }
142
-            // ensure REG_final_price has a valid value, and skip if it turns out to be zero
143
-            $registration->REG_final_price = ! empty($registration->REG_final_price) ? (float) $registration->REG_final_price : 0.00;
144
-            if (! $registration->REG_final_price > 0) {
145
-                continue;
146
-            }
147
-            // because REG_paid may have been updated by a previous payment, we need to retrieve the value from the db
148
-            $possibly_updated_REG_paid = $this->_get_possibly_updated_REG_paid($REG_ID);
149
-            if (is_float($possibly_updated_REG_paid)) {
150
-                $registration->REG_paid = $possibly_updated_REG_paid;
151
-            }
152
-            // and ensure REG_paid has a valid value
153
-            $registration->REG_paid = ! empty($registration->REG_paid) ? (float) $registration->REG_paid : 0.00;
154
-            // calculate amount owing, and skip if it turns out to be zero
155
-            $owing = $registration->REG_final_price - $registration->REG_paid;
156
-            if (! $owing > 0) {
157
-                continue;
158
-            }
159
-            // don't allow payment amount to exceed the available payment amount, OR the amount owing
160
-            $payment_amount = min($available_payment_amount, $owing);
161
-            // update $available_payment_amount
162
-            $available_payment_amount = $available_payment_amount - $payment_amount;
163
-            // add relation between registration and payment and set amount
164
-            if ($this->_insert_registration_payment($registration->REG_ID, $payment->PAY_ID, $payment_amount)) {
165
-                // calculate and set new REG_paid
166
-                $registration->REG_paid = $registration->REG_paid + $payment_amount;
167
-                $this->_update_registration_paid($registration->REG_ID, $registration->REG_paid);
168
-            }
169
-        }
170
-    }
171
-
172
-
173
-
174
-    /**
175
-     * _insert_registration_payment
176
-     *
177
-     * @param int $REG_ID
178
-     * @param int $PAY_ID
179
-     * @param float $PAY_amount
180
-     * @return bool
181
-     */
182
-    protected function _insert_registration_payment($REG_ID = 0, $PAY_ID = 0, $PAY_amount = 0.00)
183
-    {
184
-        /** @type WPDB $wpdb */
185
-        global $wpdb;
186
-        $success = $wpdb->insert(
187
-            $this->_registration_payment_table,
188
-            array( 'REG_ID' => $REG_ID, 'PAY_ID' => $PAY_ID, 'RPY_amount' => $PAY_amount, ),  // data
189
-            array( '%f' )   // data format
190
-        );
191
-        if ($success === false) {
192
-            $this->add_error(
193
-                sprintf(
194
-                    __('Could not update registration paid value for registration ID=%1$d because "%2$s"', 'event_espresso'),
195
-                    $REG_ID,
196
-                    $wpdb->last_error
197
-                )
198
-            );
199
-            return false;
200
-        }
201
-        return true;
202
-    }
203
-
204
-
205
-
206
-    /**
207
-     * _update_registration_paid
208
-     *
209
-     * @param int $REG_ID
210
-     * @param float $REG_paid
211
-     * @return bool
212
-     */
213
-    protected function _update_registration_paid($REG_ID = 0, $REG_paid = 0.00)
214
-    {
215
-        /** @type WPDB $wpdb */
216
-        global $wpdb;
217
-        $success = $wpdb->update(
218
-            $this->_registration_table,
219
-            array( 'REG_paid' => $REG_paid ),  // data
220
-            array( 'REG_ID' => $REG_ID ),  // where
221
-            array( '%f' ),   // data format
222
-            array( '%d' )  // where format
223
-        );
224
-        if ($success === false) {
225
-            $this->add_error(
226
-                sprintf(
227
-                    __('Could not update registration paid value for registration ID=%1$d because "%2$s"', 'event_espresso'),
228
-                    $REG_ID,
229
-                    $wpdb->last_error
230
-                )
231
-            );
232
-            return false;
233
-        }
234
-        return true;
235
-    }
15
+	protected $_payment_table;
16
+
17
+	protected $_registration_table;
18
+
19
+	protected $_registration_payment_table;
20
+
21
+	public function __construct()
22
+	{
23
+		/** @type WPDB $wpdb */
24
+		global $wpdb;
25
+		$this->_pretty_name = __('Registration Payment Record Generation', 'event_espresso');
26
+		// define tables
27
+		$this->_old_table                                   = $wpdb->prefix . 'esp_transaction';
28
+		$this->_payment_table                       = $wpdb->prefix . 'esp_payment';
29
+		$this->_registration_table                  = $wpdb->prefix . 'esp_registration';
30
+		$this->_registration_payment_table  = $wpdb->prefix . 'esp_registration_payment';
31
+		// build SQL WHERE clauses
32
+		$this->_extra_where_sql = "WHERE STS_ID IN ( 'TIN', 'TCM' ) AND TXN_Total != '0.000'";
33
+		parent::__construct();
34
+	}
35
+
36
+
37
+
38
+	/**
39
+	 * @param array $transaction
40
+	 * @return void
41
+	 */
42
+	protected function _migrate_old_row($transaction)
43
+	{
44
+		/** @type WPDB $wpdb */
45
+		global $wpdb;
46
+		$TXN_ID = absint($transaction['TXN_ID']);
47
+		if (! $TXN_ID) {
48
+			$this->add_error(
49
+				sprintf(
50
+					__('Invalid transaction with ID=%1$d. Error: "%2$s"', 'event_espresso'),
51
+					$TXN_ID,
52
+					$wpdb->last_error
53
+				)
54
+			);
55
+			return;
56
+		}
57
+		// get all payments for the TXN
58
+		$payments = $this->_get_payments($TXN_ID);
59
+		if (empty($payments)) {
60
+			return;
61
+		}
62
+		// then the registrants
63
+		$registrations = $this->_get_registrations($TXN_ID);
64
+		if (empty($registrations)) {
65
+			return;
66
+		}
67
+		// now loop thru each payment and apply it to each of the registrations
68
+		foreach ($payments as $PAY_ID => $payment) {
69
+			if ($payment->STS_ID === 'PAP' && $payment->PAY_amount > 0) {
70
+				$this->_process_registration_payments($payment, $registrations);
71
+			}
72
+		}
73
+	}
74
+
75
+
76
+
77
+	/**
78
+	 * _get_registrations
79
+	 *
80
+	 * @param int $TXN_ID
81
+	 * @return array
82
+	 */
83
+	protected function _get_registrations($TXN_ID)
84
+	{
85
+		/** @type WPDB $wpdb */
86
+		global $wpdb;
87
+		$SQL = "SELECT * FROM {$this->_registration_table} WHERE TXN_ID = %d AND STS_ID IN ( 'RPP', 'RAP' )";
88
+		return $wpdb->get_results($wpdb->prepare($SQL, $TXN_ID), OBJECT_K);
89
+	}
90
+
91
+
92
+
93
+	/**
94
+	 * _get_payments
95
+	 *
96
+	 * @param int $TXN_ID
97
+	 * @return array
98
+	 */
99
+	protected function _get_payments($TXN_ID)
100
+	{
101
+		/** @type WPDB $wpdb */
102
+		global $wpdb;
103
+		return $wpdb->get_results($wpdb->prepare("SELECT * FROM {$this->_payment_table} WHERE TXN_ID = %d", $TXN_ID), OBJECT_K);
104
+	}
105
+
106
+
107
+
108
+	/**
109
+	 * _get_possibly_updated_REG_paid
110
+	 *
111
+	 * @param int $REG_ID
112
+	 * @return array
113
+	 */
114
+	protected function _get_possibly_updated_REG_paid($REG_ID)
115
+	{
116
+		/** @type WPDB $wpdb */
117
+		global $wpdb;
118
+		return $wpdb->get_var($wpdb->prepare("SELECT REG_paid FROM {$this->_registration_table} WHERE REG_ID = %d", $REG_ID));
119
+	}
120
+
121
+
122
+
123
+	/**
124
+	 * _process_registration_payments
125
+	 *
126
+	 * basically a copy of the "Sequential Registration Payment Application Strategy"  logic
127
+	 * currently in EE_Payment_Processor::process_registration_payments()
128
+	 *
129
+	 * @param stdClass $payment
130
+	 * @param array $registrations
131
+	 * @return bool
132
+	 */
133
+	protected function _process_registration_payments($payment, $registrations = array())
134
+	{
135
+		// how much is available to apply to registrations?
136
+		$available_payment_amount = $payment->PAY_amount;
137
+		foreach ($registrations as $REG_ID => $registration) {
138
+			// nothing left, then we are done here?
139
+			if (! $available_payment_amount > 0) {
140
+				break;
141
+			}
142
+			// ensure REG_final_price has a valid value, and skip if it turns out to be zero
143
+			$registration->REG_final_price = ! empty($registration->REG_final_price) ? (float) $registration->REG_final_price : 0.00;
144
+			if (! $registration->REG_final_price > 0) {
145
+				continue;
146
+			}
147
+			// because REG_paid may have been updated by a previous payment, we need to retrieve the value from the db
148
+			$possibly_updated_REG_paid = $this->_get_possibly_updated_REG_paid($REG_ID);
149
+			if (is_float($possibly_updated_REG_paid)) {
150
+				$registration->REG_paid = $possibly_updated_REG_paid;
151
+			}
152
+			// and ensure REG_paid has a valid value
153
+			$registration->REG_paid = ! empty($registration->REG_paid) ? (float) $registration->REG_paid : 0.00;
154
+			// calculate amount owing, and skip if it turns out to be zero
155
+			$owing = $registration->REG_final_price - $registration->REG_paid;
156
+			if (! $owing > 0) {
157
+				continue;
158
+			}
159
+			// don't allow payment amount to exceed the available payment amount, OR the amount owing
160
+			$payment_amount = min($available_payment_amount, $owing);
161
+			// update $available_payment_amount
162
+			$available_payment_amount = $available_payment_amount - $payment_amount;
163
+			// add relation between registration and payment and set amount
164
+			if ($this->_insert_registration_payment($registration->REG_ID, $payment->PAY_ID, $payment_amount)) {
165
+				// calculate and set new REG_paid
166
+				$registration->REG_paid = $registration->REG_paid + $payment_amount;
167
+				$this->_update_registration_paid($registration->REG_ID, $registration->REG_paid);
168
+			}
169
+		}
170
+	}
171
+
172
+
173
+
174
+	/**
175
+	 * _insert_registration_payment
176
+	 *
177
+	 * @param int $REG_ID
178
+	 * @param int $PAY_ID
179
+	 * @param float $PAY_amount
180
+	 * @return bool
181
+	 */
182
+	protected function _insert_registration_payment($REG_ID = 0, $PAY_ID = 0, $PAY_amount = 0.00)
183
+	{
184
+		/** @type WPDB $wpdb */
185
+		global $wpdb;
186
+		$success = $wpdb->insert(
187
+			$this->_registration_payment_table,
188
+			array( 'REG_ID' => $REG_ID, 'PAY_ID' => $PAY_ID, 'RPY_amount' => $PAY_amount, ),  // data
189
+			array( '%f' )   // data format
190
+		);
191
+		if ($success === false) {
192
+			$this->add_error(
193
+				sprintf(
194
+					__('Could not update registration paid value for registration ID=%1$d because "%2$s"', 'event_espresso'),
195
+					$REG_ID,
196
+					$wpdb->last_error
197
+				)
198
+			);
199
+			return false;
200
+		}
201
+		return true;
202
+	}
203
+
204
+
205
+
206
+	/**
207
+	 * _update_registration_paid
208
+	 *
209
+	 * @param int $REG_ID
210
+	 * @param float $REG_paid
211
+	 * @return bool
212
+	 */
213
+	protected function _update_registration_paid($REG_ID = 0, $REG_paid = 0.00)
214
+	{
215
+		/** @type WPDB $wpdb */
216
+		global $wpdb;
217
+		$success = $wpdb->update(
218
+			$this->_registration_table,
219
+			array( 'REG_paid' => $REG_paid ),  // data
220
+			array( 'REG_ID' => $REG_ID ),  // where
221
+			array( '%f' ),   // data format
222
+			array( '%d' )  // where format
223
+		);
224
+		if ($success === false) {
225
+			$this->add_error(
226
+				sprintf(
227
+					__('Could not update registration paid value for registration ID=%1$d because "%2$s"', 'event_espresso'),
228
+					$REG_ID,
229
+					$wpdb->last_error
230
+				)
231
+			);
232
+			return false;
233
+		}
234
+		return true;
235
+	}
236 236
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
         global $wpdb;
25 25
         $this->_pretty_name = __('Registration Payment Record Generation', 'event_espresso');
26 26
         // define tables
27
-        $this->_old_table                                   = $wpdb->prefix . 'esp_transaction';
28
-        $this->_payment_table                       = $wpdb->prefix . 'esp_payment';
29
-        $this->_registration_table                  = $wpdb->prefix . 'esp_registration';
30
-        $this->_registration_payment_table  = $wpdb->prefix . 'esp_registration_payment';
27
+        $this->_old_table = $wpdb->prefix.'esp_transaction';
28
+        $this->_payment_table                       = $wpdb->prefix.'esp_payment';
29
+        $this->_registration_table                  = $wpdb->prefix.'esp_registration';
30
+        $this->_registration_payment_table = $wpdb->prefix.'esp_registration_payment';
31 31
         // build SQL WHERE clauses
32 32
         $this->_extra_where_sql = "WHERE STS_ID IN ( 'TIN', 'TCM' ) AND TXN_Total != '0.000'";
33 33
         parent::__construct();
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
         /** @type WPDB $wpdb */
45 45
         global $wpdb;
46 46
         $TXN_ID = absint($transaction['TXN_ID']);
47
-        if (! $TXN_ID) {
47
+        if ( ! $TXN_ID) {
48 48
             $this->add_error(
49 49
                 sprintf(
50 50
                     __('Invalid transaction with ID=%1$d. Error: "%2$s"', 'event_espresso'),
@@ -136,12 +136,12 @@  discard block
 block discarded – undo
136 136
         $available_payment_amount = $payment->PAY_amount;
137 137
         foreach ($registrations as $REG_ID => $registration) {
138 138
             // nothing left, then we are done here?
139
-            if (! $available_payment_amount > 0) {
139
+            if ( ! $available_payment_amount > 0) {
140 140
                 break;
141 141
             }
142 142
             // ensure REG_final_price has a valid value, and skip if it turns out to be zero
143 143
             $registration->REG_final_price = ! empty($registration->REG_final_price) ? (float) $registration->REG_final_price : 0.00;
144
-            if (! $registration->REG_final_price > 0) {
144
+            if ( ! $registration->REG_final_price > 0) {
145 145
                 continue;
146 146
             }
147 147
             // because REG_paid may have been updated by a previous payment, we need to retrieve the value from the db
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
             $registration->REG_paid = ! empty($registration->REG_paid) ? (float) $registration->REG_paid : 0.00;
154 154
             // calculate amount owing, and skip if it turns out to be zero
155 155
             $owing = $registration->REG_final_price - $registration->REG_paid;
156
-            if (! $owing > 0) {
156
+            if ( ! $owing > 0) {
157 157
                 continue;
158 158
             }
159 159
             // don't allow payment amount to exceed the available payment amount, OR the amount owing
@@ -185,8 +185,8 @@  discard block
 block discarded – undo
185 185
         global $wpdb;
186 186
         $success = $wpdb->insert(
187 187
             $this->_registration_payment_table,
188
-            array( 'REG_ID' => $REG_ID, 'PAY_ID' => $PAY_ID, 'RPY_amount' => $PAY_amount, ),  // data
189
-            array( '%f' )   // data format
188
+            array('REG_ID' => $REG_ID, 'PAY_ID' => $PAY_ID, 'RPY_amount' => $PAY_amount,), // data
189
+            array('%f')   // data format
190 190
         );
191 191
         if ($success === false) {
192 192
             $this->add_error(
@@ -216,10 +216,10 @@  discard block
 block discarded – undo
216 216
         global $wpdb;
217 217
         $success = $wpdb->update(
218 218
             $this->_registration_table,
219
-            array( 'REG_paid' => $REG_paid ),  // data
220
-            array( 'REG_ID' => $REG_ID ),  // where
221
-            array( '%f' ),   // data format
222
-            array( '%d' )  // where format
219
+            array('REG_paid' => $REG_paid), // data
220
+            array('REG_ID' => $REG_ID), // where
221
+            array('%f'), // data format
222
+            array('%d')  // where format
223 223
         );
224 224
         if ($success === false) {
225 225
             $this->add_error(
Please login to merge, or discard this patch.