Completed
Branch FET-3467-waitlists (4406f2)
by
unknown
46:31 queued 34:26
created
general_settings/templates/your_organization_settings.template.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <div class="padding">
2 2
 	<?php
3 3
 		//we'll only show site-license keys if this is main_site() (which works for both multi-site and single-site wp installations)
4
-		if ( is_main_site() ) { ?>
4
+		if (is_main_site()) { ?>
5 5
 		<h2 class="ee-admin-settings-hdr" style="width:300px;">
6 6
 			<?php _e('Your Event Espresso License Key', 'event_espresso'); ?>
7 7
 		</h2>
@@ -11,13 +11,13 @@  discard block
 block discarded – undo
11 11
 				<tr <?php echo isset($_REQUEST['license_key']) && $_REQUEST['license_key'] == true ? 'class="yellow_alert"' : '' ?>>
12 12
 					<th>
13 13
 						<label for="site_license_key">
14
-							<?php _e('Support License Key', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('site_license_key_info');?>
14
+							<?php _e('Support License Key', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('site_license_key_info'); ?>
15 15
 						</label>
16 16
 					</th>
17 17
 					<td>
18 18
 						<input name="site_license_key" id="site_license_key" size="10" class="regular-text" type="text" value="<?php echo $site_license_key; ?>" /><?php echo $site_license_key_verified; ?><br/>
19 19
 						<p class="description">
20
-							<?php printf( __('Adding a valid Support License Key will enable automatic update notifications and backend updates for Event Espresso Core and any installed add-ons. If this is a Development or Test site, %sDO NOT%s enter your Support License Key.', 'event_espresso'), '<strong>', '</strong>' ); ?>
20
+							<?php printf(__('Adding a valid Support License Key will enable automatic update notifications and backend updates for Event Espresso Core and any installed add-ons. If this is a Development or Test site, %sDO NOT%s enter your Support License Key.', 'event_espresso'), '<strong>', '</strong>'); ?>
21 21
 						</p>
22 22
 					</td>
23 23
 				</tr>
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 
31 31
 
32 32
 	<h2 id="contact_info_h4" class="ee-admin-settings-hdr">
33
-		<?php _e('Contact Information', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('contact_info_info');?>
33
+		<?php _e('Contact Information', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('contact_info_info'); ?>
34 34
 	</h2>
35 35
 
36 36
 	<table class="form-table">
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 					<input id="organization_city" class="regular-text" type="text" name="organization_city" value="<?php echo $organization_city; ?>" />
79 79
 				</td>
80 80
 			</tr>
81
-			<?php echo EEH_Form_Fields::generate_form_input( $states ); ?>
82
-			<?php echo EEH_Form_Fields::generate_form_input( $countries ); ?>
81
+			<?php echo EEH_Form_Fields::generate_form_input($states); ?>
82
+			<?php echo EEH_Form_Fields::generate_form_input($countries); ?>
83 83
 			<tr>
84 84
 				<th>
85 85
 					<label for="organization_zip">
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 				<td>
100 100
 					<input class="regular-text" type="text" name="organization_email" value="<?php echo $organization_email; ?>" />
101 101
 					<p class="description">
102
-						<?php echo sprintf( esc_html__('This is where notifications go to when you use the %1$s and %2$s shortcodes in the message templates.', 'event_espresso'), '<code>[CO_FORMATTED_EMAIL]</code>', '<code>[CO_EMAIL]</code>' ); ?>
102
+						<?php echo sprintf(esc_html__('This is where notifications go to when you use the %1$s and %2$s shortcodes in the message templates.', 'event_espresso'), '<code>[CO_FORMATTED_EMAIL]</code>', '<code>[CO_EMAIL]</code>'); ?>
103 103
 					</p>
104 104
 				</td>
105 105
 			</tr>
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	</table>
134 134
 
135 135
 	<h2 class="ee-admin-settings-hdr">
136
-		<?php _e('Company Logo', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('organization_logo_info');?>
136
+		<?php _e('Company Logo', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('organization_logo_info'); ?>
137 137
 	</h2>
138 138
 
139 139
 	<table class="form-table">
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 				</th>
162 162
 				<td>
163 163
 					<?php
164
-					if ( $organization_logo_url ) {
164
+					if ($organization_logo_url) {
165 165
 						?>
166 166
 						<p id="default-logo-thumb">
167 167
 							<img id="current-image-thumb" src="<?php echo $organization_logo_url ?>" alt="" /><br />
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	<br/><br/>
180 180
 
181 181
 	<h2 class="ee-admin-settings-hdr">
182
-		<?php _e('Social Links', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('social_links_info');?>
182
+		<?php _e('Social Links', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('social_links_info'); ?>
183 183
 	</h2>
184 184
 	<p class="description"><?php _e('Enter any links to social accounts for your organization here', 'event_espresso'); ?></p>
185 185
 
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
 	<br/><br/>
257 257
 
258 258
 
259
-	<?php if ( is_main_site() ) : ?>
259
+	<?php if (is_main_site()) : ?>
260 260
 		<p>
261
-			<?php echo  EE_PUE::espresso_data_collection_optin_text( FALSE ); ?>
261
+			<?php echo  EE_PUE::espresso_data_collection_optin_text(FALSE); ?>
262 262
 		</p>
263 263
 
264 264
 		<table class="form-table">
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
 					</th>
273 273
 					<td>
274 274
 						<?php
275
-							$values=array(
276
-								array('id'=>'yes','text'=> __('Yes! I want to help improve Event Espresso!','event_espresso')),
277
-								array('id'=>'no','text'=> __('Not at this time. Maybe later.','event_espresso'))
275
+							$values = array(
276
+								array('id'=>'yes', 'text'=> __('Yes! I want to help improve Event Espresso!', 'event_espresso')),
277
+								array('id'=>'no', 'text'=> __('Not at this time. Maybe later.', 'event_espresso'))
278 278
 							);
279
-							echo EEH_Form_Fields::select_input('ueip_optin', $values, !empty($ee_ueip_optin) ? $ee_ueip_optin : 'yes');
279
+							echo EEH_Form_Fields::select_input('ueip_optin', $values, ! empty($ee_ueip_optin) ? $ee_ueip_optin : 'yes');
280 280
 						?>
281 281
 					</td>
282 282
 				</tr>
Please login to merge, or discard this patch.
pricing/templates/event_tickets_datetime_attached_tickets_row.template.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
 				</table>
52 52
 				<div class="ee-editor-footer-container">
53 53
 					<div class="ee-editor-id-container">
54
-						<span class="ee-item-id"><?php echo $DTT_ID ? sprintf( esc_html__( 'Datetime ID: %d', 'event_espresso' ), $DTT_ID ) : ''; ?></span>
54
+						<span class="ee-item-id"><?php echo $DTT_ID ? sprintf(esc_html__('Datetime ID: %d', 'event_espresso'), $DTT_ID) : ''; ?></span>
55 55
 					</div>
56 56
 					<div class="save-cancel-button-container">
57 57
 						<button data-context="short-ticket" data-datetime-row="<?php echo $dtt_row; ?>" class="button-primary ee-create-button">
Please login to merge, or discard this patch.
caffeinated/payment_methods/Aim/templates/aim_intro.template.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,1 +1,1 @@
 block discarded – undo
1
-<?php printf( esc_html__('Authorize.Net AIM is an on-site payment method for accepting credit and debit card payments and is available to event organizers in the United States, Canada, United Kingdom, and Australia. An account with Authorize.Net is required to accept payments. Need an Authorize.Net account? %1$sClick here to sign up for a merchant account%2$s.', 'event_espresso'), '<a href="https://eventespresso.com/go/authorizenetaim/" target="_blank">','</a>' );
2 1
\ No newline at end of file
2
+<?php printf(esc_html__('Authorize.Net AIM is an on-site payment method for accepting credit and debit card payments and is available to event organizers in the United States, Canada, United Kingdom, and Australia. An account with Authorize.Net is required to accept payments. Need an Authorize.Net account? %1$sClick here to sign up for a merchant account%2$s.', 'event_espresso'), '<a href="https://eventespresso.com/go/authorizenetaim/" target="_blank">', '</a>');
3 3
\ No newline at end of file
Please login to merge, or discard this patch.
payment_methods/Paypal_Pro/templates/paypal_pro_intro.template.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,1 +1,1 @@
 block discarded – undo
1
-<?php printf( esc_html__('PayPal Pro (Website Payments Pro) is an on-site payment method for accepting credit and debit cards and is available to event organizers in the United States, United Kingdom, and Canada. An account with PayPal is required to accept payments. Need a PayPal Pro account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.', 'event_espresso'), '<a href="https://eventespresso.com/go/paypalpro/" target="_blank">','</a>' );
2 1
\ No newline at end of file
2
+<?php printf(esc_html__('PayPal Pro (Website Payments Pro) is an on-site payment method for accepting credit and debit cards and is available to event organizers in the United States, United Kingdom, and Canada. An account with PayPal is required to accept payments. Need a PayPal Pro account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.', 'event_espresso'), '<a href="https://eventespresso.com/go/paypalpro/" target="_blank">', '</a>');
3 3
\ No newline at end of file
Please login to merge, or discard this patch.
Paypal_Standard/templates/paypal_standard_intro.template.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 $closing_tag = '</a>';
3 3
 //if this is decaf, which is put on WordPress.org, we need to inform users that
4 4
 //we just put an affiliate link there. See https://developer.wordpress.org/plugins/wordpress-org/detailed-plugin-guidelines/ section 12
5
-if( apply_filters( 'FHEE__ee_show_affiliate_links', true ) ) {
6
-	$closing_tag .= esc_html__( ' (affiliate link)', 'event_espresso' );
5
+if (apply_filters('FHEE__ee_show_affiliate_links', true)) {
6
+	$closing_tag .= esc_html__(' (affiliate link)', 'event_espresso');
7 7
 }
8
-printf( esc_html__('PayPal Standard (PayPal Payments Standard) is an off-site payment method and is available to event organizers in many countries. A PayPal premier or business account is needed to accept payments. Need a PayPal account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.', 'event_espresso'), '<a href="https://eventespresso.com/go/paypalstandard/" target="_blank">', $closing_tag );
9 8
\ No newline at end of file
9
+printf(esc_html__('PayPal Standard (PayPal Payments Standard) is an off-site payment method and is available to event organizers in many countries. A PayPal premier or business account is needed to accept payments. Need a PayPal account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.', 'event_espresso'), '<a href="https://eventespresso.com/go/paypalstandard/" target="_blank">', $closing_tag);
10 10
\ No newline at end of file
Please login to merge, or discard this patch.
public/Espresso_Arabica_2014/loop-espresso_event_attendees.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,27 +15,27 @@
 block discarded – undo
15 15
  * @type bool       $show_gravatar  whether to show gravatar or not.
16 16
  */
17 17
 
18
-$no_attendees_message =  apply_filters( 'FHEE__loop-espresso_attendees-shortcode__template__no_attendees_message', __('No Attendees Yet', 'event_espresso' ) );
18
+$no_attendees_message = apply_filters('FHEE__loop-espresso_attendees-shortcode__template__no_attendees_message', __('No Attendees Yet', 'event_espresso'));
19 19
 
20 20
 
21 21
 ?>
22 22
 
23 23
 <div class="event-attendees">
24
-	<?php do_action( 'AHEE__loop-espresso_event_attendees__before', $contacts, $event, $datetime, $ticket, $show_gravatar ); ?>
25
-	<?php if ( $contacts ) : ?>
24
+	<?php do_action('AHEE__loop-espresso_event_attendees__before', $contacts, $event, $datetime, $ticket, $show_gravatar); ?>
25
+	<?php if ($contacts) : ?>
26 26
 		<ul class="event-attendees-list">
27
-			<?php foreach( $contacts as $contact ) :
28
-				EEH_Template::get_template_part( 'content', 'espresso_event_attendees', array( 
27
+			<?php foreach ($contacts as $contact) :
28
+				EEH_Template::get_template_part('content', 'espresso_event_attendees', array( 
29 29
 					'contact'       => $contact, 
30 30
 					'event'         => $event,
31 31
 					'datetime'      => $datetime,
32 32
 					'ticket'        => $ticket,
33 33
 					'show_gravatar' => $show_gravatar 
34
-				) );
34
+				));
35 35
 				endforeach; ?>
36 36
 		</ul>
37 37
 	<?php else : ?>
38 38
 		<p><?php echo $no_attendees_message; ?></p>
39 39
 	<?php endif; ?>
40
-	<?php do_action( 'AHEE__loop-espresso_event_attendees__after', $contacts, $event, $datetime, $ticket, $show_gravatar ); ?>
40
+	<?php do_action('AHEE__loop-espresso_event_attendees__after', $contacts, $event, $datetime, $ticket, $show_gravatar); ?>
41 41
 </div>
42 42
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,8 +34,11 @@
 block discarded – undo
34 34
 				) );
35 35
 				endforeach; ?>
36 36
 		</ul>
37
-	<?php else : ?>
38
-		<p><?php echo $no_attendees_message; ?></p>
37
+	<?php else {
38
+	: ?>
39
+		<p><?php echo $no_attendees_message;
40
+}
41
+?></p>
39 42
 	<?php endif; ?>
40 43
 	<?php do_action( 'AHEE__loop-espresso_event_attendees__after', $contacts, $event, $datetime, $ticket, $show_gravatar ); ?>
41 44
 </div>
42 45
\ No newline at end of file
Please login to merge, or discard this patch.
core/services/container/OpenCoffeeShop.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	 * OpenCoffeeShop constructor.
34 34
 	 */
35 35
 	public function __construct()
36
-    {
36
+	{
37 37
 		// instantiate the container
38 38
 		$this->CoffeeShop = new CoffeeShop();
39 39
 		// create a dependency injector class for resolving class constructor arguments
@@ -83,11 +83,11 @@  discard block
 block discarded – undo
83 83
 			new Recipe(
84 84
 				'CommandHandlerManager',
85 85
 				'EventEspresso\core\services\commands\CommandHandlerManager',
86
-                array(
87
-                    'CommandHandlerManagerInterface',
88
-                    'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
89
-                ),
90
-                array(),
86
+				array(
87
+					'CommandHandlerManagerInterface',
88
+					'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
89
+				),
90
+				array(),
91 91
 				CoffeeMaker::BREW_SHARED
92 92
 			)
93 93
 		);
@@ -96,11 +96,11 @@  discard block
 block discarded – undo
96 96
 			new Recipe(
97 97
 				'CommandBus',
98 98
 				'EventEspresso\core\services\commands\CommandBus',
99
-                array(
100
-                    'CommandBusInterface',
101
-                    'EventEspresso\core\services\commands\CommandBusInterface',
102
-                ),
103
-                array(),
99
+				array(
100
+					'CommandBusInterface',
101
+					'EventEspresso\core\services\commands\CommandBusInterface',
102
+				),
103
+				array(),
104 104
 				CoffeeMaker::BREW_SHARED
105 105
 			)
106 106
 		);
@@ -110,22 +110,22 @@  discard block
 block discarded – undo
110 110
 			new Recipe(
111 111
 				'EEI_*',
112 112
 				'',
113
-                array(),
114
-                array(),
113
+				array(),
114
+				array(),
115 115
 				CoffeeMaker::BREW_LOAD_ONLY,
116
-                array(
117
-                    EE_INTERFACES . '*.php',
118
-                    EE_INTERFACES . '*.interfaces.php',
119
-                )
116
+				array(
117
+					EE_INTERFACES . '*.php',
118
+					EE_INTERFACES . '*.interfaces.php',
119
+				)
120 120
 			)
121 121
 		);
122 122
 		// add a wildcard recipe for loading models
123 123
 		$this->CoffeeShop->addRecipe(
124 124
 			new Recipe(
125 125
 				'EEM_*',
126
-                '',
127
-                array(),
128
-                array(),
126
+				'',
127
+				array(),
128
+				array(),
129 129
 				CoffeeMaker::BREW_SHARED,
130 130
 				EE_MODELS . '*.model.php'
131 131
 			)
@@ -134,10 +134,10 @@  discard block
 block discarded – undo
134 134
 		$this->CoffeeShop->addRecipe(
135 135
 			new Recipe(
136 136
 				'EE_*',
137
-                '',
138
-                array(),
139
-                array(),
140
-                CoffeeMaker::BREW_SHARED,
137
+				'',
138
+				array(),
139
+				array(),
140
+				CoffeeMaker::BREW_SHARED,
141 141
 				array(
142 142
 					EE_CORE . '*.core.php',
143 143
 					EE_ADMIN . '*.core.php',
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
 		$this->CoffeeShop->addRecipe(
153 153
 			new Recipe(
154 154
 				'EE_Admin_Page*',
155
-                '',
156
-                array(),
157
-                array(),
158
-                CoffeeMaker::BREW_LOAD_ONLY,
155
+				'',
156
+				array(),
157
+				array(),
158
+				CoffeeMaker::BREW_LOAD_ONLY,
159 159
 				array( EE_ADMIN . '*.core.php' )
160 160
 			)
161 161
 		);
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
 		// $this->CoffeeShop->addRecipe(
164 164
 		// 	new Recipe(
165 165
 		// 		'*_Admin_Page',
166
-        //      '',
167
-        //      array(),
168
-        // 		array(),
169
-        // 		CoffeeMaker::BREW_SHARED,
166
+		//      '',
167
+		//      array(),
168
+		// 		array(),
169
+		// 		CoffeeMaker::BREW_SHARED,
170 170
 		// 		array(
171 171
 		// 			EE_ADMIN_PAGES . 'transactions' . DS . '*.core.php',
172 172
 		// 		)
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\services\container;
3 3
 
4
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-	exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -43,17 +43,17 @@  discard block
 block discarded – undo
43 43
 		);
44 44
 		// and some coffeemakers, one for creating new instances
45 45
 		$this->CoffeeShop->addCoffeeMaker(
46
-			new NewCoffeeMaker( $this->CoffeeShop, $this->DependencyInjector ),
46
+			new NewCoffeeMaker($this->CoffeeShop, $this->DependencyInjector),
47 47
 			CoffeeMaker::BREW_NEW
48 48
 		);
49 49
 		// one for shared services
50 50
 		$this->CoffeeShop->addCoffeeMaker(
51
-			new SharedCoffeeMaker( $this->CoffeeShop, $this->DependencyInjector ),
51
+			new SharedCoffeeMaker($this->CoffeeShop, $this->DependencyInjector),
52 52
 			CoffeeMaker::BREW_SHARED
53 53
 		);
54 54
 		// and one for classes that only get loaded
55 55
 		$this->CoffeeShop->addCoffeeMaker(
56
-			new LoadOnlyCoffeeMaker( $this->CoffeeShop, $this->DependencyInjector ),
56
+			new LoadOnlyCoffeeMaker($this->CoffeeShop, $this->DependencyInjector),
57 57
 			CoffeeMaker::BREW_LOAD_ONLY
58 58
 		);
59 59
 		// add default recipe, which should handle loading for most PSR-4 compatible classes
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
                 array(),
115 115
 				CoffeeMaker::BREW_LOAD_ONLY,
116 116
                 array(
117
-                    EE_INTERFACES . '*.php',
118
-                    EE_INTERFACES . '*.interfaces.php',
117
+                    EE_INTERFACES.'*.php',
118
+                    EE_INTERFACES.'*.interfaces.php',
119 119
                 )
120 120
 			)
121 121
 		);
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
                 array(),
128 128
                 array(),
129 129
 				CoffeeMaker::BREW_SHARED,
130
-				EE_MODELS . '*.model.php'
130
+				EE_MODELS.'*.model.php'
131 131
 			)
132 132
 		);
133 133
 		// add a wildcard recipe for loading core classes
@@ -139,12 +139,12 @@  discard block
 block discarded – undo
139 139
                 array(),
140 140
                 CoffeeMaker::BREW_SHARED,
141 141
 				array(
142
-					EE_CORE . '*.core.php',
143
-					EE_ADMIN . '*.core.php',
144
-					EE_CPTS . '*.core.php',
145
-					EE_CORE . 'data_migration_scripts' . DS . '*.core.php',
146
-					EE_CORE . 'request_stack' . DS . '*.core.php',
147
-					EE_CORE . 'middleware' . DS . '*.core.php',
142
+					EE_CORE.'*.core.php',
143
+					EE_ADMIN.'*.core.php',
144
+					EE_CPTS.'*.core.php',
145
+					EE_CORE.'data_migration_scripts'.DS.'*.core.php',
146
+					EE_CORE.'request_stack'.DS.'*.core.php',
147
+					EE_CORE.'middleware'.DS.'*.core.php',
148 148
 				)
149 149
 			)
150 150
 		);
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
                 array(),
157 157
                 array(),
158 158
                 CoffeeMaker::BREW_LOAD_ONLY,
159
-				array( EE_ADMIN . '*.core.php' )
159
+				array(EE_ADMIN.'*.core.php')
160 160
 			)
161 161
 		);
162 162
 		// add a wildcard recipe for loading core classes
Please login to merge, or discard this patch.
core/services/container/Recipe.php 2 patches
Indentation   +308 added lines, -308 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 use RuntimeException;
8 8
 
9 9
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
10
-    exit('No direct script access allowed');
10
+	exit('No direct script access allowed');
11 11
 }
12 12
 
13 13
 
@@ -23,313 +23,313 @@  discard block
 block discarded – undo
23 23
 class Recipe implements RecipeInterface
24 24
 {
25 25
 
26
-    /**
27
-     * A default Recipe to use if none is specified for a class
28
-     */
29
-    const DEFAULT_ID = '*';
30
-
31
-    /**
32
-     * Identifier for the entity class to be constructed.
33
-     * Typically a Fully Qualified Class Name
34
-     *
35
-     * @var string $identifier
36
-     */
37
-    private $identifier;
38
-
39
-    /**
40
-     * Fully Qualified Class Name
41
-     *
42
-     * @var string $fqcn
43
-     */
44
-    private $fqcn;
45
-
46
-    /**
47
-     * a dependency class map array
48
-     * If a Recipe is for a single class (or group of classes that shares the EXACT SAME constructor arguments),
49
-     * and that class type hints for an interface, then this property allows you to configure what dependencies
50
-     * get used when instantiating the class.
51
-     * For example:
52
-     *  There's a class called Coffee, and one of its constructor arguments is BeanInterface
53
-     *  There are two implementations of BeanInterface: HonduranBean, and KenyanBean
54
-     *  We want one Coffee object to use HonduranBean for its BeanInterface,
55
-     *  and the 2nd Coffee object to use KenyanBean for its BeanInterface.
56
-     *  To do this, we need to create two Recipes:
57
-     *      one with an identifier of 'HonduranCoffee' using the following ingredients :
58
-     *          array('BeanInterface' => 'HonduranBean')
59
-     *      and the other with an identifier of 'KenyanCoffee' using the following ingredients :
60
-     *          array('BeanInterface' => 'KenyanBean')
61
-     *  Then, whenever the CoffeeShop brews an instance of HonduranCoffee,
62
-     *  an instance of HonduranBean will get injected for the BeanInterface dependency,
63
-     *  and whenever the CoffeeShop brews an instance of KenyanCoffee,
64
-     *  an instance of KenyanBean will get injected for the BeanInterface dependency
65
-     *
66
-     * @var array $ingredients
67
-     */
68
-    private $ingredients = array();
69
-
70
-    /**
71
-     * one of the class constants from CoffeeShop:
72
-     *  CoffeeMaker::BREW_NEW - creates a new instance
73
-     *  CoffeeMaker::BREW_SHARED - creates a shared instance
74
-     *  CoffeeMaker::BREW_LOAD_ONLY - loads but does not instantiate
75
-     *
76
-     * @var string $type
77
-     */
78
-    private $type;
79
-
80
-    /**
81
-     * class name aliases - typically a Fully Qualified Interface that the class implements
82
-     * identifiers passed to the CoffeeShop will be run through the filters to find the correct class name
83
-     *
84
-     * @var array $filters
85
-     */
86
-    private $filters = array();
87
-
88
-    /**
89
-     * array of full server filepaths to files that may contain the class
90
-     *
91
-     * @var array $paths
92
-     */
93
-    private $paths = array();
94
-
95
-
96
-
97
-    /**
98
-     * Recipe constructor.
99
-     *
100
-     * @param string $identifier    class identifier, can be an alias, or FQCN, or whatever
101
-     * @param string $fqcn          \Fully\Qualified\ClassName, optional if $identifier is FQCN
102
-     * @param array  $ingredients   array of dependencies that can not be resolved automatically,
103
-     *                              used for resolving concrete classes for type hinted interfaces
104
-     *                              for the dependencies of THIS class
105
-     * @param string $type          recipe type: one of the class constants on
106
-     *                              \EventEspresso\core\services\container\CoffeeMaker
107
-     * @param array  $filters       array of class aliases, or class interfaces
108
-     *                              this works somewhat opposite to the $ingredients array above,
109
-     *                              in that this array specifies interfaces or aliases
110
-     *                              that this Recipe can be used for when resolving OTHER class's dependencies
111
-     * @param array  $paths         if class can not be loaded via PSR-4 autoloading,
112
-     *                              then supply a filepath, or array of filepaths, so that it can be included
113
-     */
114
-    public function __construct(
115
-	    $identifier,
116
-        $fqcn = '',
117
-        $filters = array(),
118
-        $ingredients = array(),
119
-	    $type = CoffeeMaker::BREW_NEW,
120
-	    $paths = array()
121
-    )
122
-    {
123
-        $this->setIdentifier($identifier);
124
-        $this->setFilters((array)$filters);
125
-        $this->setIngredients((array)$ingredients);
126
-        $this->setType($type);
127
-        $this->setPaths($paths);
128
-        $this->setFqcn($fqcn);
129
-    }
130
-
131
-
132
-
133
-    /**
134
-     * @return string
135
-     */
136
-    public function identifier()
137
-    {
138
-        return $this->identifier;
139
-    }
140
-
141
-
142
-
143
-    /**
144
-     * @return string
145
-     */
146
-    public function fqcn()
147
-    {
148
-        return $this->fqcn;
149
-    }
150
-
151
-
152
-
153
-    /**
154
-     * @return array
155
-     */
156
-    public function filters()
157
-    {
158
-        return (array)$this->filters;
159
-    }
160
-
161
-
162
-
163
-    /**
164
-     * @return array
165
-     */
166
-    public function ingredients()
167
-    {
168
-        return $this->ingredients;
169
-    }
170
-
171
-
172
-
173
-    /**
174
-     * @return string
175
-     */
176
-    public function type()
177
-    {
178
-        return $this->type;
179
-    }
180
-
181
-
182
-
183
-    /**
184
-     * @return array
185
-     */
186
-    public function paths()
187
-    {
188
-        return (array)$this->paths;
189
-    }
190
-
191
-
192
-
193
-    /**
194
-     * @param  string $identifier Identifier for the entity class that the Recipe applies to
195
-     *                            Typically a Fully Qualified Class Name
196
-     */
197
-    public function setIdentifier($identifier)
198
-    {
199
-        if ( ! is_string($identifier) || empty($identifier)) {
200
-            throw new InvalidIdentifierException(
201
-                is_object($identifier) ? get_class($identifier) : gettype($identifier),
202
-                __('class identifier (typically a \Fully\Qualified\ClassName)', 'event_espresso')
203
-            );
204
-        }
205
-        $this->identifier = $identifier;
206
-    }
207
-
208
-
209
-
210
-    /**
211
-     * Ensures incoming string is a valid Fully Qualified Class Name,
212
-     * except if this is the default wildcard Recipe ( * ),
213
-     * or it's NOT an actual FQCN because the Recipe is using filepaths
214
-     * for classes that are not PSR-4 compatible
215
-     * PLZ NOTE:
216
-     *  Recipe::setFqcn() has a check to see if Recipe::$paths is empty or not,
217
-     *  therefore you should always call Recipe::setPaths() before Recipe::setFqcn()
218
-     *
219
-     * @param string $fqcn
220
-     */
221
-    public function setFqcn($fqcn)
222
-    {
223
-	    $fqcn = ! empty($fqcn) ? $fqcn : $this->identifier;
224
-        if ( ! is_string($fqcn)) {
225
-            throw new InvalidDataTypeException(
226
-                '$fqcn',
227
-                is_object($fqcn) ? get_class($fqcn) : gettype($fqcn),
228
-                __('string (Fully\Qualified\ClassName)', 'event_espresso')
229
-            );
230
-        }
231
-        $fqcn = ltrim($fqcn, '\\');
232
-        if (
233
-            $fqcn !== Recipe::DEFAULT_ID
234
-            && ! empty($fqcn)
235
-            && empty($this->paths)
236
-            && ! class_exists($fqcn)
237
-        ) {
238
-            throw new InvalidClassException($fqcn);
239
-        }
240
-        $this->fqcn = $fqcn;
241
-    }
242
-
243
-
244
-
245
-    /**
246
-     * @param array $ingredients    an array of dependencies where keys are the aliases and values are the FQCNs
247
-     *                              example:
248
-     *                              array( 'ClassInterface' => 'Fully\Qualified\ClassName' )
249
-     */
250
-    public function setIngredients(array $ingredients)
251
-    {
252
-        if (empty($ingredients)) {
253
-            return;
254
-        }
255
-        if ( ! is_array($ingredients)) {
256
-            throw new InvalidDataTypeException(
257
-                '$ingredients',
258
-                is_object($ingredients) ? get_class($ingredients) : gettype($ingredients),
259
-                __('array of class dependencies', 'event_espresso')
260
-            );
261
-        }
262
-        $this->ingredients = array_merge($this->ingredients, $ingredients);
263
-    }
264
-
265
-
266
-    /**
267
-     * @param string $type one of the class constants returned from CoffeeMaker::getTypes()
268
-     */
269
-    public function setType($type = CoffeeMaker::BREW_NEW)
270
-    {
271
-        $this->type = CoffeeMaker::validateType($type);
272
-    }
273
-
274
-
275
-
276
-    /**
277
-     * @param array $filters an array of filters where keys are the aliases and values are the FQCNs
278
-     *                          example:
279
-     *                          array( 'ClassInterface' => 'Fully\Qualified\ClassName' )
280
-     */
281
-    public function setFilters(array $filters)
282
-    {
283
-        if (empty($filters)) {
284
-            return;
285
-        }
286
-        if ( ! is_array($filters)) {
287
-            throw new InvalidDataTypeException(
288
-                '$filters',
289
-                is_object($filters) ? get_class($filters) : gettype($filters),
290
-                __('array of class aliases', 'event_espresso')
291
-            );
292
-        }
293
-        $this->filters = array_merge($this->filters, $filters);
294
-    }
295
-
296
-
297
-
298
-    /**
299
-     * Ensures incoming paths is a valid filepath, or array of valid filepaths,
300
-     * and merges them in with any existing filepaths
301
-     *
302
-     * PLZ NOTE:
303
-     *  Recipe::setFqcn() has a check to see if Recipe::$paths is empty or not,
304
-     *  therefore you should always call Recipe::setPaths() before Recipe::setFqcn()
305
-     *
306
-     * @param string|array $paths
307
-     */
308
-    public function setPaths($paths = array())
309
-    {
310
-        if (empty($paths)) {
311
-            return;
312
-        }
313
-        if ( ! (is_string($paths) || is_array($paths))) {
314
-            throw new InvalidDataTypeException(
315
-                '$path',
316
-                is_object($paths) ? get_class($paths) : gettype($paths),
317
-                __('string or array of strings (full server filepath(s))', 'event_espresso')
318
-            );
319
-        }
320
-        $paths = (array)$paths;
321
-        foreach ($paths as $path) {
322
-            if (strpos($path, '*') === false && ! is_readable($path)) {
323
-                throw new RuntimeException(
324
-                    sprintf(
325
-                        __('The following filepath is not readable: "%1$s"', 'event_espresso'),
326
-                        $path
327
-                    )
328
-                );
329
-            }
330
-        }
331
-        $this->paths = array_merge($this->paths, $paths);
332
-    }
26
+	/**
27
+	 * A default Recipe to use if none is specified for a class
28
+	 */
29
+	const DEFAULT_ID = '*';
30
+
31
+	/**
32
+	 * Identifier for the entity class to be constructed.
33
+	 * Typically a Fully Qualified Class Name
34
+	 *
35
+	 * @var string $identifier
36
+	 */
37
+	private $identifier;
38
+
39
+	/**
40
+	 * Fully Qualified Class Name
41
+	 *
42
+	 * @var string $fqcn
43
+	 */
44
+	private $fqcn;
45
+
46
+	/**
47
+	 * a dependency class map array
48
+	 * If a Recipe is for a single class (or group of classes that shares the EXACT SAME constructor arguments),
49
+	 * and that class type hints for an interface, then this property allows you to configure what dependencies
50
+	 * get used when instantiating the class.
51
+	 * For example:
52
+	 *  There's a class called Coffee, and one of its constructor arguments is BeanInterface
53
+	 *  There are two implementations of BeanInterface: HonduranBean, and KenyanBean
54
+	 *  We want one Coffee object to use HonduranBean for its BeanInterface,
55
+	 *  and the 2nd Coffee object to use KenyanBean for its BeanInterface.
56
+	 *  To do this, we need to create two Recipes:
57
+	 *      one with an identifier of 'HonduranCoffee' using the following ingredients :
58
+	 *          array('BeanInterface' => 'HonduranBean')
59
+	 *      and the other with an identifier of 'KenyanCoffee' using the following ingredients :
60
+	 *          array('BeanInterface' => 'KenyanBean')
61
+	 *  Then, whenever the CoffeeShop brews an instance of HonduranCoffee,
62
+	 *  an instance of HonduranBean will get injected for the BeanInterface dependency,
63
+	 *  and whenever the CoffeeShop brews an instance of KenyanCoffee,
64
+	 *  an instance of KenyanBean will get injected for the BeanInterface dependency
65
+	 *
66
+	 * @var array $ingredients
67
+	 */
68
+	private $ingredients = array();
69
+
70
+	/**
71
+	 * one of the class constants from CoffeeShop:
72
+	 *  CoffeeMaker::BREW_NEW - creates a new instance
73
+	 *  CoffeeMaker::BREW_SHARED - creates a shared instance
74
+	 *  CoffeeMaker::BREW_LOAD_ONLY - loads but does not instantiate
75
+	 *
76
+	 * @var string $type
77
+	 */
78
+	private $type;
79
+
80
+	/**
81
+	 * class name aliases - typically a Fully Qualified Interface that the class implements
82
+	 * identifiers passed to the CoffeeShop will be run through the filters to find the correct class name
83
+	 *
84
+	 * @var array $filters
85
+	 */
86
+	private $filters = array();
87
+
88
+	/**
89
+	 * array of full server filepaths to files that may contain the class
90
+	 *
91
+	 * @var array $paths
92
+	 */
93
+	private $paths = array();
94
+
95
+
96
+
97
+	/**
98
+	 * Recipe constructor.
99
+	 *
100
+	 * @param string $identifier    class identifier, can be an alias, or FQCN, or whatever
101
+	 * @param string $fqcn          \Fully\Qualified\ClassName, optional if $identifier is FQCN
102
+	 * @param array  $ingredients   array of dependencies that can not be resolved automatically,
103
+	 *                              used for resolving concrete classes for type hinted interfaces
104
+	 *                              for the dependencies of THIS class
105
+	 * @param string $type          recipe type: one of the class constants on
106
+	 *                              \EventEspresso\core\services\container\CoffeeMaker
107
+	 * @param array  $filters       array of class aliases, or class interfaces
108
+	 *                              this works somewhat opposite to the $ingredients array above,
109
+	 *                              in that this array specifies interfaces or aliases
110
+	 *                              that this Recipe can be used for when resolving OTHER class's dependencies
111
+	 * @param array  $paths         if class can not be loaded via PSR-4 autoloading,
112
+	 *                              then supply a filepath, or array of filepaths, so that it can be included
113
+	 */
114
+	public function __construct(
115
+		$identifier,
116
+		$fqcn = '',
117
+		$filters = array(),
118
+		$ingredients = array(),
119
+		$type = CoffeeMaker::BREW_NEW,
120
+		$paths = array()
121
+	)
122
+	{
123
+		$this->setIdentifier($identifier);
124
+		$this->setFilters((array)$filters);
125
+		$this->setIngredients((array)$ingredients);
126
+		$this->setType($type);
127
+		$this->setPaths($paths);
128
+		$this->setFqcn($fqcn);
129
+	}
130
+
131
+
132
+
133
+	/**
134
+	 * @return string
135
+	 */
136
+	public function identifier()
137
+	{
138
+		return $this->identifier;
139
+	}
140
+
141
+
142
+
143
+	/**
144
+	 * @return string
145
+	 */
146
+	public function fqcn()
147
+	{
148
+		return $this->fqcn;
149
+	}
150
+
151
+
152
+
153
+	/**
154
+	 * @return array
155
+	 */
156
+	public function filters()
157
+	{
158
+		return (array)$this->filters;
159
+	}
160
+
161
+
162
+
163
+	/**
164
+	 * @return array
165
+	 */
166
+	public function ingredients()
167
+	{
168
+		return $this->ingredients;
169
+	}
170
+
171
+
172
+
173
+	/**
174
+	 * @return string
175
+	 */
176
+	public function type()
177
+	{
178
+		return $this->type;
179
+	}
180
+
181
+
182
+
183
+	/**
184
+	 * @return array
185
+	 */
186
+	public function paths()
187
+	{
188
+		return (array)$this->paths;
189
+	}
190
+
191
+
192
+
193
+	/**
194
+	 * @param  string $identifier Identifier for the entity class that the Recipe applies to
195
+	 *                            Typically a Fully Qualified Class Name
196
+	 */
197
+	public function setIdentifier($identifier)
198
+	{
199
+		if ( ! is_string($identifier) || empty($identifier)) {
200
+			throw new InvalidIdentifierException(
201
+				is_object($identifier) ? get_class($identifier) : gettype($identifier),
202
+				__('class identifier (typically a \Fully\Qualified\ClassName)', 'event_espresso')
203
+			);
204
+		}
205
+		$this->identifier = $identifier;
206
+	}
207
+
208
+
209
+
210
+	/**
211
+	 * Ensures incoming string is a valid Fully Qualified Class Name,
212
+	 * except if this is the default wildcard Recipe ( * ),
213
+	 * or it's NOT an actual FQCN because the Recipe is using filepaths
214
+	 * for classes that are not PSR-4 compatible
215
+	 * PLZ NOTE:
216
+	 *  Recipe::setFqcn() has a check to see if Recipe::$paths is empty or not,
217
+	 *  therefore you should always call Recipe::setPaths() before Recipe::setFqcn()
218
+	 *
219
+	 * @param string $fqcn
220
+	 */
221
+	public function setFqcn($fqcn)
222
+	{
223
+		$fqcn = ! empty($fqcn) ? $fqcn : $this->identifier;
224
+		if ( ! is_string($fqcn)) {
225
+			throw new InvalidDataTypeException(
226
+				'$fqcn',
227
+				is_object($fqcn) ? get_class($fqcn) : gettype($fqcn),
228
+				__('string (Fully\Qualified\ClassName)', 'event_espresso')
229
+			);
230
+		}
231
+		$fqcn = ltrim($fqcn, '\\');
232
+		if (
233
+			$fqcn !== Recipe::DEFAULT_ID
234
+			&& ! empty($fqcn)
235
+			&& empty($this->paths)
236
+			&& ! class_exists($fqcn)
237
+		) {
238
+			throw new InvalidClassException($fqcn);
239
+		}
240
+		$this->fqcn = $fqcn;
241
+	}
242
+
243
+
244
+
245
+	/**
246
+	 * @param array $ingredients    an array of dependencies where keys are the aliases and values are the FQCNs
247
+	 *                              example:
248
+	 *                              array( 'ClassInterface' => 'Fully\Qualified\ClassName' )
249
+	 */
250
+	public function setIngredients(array $ingredients)
251
+	{
252
+		if (empty($ingredients)) {
253
+			return;
254
+		}
255
+		if ( ! is_array($ingredients)) {
256
+			throw new InvalidDataTypeException(
257
+				'$ingredients',
258
+				is_object($ingredients) ? get_class($ingredients) : gettype($ingredients),
259
+				__('array of class dependencies', 'event_espresso')
260
+			);
261
+		}
262
+		$this->ingredients = array_merge($this->ingredients, $ingredients);
263
+	}
264
+
265
+
266
+	/**
267
+	 * @param string $type one of the class constants returned from CoffeeMaker::getTypes()
268
+	 */
269
+	public function setType($type = CoffeeMaker::BREW_NEW)
270
+	{
271
+		$this->type = CoffeeMaker::validateType($type);
272
+	}
273
+
274
+
275
+
276
+	/**
277
+	 * @param array $filters an array of filters where keys are the aliases and values are the FQCNs
278
+	 *                          example:
279
+	 *                          array( 'ClassInterface' => 'Fully\Qualified\ClassName' )
280
+	 */
281
+	public function setFilters(array $filters)
282
+	{
283
+		if (empty($filters)) {
284
+			return;
285
+		}
286
+		if ( ! is_array($filters)) {
287
+			throw new InvalidDataTypeException(
288
+				'$filters',
289
+				is_object($filters) ? get_class($filters) : gettype($filters),
290
+				__('array of class aliases', 'event_espresso')
291
+			);
292
+		}
293
+		$this->filters = array_merge($this->filters, $filters);
294
+	}
295
+
296
+
297
+
298
+	/**
299
+	 * Ensures incoming paths is a valid filepath, or array of valid filepaths,
300
+	 * and merges them in with any existing filepaths
301
+	 *
302
+	 * PLZ NOTE:
303
+	 *  Recipe::setFqcn() has a check to see if Recipe::$paths is empty or not,
304
+	 *  therefore you should always call Recipe::setPaths() before Recipe::setFqcn()
305
+	 *
306
+	 * @param string|array $paths
307
+	 */
308
+	public function setPaths($paths = array())
309
+	{
310
+		if (empty($paths)) {
311
+			return;
312
+		}
313
+		if ( ! (is_string($paths) || is_array($paths))) {
314
+			throw new InvalidDataTypeException(
315
+				'$path',
316
+				is_object($paths) ? get_class($paths) : gettype($paths),
317
+				__('string or array of strings (full server filepath(s))', 'event_espresso')
318
+			);
319
+		}
320
+		$paths = (array)$paths;
321
+		foreach ($paths as $path) {
322
+			if (strpos($path, '*') === false && ! is_readable($path)) {
323
+				throw new RuntimeException(
324
+					sprintf(
325
+						__('The following filepath is not readable: "%1$s"', 'event_espresso'),
326
+						$path
327
+					)
328
+				);
329
+			}
330
+		}
331
+		$this->paths = array_merge($this->paths, $paths);
332
+	}
333 333
 
334 334
 
335 335
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
     )
122 122
     {
123 123
         $this->setIdentifier($identifier);
124
-        $this->setFilters((array)$filters);
125
-        $this->setIngredients((array)$ingredients);
124
+        $this->setFilters((array) $filters);
125
+        $this->setIngredients((array) $ingredients);
126 126
         $this->setType($type);
127 127
         $this->setPaths($paths);
128 128
         $this->setFqcn($fqcn);
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
      */
156 156
     public function filters()
157 157
     {
158
-        return (array)$this->filters;
158
+        return (array) $this->filters;
159 159
     }
160 160
 
161 161
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
      */
186 186
     public function paths()
187 187
     {
188
-        return (array)$this->paths;
188
+        return (array) $this->paths;
189 189
     }
190 190
 
191 191
 
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
                 __('string or array of strings (full server filepath(s))', 'event_espresso')
318 318
             );
319 319
         }
320
-        $paths = (array)$paths;
320
+        $paths = (array) $paths;
321 321
         foreach ($paths as $path) {
322 322
             if (strpos($path, '*') === false && ! is_readable($path)) {
323 323
                 throw new RuntimeException(
Please login to merge, or discard this patch.
core/services/container/DependencyInjector.php 1 patch
Indentation   +209 added lines, -209 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 use UnexpectedValueException;
5 5
 
6 6
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
7
-    exit('No direct script access allowed');
7
+	exit('No direct script access allowed');
8 8
 }
9 9
 
10 10
 
@@ -22,214 +22,214 @@  discard block
 block discarded – undo
22 22
 class DependencyInjector implements InjectorInterface
23 23
 {
24 24
 
25
-    /**
26
-     * @var CoffeePotInterface $coffee_pot
27
-     */
28
-    private $coffee_pot;
29
-
30
-    /**
31
-     * @var \EEH_Array $array_helper
32
-     */
33
-    private $array_helper;
34
-
35
-    /**
36
-     * @var \ReflectionClass[] $reflectors
37
-     */
38
-    private $reflectors;
39
-
40
-    /**
41
-     * @var \ReflectionMethod[] $constructors
42
-     */
43
-    private $constructors;
44
-
45
-    /**
46
-     * @var \ReflectionParameter[] $parameters
47
-     */
48
-    private $parameters;
49
-
50
-
51
-
52
-    /**
53
-     * DependencyInjector constructor
54
-     *
55
-     * @param CoffeePotInterface $coffee_pot
56
-     * @param \EEH_Array         $array_helper
57
-     */
58
-    public function __construct(CoffeePotInterface $coffee_pot, \EEH_Array $array_helper)
59
-    {
60
-        $this->coffee_pot = $coffee_pot;
61
-        $this->array_helper = $array_helper;
62
-    }
63
-
64
-
65
-
66
-    /**
67
-     * getReflectionClass
68
-     * checks if a ReflectionClass object has already been generated for a class
69
-     * and returns that instead of creating a new one
70
-     *
71
-     * @param string $class_name
72
-     * @return \ReflectionClass
73
-     */
74
-    public function getReflectionClass($class_name)
75
-    {
76
-        if (
77
-            ! isset($this->reflectors[$class_name])
78
-            || ! $this->reflectors[$class_name] instanceof \ReflectionClass
79
-        ) {
80
-            $this->reflectors[$class_name] = new \ReflectionClass($class_name);
81
-        }
82
-        return $this->reflectors[$class_name];
83
-    }
84
-
85
-
86
-
87
-    /**
88
-     * getConstructor
89
-     * checks if a ReflectionMethod object has already been generated for the class constructor
90
-     * and returns that instead of creating a new one
91
-     *
92
-     * @param \ReflectionClass $reflector
93
-     * @return \ReflectionMethod
94
-     */
95
-    protected function getConstructor(\ReflectionClass $reflector)
96
-    {
97
-        if (
98
-            ! isset($this->constructors[$reflector->getName()])
99
-            || ! $this->constructors[$reflector->getName()] instanceof \ReflectionMethod
100
-        ) {
101
-            $this->constructors[$reflector->getName()] = $reflector->getConstructor();
102
-        }
103
-        return $this->constructors[$reflector->getName()];
104
-    }
105
-
106
-
107
-
108
-    /**
109
-     * getParameters
110
-     * checks if an array of ReflectionParameter objects has already been generated for the class constructor
111
-     * and returns that instead of creating a new one
112
-     *
113
-     * @param \ReflectionMethod $constructor
114
-     * @return \ReflectionParameter[]
115
-     */
116
-    protected function getParameters(\ReflectionMethod $constructor)
117
-    {
118
-        if ( ! isset($this->parameters[$constructor->class])) {
119
-            $this->parameters[$constructor->class] = $constructor->getParameters();
120
-        }
121
-        return $this->parameters[$constructor->class];
122
-    }
123
-
124
-
125
-
126
-    /**
127
-     * resolveDependencies
128
-     * examines the constructor for the requested class to determine
129
-     * if any dependencies exist, and if they can be injected.
130
-     * If so, then those classes will be added to the array of arguments passed to the constructor
131
-     * PLZ NOTE: this is achieved by type hinting the constructor params
132
-     * For example:
133
-     *        if attempting to load a class "Foo" with the following constructor:
134
-     *        __construct( Bar $bar_class, Fighter $grohl_class )
135
-     *        then $bar_class and $grohl_class will be added to the $arguments array,
136
-     *        but only IF they are NOT already present in the incoming arguments array,
137
-     *        and the correct classes can be loaded
138
-     *
139
-     * @param RecipeInterface   $recipe
140
-     * @param \ReflectionClass  $reflector
141
-     * @param array             $arguments
142
-     * @return array
143
-     */
144
-    public function resolveDependencies(RecipeInterface $recipe, \ReflectionClass $reflector, $arguments = array())
145
-    {
146
-        // if arguments array is numerically and sequentially indexed, then we want it to remain as is,
147
-        // else wrap it in an additional array so that it doesn't get split into multiple parameters
148
-        $arguments = $this->array_helper->is_array_numerically_and_sequentially_indexed($arguments)
149
-            ? $arguments
150
-            : array($arguments);
151
-        $resolved_parameters = array();
152
-        // let's examine the constructor
153
-        // let's examine the constructor
154
-        $constructor = $this->getConstructor($reflector);
155
-        // whu? huh? nothing?
156
-        if ( ! $constructor) {
157
-            return $arguments;
158
-        }
159
-        // get constructor parameters
160
-        $params = $this->getParameters($constructor);
161
-        if (empty($params)) {
162
-            return $resolved_parameters;
163
-        }
164
-        $ingredients = $recipe->ingredients();
165
-        // and the keys for the incoming arguments array so that we can compare existing arguments with what is expected
166
-        $argument_keys = array_keys($arguments);
167
-        // now loop thru all of the constructors expected parameters
168
-        foreach ($params as $index => $param) {
169
-            if ( ! $param instanceof \ReflectionParameter) {
170
-                continue;
171
-            }
172
-            // is this a dependency for a specific class ?
173
-            $param_class = $param->getClass() ? $param->getClass()->name : null;
174
-            if (
175
-                // param is specified in the list of ingredients for this Recipe
176
-                isset($ingredients[$param_class])
177
-            ) {
178
-                // attempt to inject the dependency
179
-                $resolved_parameters[$index] = $this->injectDependency($ingredients[$param_class]);
180
-            } else if (
181
-                // param is not even a class
182
-                empty($param_class)
183
-                // and something already exists in the incoming arguments for this param
184
-                && isset($argument_keys[$index], $arguments[$argument_keys[$index]])
185
-            ) {
186
-                // add parameter from incoming arguments
187
-                $resolved_parameters[$index] = $arguments[$argument_keys[$index]];
188
-            } else if (
189
-                // parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class
190
-                ! empty($param_class)
191
-                && isset($argument_keys[$index], $arguments[$argument_keys[$index]])
192
-                && $arguments[$argument_keys[$index]] instanceof $param_class
193
-            ) {
194
-                // add parameter from incoming arguments
195
-                $resolved_parameters[$index] = $arguments[$argument_keys[$index]];
196
-            } else if (
197
-                // parameter is type hinted as a class, and should be injected
198
-            ! empty($param_class)
199
-            ) {
200
-                // attempt to inject the dependency
201
-                $resolved_parameters[$index] = $this->injectDependency($param_class);
202
-            } else if ($param->isOptional()) {
203
-                $resolved_parameters[$index] = $param->getDefaultValue();
204
-            } else {
205
-                $resolved_parameters[$index] = null;
206
-            }
207
-        }
208
-        return $resolved_parameters;
209
-    }
210
-
211
-
212
-
213
-    /**
214
-     * @param string $param_class
215
-     * @return mixed
216
-     */
217
-    private function injectDependency($param_class)
218
-    {
219
-        $dependency = $this->coffee_pot->brew($param_class);
220
-        if ( ! $dependency instanceof $param_class) {
221
-            throw new UnexpectedValueException(
222
-                sprintf(
223
-                    __(
224
-                        'Could not resolve dependency for "%1$s" for the "%2$s" class constructor.',
225
-                        'event_espresso'
226
-                    ),
227
-                    $param_class
228
-                )
229
-            );
230
-        }
231
-        return $dependency;
232
-    }
25
+	/**
26
+	 * @var CoffeePotInterface $coffee_pot
27
+	 */
28
+	private $coffee_pot;
29
+
30
+	/**
31
+	 * @var \EEH_Array $array_helper
32
+	 */
33
+	private $array_helper;
34
+
35
+	/**
36
+	 * @var \ReflectionClass[] $reflectors
37
+	 */
38
+	private $reflectors;
39
+
40
+	/**
41
+	 * @var \ReflectionMethod[] $constructors
42
+	 */
43
+	private $constructors;
44
+
45
+	/**
46
+	 * @var \ReflectionParameter[] $parameters
47
+	 */
48
+	private $parameters;
49
+
50
+
51
+
52
+	/**
53
+	 * DependencyInjector constructor
54
+	 *
55
+	 * @param CoffeePotInterface $coffee_pot
56
+	 * @param \EEH_Array         $array_helper
57
+	 */
58
+	public function __construct(CoffeePotInterface $coffee_pot, \EEH_Array $array_helper)
59
+	{
60
+		$this->coffee_pot = $coffee_pot;
61
+		$this->array_helper = $array_helper;
62
+	}
63
+
64
+
65
+
66
+	/**
67
+	 * getReflectionClass
68
+	 * checks if a ReflectionClass object has already been generated for a class
69
+	 * and returns that instead of creating a new one
70
+	 *
71
+	 * @param string $class_name
72
+	 * @return \ReflectionClass
73
+	 */
74
+	public function getReflectionClass($class_name)
75
+	{
76
+		if (
77
+			! isset($this->reflectors[$class_name])
78
+			|| ! $this->reflectors[$class_name] instanceof \ReflectionClass
79
+		) {
80
+			$this->reflectors[$class_name] = new \ReflectionClass($class_name);
81
+		}
82
+		return $this->reflectors[$class_name];
83
+	}
84
+
85
+
86
+
87
+	/**
88
+	 * getConstructor
89
+	 * checks if a ReflectionMethod object has already been generated for the class constructor
90
+	 * and returns that instead of creating a new one
91
+	 *
92
+	 * @param \ReflectionClass $reflector
93
+	 * @return \ReflectionMethod
94
+	 */
95
+	protected function getConstructor(\ReflectionClass $reflector)
96
+	{
97
+		if (
98
+			! isset($this->constructors[$reflector->getName()])
99
+			|| ! $this->constructors[$reflector->getName()] instanceof \ReflectionMethod
100
+		) {
101
+			$this->constructors[$reflector->getName()] = $reflector->getConstructor();
102
+		}
103
+		return $this->constructors[$reflector->getName()];
104
+	}
105
+
106
+
107
+
108
+	/**
109
+	 * getParameters
110
+	 * checks if an array of ReflectionParameter objects has already been generated for the class constructor
111
+	 * and returns that instead of creating a new one
112
+	 *
113
+	 * @param \ReflectionMethod $constructor
114
+	 * @return \ReflectionParameter[]
115
+	 */
116
+	protected function getParameters(\ReflectionMethod $constructor)
117
+	{
118
+		if ( ! isset($this->parameters[$constructor->class])) {
119
+			$this->parameters[$constructor->class] = $constructor->getParameters();
120
+		}
121
+		return $this->parameters[$constructor->class];
122
+	}
123
+
124
+
125
+
126
+	/**
127
+	 * resolveDependencies
128
+	 * examines the constructor for the requested class to determine
129
+	 * if any dependencies exist, and if they can be injected.
130
+	 * If so, then those classes will be added to the array of arguments passed to the constructor
131
+	 * PLZ NOTE: this is achieved by type hinting the constructor params
132
+	 * For example:
133
+	 *        if attempting to load a class "Foo" with the following constructor:
134
+	 *        __construct( Bar $bar_class, Fighter $grohl_class )
135
+	 *        then $bar_class and $grohl_class will be added to the $arguments array,
136
+	 *        but only IF they are NOT already present in the incoming arguments array,
137
+	 *        and the correct classes can be loaded
138
+	 *
139
+	 * @param RecipeInterface   $recipe
140
+	 * @param \ReflectionClass  $reflector
141
+	 * @param array             $arguments
142
+	 * @return array
143
+	 */
144
+	public function resolveDependencies(RecipeInterface $recipe, \ReflectionClass $reflector, $arguments = array())
145
+	{
146
+		// if arguments array is numerically and sequentially indexed, then we want it to remain as is,
147
+		// else wrap it in an additional array so that it doesn't get split into multiple parameters
148
+		$arguments = $this->array_helper->is_array_numerically_and_sequentially_indexed($arguments)
149
+			? $arguments
150
+			: array($arguments);
151
+		$resolved_parameters = array();
152
+		// let's examine the constructor
153
+		// let's examine the constructor
154
+		$constructor = $this->getConstructor($reflector);
155
+		// whu? huh? nothing?
156
+		if ( ! $constructor) {
157
+			return $arguments;
158
+		}
159
+		// get constructor parameters
160
+		$params = $this->getParameters($constructor);
161
+		if (empty($params)) {
162
+			return $resolved_parameters;
163
+		}
164
+		$ingredients = $recipe->ingredients();
165
+		// and the keys for the incoming arguments array so that we can compare existing arguments with what is expected
166
+		$argument_keys = array_keys($arguments);
167
+		// now loop thru all of the constructors expected parameters
168
+		foreach ($params as $index => $param) {
169
+			if ( ! $param instanceof \ReflectionParameter) {
170
+				continue;
171
+			}
172
+			// is this a dependency for a specific class ?
173
+			$param_class = $param->getClass() ? $param->getClass()->name : null;
174
+			if (
175
+				// param is specified in the list of ingredients for this Recipe
176
+				isset($ingredients[$param_class])
177
+			) {
178
+				// attempt to inject the dependency
179
+				$resolved_parameters[$index] = $this->injectDependency($ingredients[$param_class]);
180
+			} else if (
181
+				// param is not even a class
182
+				empty($param_class)
183
+				// and something already exists in the incoming arguments for this param
184
+				&& isset($argument_keys[$index], $arguments[$argument_keys[$index]])
185
+			) {
186
+				// add parameter from incoming arguments
187
+				$resolved_parameters[$index] = $arguments[$argument_keys[$index]];
188
+			} else if (
189
+				// parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class
190
+				! empty($param_class)
191
+				&& isset($argument_keys[$index], $arguments[$argument_keys[$index]])
192
+				&& $arguments[$argument_keys[$index]] instanceof $param_class
193
+			) {
194
+				// add parameter from incoming arguments
195
+				$resolved_parameters[$index] = $arguments[$argument_keys[$index]];
196
+			} else if (
197
+				// parameter is type hinted as a class, and should be injected
198
+			! empty($param_class)
199
+			) {
200
+				// attempt to inject the dependency
201
+				$resolved_parameters[$index] = $this->injectDependency($param_class);
202
+			} else if ($param->isOptional()) {
203
+				$resolved_parameters[$index] = $param->getDefaultValue();
204
+			} else {
205
+				$resolved_parameters[$index] = null;
206
+			}
207
+		}
208
+		return $resolved_parameters;
209
+	}
210
+
211
+
212
+
213
+	/**
214
+	 * @param string $param_class
215
+	 * @return mixed
216
+	 */
217
+	private function injectDependency($param_class)
218
+	{
219
+		$dependency = $this->coffee_pot->brew($param_class);
220
+		if ( ! $dependency instanceof $param_class) {
221
+			throw new UnexpectedValueException(
222
+				sprintf(
223
+					__(
224
+						'Could not resolve dependency for "%1$s" for the "%2$s" class constructor.',
225
+						'event_espresso'
226
+					),
227
+					$param_class
228
+				)
229
+			);
230
+		}
231
+		return $dependency;
232
+	}
233 233
 
234 234
 }
235 235
 // End of file DependencyInjector.php
Please login to merge, or discard this patch.