@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * @author Mike Nelson |
15 | 15 | * |
16 | 16 | */ |
17 | -class EE_Restriction_Generator_Meta extends EE_Restriction_Generator_Base{ |
|
17 | +class EE_Restriction_Generator_Meta extends EE_Restriction_Generator_Base { |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param string $key_field_name |
34 | 34 | * @param string $value_field_name |
35 | 35 | */ |
36 | - public function __construct( $key_field_name, $value_field_name ) { |
|
36 | + public function __construct($key_field_name, $value_field_name) { |
|
37 | 37 | $this->_key_field_name = $key_field_name; |
38 | 38 | $this->_value_field_name = $value_field_name; |
39 | 39 | } |
@@ -45,21 +45,21 @@ discard block |
||
45 | 45 | * @throws EE_Error |
46 | 46 | */ |
47 | 47 | protected function _generate_restrictions() { |
48 | - $whitelisted_meta_keys = apply_filters( 'FHEE__EE_Restriction_Generator_Meta___generate_restrictions__whitelisted_meta_keys', array() ); |
|
49 | - $blacklisted_meta_keys = apply_filters( 'FHEE__EE_Restriction_Generator_Meta___generate_restrictions__blacklisted_meta_keys', array() ); |
|
48 | + $whitelisted_meta_keys = apply_filters('FHEE__EE_Restriction_Generator_Meta___generate_restrictions__whitelisted_meta_keys', array()); |
|
49 | + $blacklisted_meta_keys = apply_filters('FHEE__EE_Restriction_Generator_Meta___generate_restrictions__blacklisted_meta_keys', array()); |
|
50 | 50 | $conditions = array( |
51 | - $this->_key_field_name => array( 'NOT_LIKE', "\\\\_%" ),//each slash is escaped because we are using double quotes, and |
|
51 | + $this->_key_field_name => array('NOT_LIKE', "\\\\_%"), //each slash is escaped because we are using double quotes, and |
|
52 | 52 | //stripslashes will be called on this because the models assume this is from user input |
53 | - $this->_value_field_name => array( 'NOT_REGEXP', '^[aOs]:[\d]:.*$') |
|
53 | + $this->_value_field_name => array('NOT_REGEXP', '^[aOs]:[\d]:.*$') |
|
54 | 54 | ); |
55 | - if( ! empty( $blacklisted_meta_keys ) ) { |
|
56 | - $conditions[ $this->_key_field_name . '*blacklisted' ] = array( 'NOT_IN', $blacklisted_meta_keys ); |
|
55 | + if ( ! empty($blacklisted_meta_keys)) { |
|
56 | + $conditions[$this->_key_field_name.'*blacklisted'] = array('NOT_IN', $blacklisted_meta_keys); |
|
57 | 57 | } |
58 | - if( ! empty( $whitelisted_meta_keys ) ) { |
|
58 | + if ( ! empty($whitelisted_meta_keys)) { |
|
59 | 59 | $conditions = array( |
60 | 60 | 'OR*whitelisted-or-normal' => array( |
61 | 61 | 'AND' => $conditions, |
62 | - $this->_key_field_name . '*whitelisted' => array( 'IN', $whitelisted_meta_keys ) |
|
62 | + $this->_key_field_name.'*whitelisted' => array('IN', $whitelisted_meta_keys) |
|
63 | 63 | ) |
64 | 64 | ); |
65 | 65 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | //only allow access to non-protected metas if they're an admin |
68 | 68 | EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions(), |
69 | 69 | //don't allow access to protected metas to anyone. If they want that, don't apply caps to the query |
70 | - 'apply-to-all-queries-using-caps' => new EE_Default_Where_Conditions( $conditions ), |
|
70 | + 'apply-to-all-queries-using-caps' => new EE_Default_Where_Conditions($conditions), |
|
71 | 71 | ); |
72 | 72 | } |
73 | 73 | } |
@@ -7,6 +7,10 @@ discard block |
||
7 | 7 | |
8 | 8 | protected $_post_type; |
9 | 9 | protected $_meta_field; |
10 | + |
|
11 | + /** |
|
12 | + * @param string $post_type |
|
13 | + */ |
|
10 | 14 | function __construct($post_type, $meta_field_to_chk = ''){ |
11 | 15 | $this->_post_type = $post_type; |
12 | 16 | $this->_meta_field = $meta_field_to_chk; |
@@ -27,7 +31,6 @@ discard block |
||
27 | 31 | } |
28 | 32 | /** |
29 | 33 | * Gets the where default where conditions for a custom post type model |
30 | - * @param string $model_relation_path. Eg, from Event to Payment, this should be "Registration.Transaction.Payment" |
|
31 | 34 | * @return array like EEM_Base::get_all's $query_params's index [0] (where conditions) |
32 | 35 | */ |
33 | 36 | protected function _get_default_where_conditions() { |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | * @since 4.8.29.rc.010 |
16 | 16 | * |
17 | 17 | */ |
18 | -class EE_CPT_Minimum_Where_Conditions extends EE_Default_Where_Conditions{ |
|
18 | +class EE_CPT_Minimum_Where_Conditions extends EE_Default_Where_Conditions { |
|
19 | 19 | |
20 | 20 | protected $_post_type; |
21 | 21 | protected $_meta_field; |
22 | - function __construct($post_type, $meta_field_to_chk = ''){ |
|
22 | + function __construct($post_type, $meta_field_to_chk = '') { |
|
23 | 23 | $this->_post_type = $post_type; |
24 | 24 | $this->_meta_field = $meta_field_to_chk; |
25 | 25 | } |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | * @param string $column column name |
30 | 30 | * @return EE_Model_Field_Base |
31 | 31 | */ |
32 | - protected function _get_field_on_column($column){ |
|
32 | + protected function _get_field_on_column($column) { |
|
33 | 33 | $all_fields = $this->_model->field_settings(true); |
34 | - foreach($all_fields as $field_name => $field_obj){ |
|
35 | - if($column == $field_obj->get_table_column()){ |
|
34 | + foreach ($all_fields as $field_name => $field_obj) { |
|
35 | + if ($column == $field_obj->get_table_column()) { |
|
36 | 36 | return $field_obj; |
37 | 37 | } |
38 | 38 | } |
@@ -5,7 +5,7 @@ |
||
5 | 5 | /** |
6 | 6 | * |
7 | 7 | * Class EE_CPT_Minimum_Where_Conditions |
8 | - * |
|
8 | + * |
|
9 | 9 | * Strategy specifically for adding where conditions specific to CPT models. |
10 | 10 | * But only sets the minimum, so any row of the right type will get used |
11 | 11 | * |
@@ -17,7 +17,6 @@ |
||
17 | 17 | class EE_CPT_Where_Conditions extends EE_CPT_Minimum_Where_Conditions{ |
18 | 18 | /** |
19 | 19 | * Gets the where default where conditions for a custom post type model |
20 | - * @param string $model_relation_path. Eg, from Event to Payment, this should be "Registration.Transaction.Payment" |
|
21 | 20 | * @return array like EEM_Base::get_all's $query_params's index [0] (where conditions) |
22 | 21 | */ |
23 | 22 | protected function _get_default_where_conditions() { |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * * @since 4.6.0 |
15 | 15 | * |
16 | 16 | */ |
17 | -class EE_CPT_Where_Conditions extends EE_CPT_Minimum_Where_Conditions{ |
|
17 | +class EE_CPT_Where_Conditions extends EE_CPT_Minimum_Where_Conditions { |
|
18 | 18 | /** |
19 | 19 | * Gets the where default where conditions for a custom post type model |
20 | 20 | * @param string $model_relation_path. Eg, from Event to Payment, this should be "Registration.Transaction.Payment" |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | return array_merge( |
26 | 26 | parent::_get_default_where_conditions(), |
27 | 27 | array( |
28 | - $status_field->get_name() => array('NOT IN',array('auto-draft','trash') ) |
|
28 | + $status_field->get_name() => array('NOT IN', array('auto-draft', 'trash')) |
|
29 | 29 | ) |
30 | 30 | ); |
31 | 31 | } |
@@ -5,7 +5,7 @@ |
||
5 | 5 | /** |
6 | 6 | * |
7 | 7 | * Class EE_Default_Where_Conditions |
8 | - * |
|
8 | + * |
|
9 | 9 | * Strategy specifically for adding where conditions specific to CPT models. |
10 | 10 | * |
11 | 11 | * @package Event Espresso |
@@ -32,11 +32,11 @@ |
||
32 | 32 | interface RequestMethod |
33 | 33 | { |
34 | 34 | |
35 | - /** |
|
36 | - * Submit the request with the specified parameters. |
|
37 | - * |
|
38 | - * @param RequestParameters $params Request parameters |
|
39 | - * @return string Body of the reCAPTCHA response |
|
40 | - */ |
|
41 | - public function submit(RequestParameters $params); |
|
35 | + /** |
|
36 | + * Submit the request with the specified parameters. |
|
37 | + * |
|
38 | + * @param RequestParameters $params Request parameters |
|
39 | + * @return string Body of the reCAPTCHA response |
|
40 | + */ |
|
41 | + public function submit(RequestParameters $params); |
|
42 | 42 | } |
@@ -53,7 +53,7 @@ |
||
53 | 53 | * @access protected |
54 | 54 | * @param object $object |
55 | 55 | * @param mixed $info |
56 | - * @return bool |
|
56 | + * @return boolean|null |
|
57 | 57 | */ |
58 | 58 | public function setObjectInfo( $object, $info = null ) { |
59 | 59 | $info = is_array( $info ) ? $info : array( 'ID' => spl_object_hash( $object ) ); |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | /** |
39 | 39 | * @param EEI_Collection $object_collection |
40 | 40 | */ |
41 | - public function setCollection( EEI_Collection $object_collection ) { |
|
41 | + public function setCollection(EEI_Collection $object_collection) { |
|
42 | 42 | $this->object_collection = $object_collection; |
43 | 43 | } |
44 | 44 | |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | * @param mixed $info |
56 | 56 | * @return bool |
57 | 57 | */ |
58 | - public function setObjectInfo( $object, $info = null ) { |
|
59 | - $info = is_array( $info ) ? $info : array( 'ID' => spl_object_hash( $object ) ); |
|
58 | + public function setObjectInfo($object, $info = null) { |
|
59 | + $info = is_array($info) ? $info : array('ID' => spl_object_hash($object)); |
|
60 | 60 | $this->object_collection->rewind(); |
61 | - while ( $this->object_collection->valid() ) { |
|
62 | - if ( $object == $this->object_collection->current() ) { |
|
63 | - $this->object_collection->setInfo( $info ); |
|
61 | + while ($this->object_collection->valid()) { |
|
62 | + if ($object == $this->object_collection->current()) { |
|
63 | + $this->object_collection->setInfo($info); |
|
64 | 64 | $this->object_collection->rewind(); |
65 | 65 | return; |
66 | 66 | } |
@@ -79,22 +79,22 @@ discard block |
||
79 | 79 | * @param array $array_of_key_value_pairings |
80 | 80 | * @return null|object |
81 | 81 | */ |
82 | - public function getObjectByInfo( $array_of_key_value_pairings ) { |
|
82 | + public function getObjectByInfo($array_of_key_value_pairings) { |
|
83 | 83 | $this->object_collection->rewind(); |
84 | - while ( $this->object_collection->valid() ) { |
|
84 | + while ($this->object_collection->valid()) { |
|
85 | 85 | $currentInfo = $this->object_collection->getInfo(); |
86 | - if ( ! is_array( $currentInfo ) ) { |
|
86 | + if ( ! is_array($currentInfo)) { |
|
87 | 87 | $this->object_collection->next(); |
88 | 88 | continue; |
89 | 89 | } |
90 | 90 | $found = true; |
91 | - foreach ( $array_of_key_value_pairings as $key => $value ) { |
|
92 | - if ( ! isset( $currentInfo[ $key ] ) || $currentInfo[ $key ] !== $value ) { |
|
91 | + foreach ($array_of_key_value_pairings as $key => $value) { |
|
92 | + if ( ! isset($currentInfo[$key]) || $currentInfo[$key] !== $value) { |
|
93 | 93 | $found = false; |
94 | 94 | break; |
95 | 95 | } |
96 | 96 | } |
97 | - if ( ! $found ) { |
|
97 | + if ( ! $found) { |
|
98 | 98 | continue; |
99 | 99 | } |
100 | 100 | $object = $this->object_collection->current(); |
@@ -115,22 +115,22 @@ discard block |
||
115 | 115 | * @param $array_of_key_value_pairings |
116 | 116 | * @return void |
117 | 117 | */ |
118 | - public function setCurrentByInfo( $array_of_key_value_pairings ) { |
|
118 | + public function setCurrentByInfo($array_of_key_value_pairings) { |
|
119 | 119 | $this->object_collection->rewind(); |
120 | - while ( $this->object_collection->valid() ) { |
|
120 | + while ($this->object_collection->valid()) { |
|
121 | 121 | $currentInfo = $this->object_collection->getInfo(); |
122 | - if ( ! is_array( $currentInfo ) ) { |
|
122 | + if ( ! is_array($currentInfo)) { |
|
123 | 123 | $this->object_collection->next(); |
124 | 124 | continue; |
125 | 125 | } |
126 | 126 | $found = true; |
127 | - foreach ( $array_of_key_value_pairings as $key => $value ) { |
|
128 | - if ( ! isset( $currentInfo[ $key ] ) || $currentInfo[ $key ] !== $value ) { |
|
127 | + foreach ($array_of_key_value_pairings as $key => $value) { |
|
128 | + if ( ! isset($currentInfo[$key]) || $currentInfo[$key] !== $value) { |
|
129 | 129 | $found = false; |
130 | 130 | break; |
131 | 131 | } |
132 | 132 | } |
133 | - if ( ! $found ) { |
|
133 | + if ( ! $found) { |
|
134 | 134 | $this->object_collection->next(); |
135 | 135 | } |
136 | 136 | break; |
@@ -29,15 +29,15 @@ discard block |
||
29 | 29 | |
30 | 30 | |
31 | 31 | /** |
32 | - * @type ObjectRepository $object_collection |
|
33 | - */ |
|
32 | + * @type ObjectRepository $object_collection |
|
33 | + */ |
|
34 | 34 | protected $object_collection; |
35 | 35 | |
36 | 36 | |
37 | 37 | |
38 | 38 | /** |
39 | - * @param EEI_Collection $object_collection |
|
40 | - */ |
|
39 | + * @param EEI_Collection $object_collection |
|
40 | + */ |
|
41 | 41 | public function setCollection( EEI_Collection $object_collection ) { |
42 | 42 | $this->object_collection = $object_collection; |
43 | 43 | } |
@@ -45,16 +45,16 @@ discard block |
||
45 | 45 | |
46 | 46 | |
47 | 47 | /** |
48 | - * setObjectInfo |
|
49 | - * |
|
50 | - * Sets the data associated with an object in the SplObjectStorage |
|
51 | - * if no $info is supplied, then the spl_object_hash() is used |
|
52 | - * |
|
53 | - * @access protected |
|
54 | - * @param object $object |
|
55 | - * @param mixed $info |
|
56 | - * @return bool |
|
57 | - */ |
|
48 | + * setObjectInfo |
|
49 | + * |
|
50 | + * Sets the data associated with an object in the SplObjectStorage |
|
51 | + * if no $info is supplied, then the spl_object_hash() is used |
|
52 | + * |
|
53 | + * @access protected |
|
54 | + * @param object $object |
|
55 | + * @param mixed $info |
|
56 | + * @return bool |
|
57 | + */ |
|
58 | 58 | public function setObjectInfo( $object, $info = null ) { |
59 | 59 | $info = is_array( $info ) ? $info : array( 'ID' => spl_object_hash( $object ) ); |
60 | 60 | $this->object_collection->rewind(); |
@@ -71,14 +71,14 @@ discard block |
||
71 | 71 | |
72 | 72 | |
73 | 73 | /** |
74 | - * getObjectByInfo |
|
75 | - * |
|
76 | - * finds and returns an object in the repository based on the info that was set using addObject() |
|
77 | - * |
|
78 | - * @access protected |
|
79 | - * @param array $array_of_key_value_pairings |
|
80 | - * @return null|object |
|
81 | - */ |
|
74 | + * getObjectByInfo |
|
75 | + * |
|
76 | + * finds and returns an object in the repository based on the info that was set using addObject() |
|
77 | + * |
|
78 | + * @access protected |
|
79 | + * @param array $array_of_key_value_pairings |
|
80 | + * @return null|object |
|
81 | + */ |
|
82 | 82 | public function getObjectByInfo( $array_of_key_value_pairings ) { |
83 | 83 | $this->object_collection->rewind(); |
84 | 84 | while ( $this->object_collection->valid() ) { |
@@ -68,6 +68,9 @@ |
||
68 | 68 | |
69 | 69 | |
70 | 70 | |
71 | + /** |
|
72 | + * @param string $ID |
|
73 | + */ |
|
71 | 74 | function __construct( |
72 | 75 | $ID, |
73 | 76 | CartItemRepository $cartItemRepository, |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | CartTotal $cartTotal, |
76 | 76 | \DateTime $created = null |
77 | 77 | ) { |
78 | - $this->ID = $ID; |
|
79 | - $this->items = $cartItemRepository; |
|
78 | + $this->ID = $ID; |
|
79 | + $this->items = $cartItemRepository; |
|
80 | 80 | $this->cartCalculators = $cartCalculatorRepository; |
81 | - $this->cartTotal = $cartTotal; |
|
82 | - $this->setCreated( $created ); |
|
81 | + $this->cartTotal = $cartTotal; |
|
82 | + $this->setCreated($created); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | /** |
103 | 103 | * @param boolean $open |
104 | 104 | */ |
105 | - public function setOpen( $open = true ) { |
|
106 | - $this->open = filter_var( $open, FILTER_VALIDATE_BOOLEAN ); |
|
105 | + public function setOpen($open = true) { |
|
106 | + $this->open = filter_var($open, FILTER_VALIDATE_BOOLEAN); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * sets the cart open status to false |
113 | 113 | */ |
114 | 114 | public function closeCart() { |
115 | - $this->setOpen( false ); |
|
115 | + $this->setOpen(false); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | * @access protected |
122 | 122 | * @param \DateTime $created |
123 | 123 | */ |
124 | - protected function setCreated( \DateTime $created = null ) { |
|
125 | - if ( ! $created instanceof \DateTime ) { |
|
126 | - $created = new \DateTime( 'now', new \DateTimeZone( 'UTC' ) ); |
|
124 | + protected function setCreated(\DateTime $created = null) { |
|
125 | + if ( ! $created instanceof \DateTime) { |
|
126 | + $created = new \DateTime('now', new \DateTimeZone('UTC')); |
|
127 | 127 | } |
128 | 128 | $this->created = $created; |
129 | 129 | } |
@@ -143,9 +143,9 @@ discard block |
||
143 | 143 | * @access protected |
144 | 144 | * @param \DateTime $updated |
145 | 145 | */ |
146 | - protected function setUpdated( \DateTime $updated = null ) { |
|
147 | - if ( ! $updated instanceof \DateTime ) { |
|
148 | - $updated = new \DateTime( 'now', new \DateTimeZone( 'UTC' ) ); |
|
146 | + protected function setUpdated(\DateTime $updated = null) { |
|
147 | + if ( ! $updated instanceof \DateTime) { |
|
148 | + $updated = new \DateTime('now', new \DateTimeZone('UTC')); |
|
149 | 149 | } |
150 | 150 | $this->updated = $updated; |
151 | 151 | } |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | * @param CartItemOption[] $options |
168 | 168 | * @return bool |
169 | 169 | */ |
170 | - public function addTicket( EEI_Ticket $ticket, $quantity = 1, $options = array() ) { |
|
171 | - return $this->addItem( $ticket, $quantity, $options, 'Ticket' ); |
|
170 | + public function addTicket(EEI_Ticket $ticket, $quantity = 1, $options = array()) { |
|
171 | + return $this->addItem($ticket, $quantity, $options, 'Ticket'); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @return EEI_Ticket[] |
178 | 178 | */ |
179 | 179 | public function getTickets() { |
180 | - return $this->getItems( 'Ticket' ); |
|
180 | + return $this->getItems('Ticket'); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * @return TicketCartItem[] |
187 | 187 | */ |
188 | 188 | public function getTicketCartItems() { |
189 | - return $this->getCartItems( 'Ticket' ); |
|
189 | + return $this->getCartItems('Ticket'); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | * @param CartItemOption[] $options |
198 | 198 | * @return bool |
199 | 199 | */ |
200 | - public function addDiscount( DiscountInterface $discount, $quantity = 1, $options = array() ) { |
|
201 | - return $this->addItem( $discount, $quantity, $options, 'Discount' ); |
|
200 | + public function addDiscount(DiscountInterface $discount, $quantity = 1, $options = array()) { |
|
201 | + return $this->addItem($discount, $quantity, $options, 'Discount'); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * @return DiscountInterface[] |
208 | 208 | */ |
209 | 209 | public function getDiscounts() { |
210 | - return $this->getItems( 'Discount' ); |
|
210 | + return $this->getItems('Discount'); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * @return DiscountCartItem[] |
217 | 217 | */ |
218 | 218 | public function getDiscountCartItems() { |
219 | - return $this->getCartItems( 'Discount' ); |
|
219 | + return $this->getCartItems('Discount'); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | |
@@ -227,8 +227,8 @@ discard block |
||
227 | 227 | * @param CartItemOption[] $options |
228 | 228 | * @return bool |
229 | 229 | */ |
230 | - public function addSurcharge( SurchargeInterface $surcharge, $quantity = 1, $options = array() ) { |
|
231 | - return $this->addItem( $surcharge, $quantity, $options, 'Surcharge' ); |
|
230 | + public function addSurcharge(SurchargeInterface $surcharge, $quantity = 1, $options = array()) { |
|
231 | + return $this->addItem($surcharge, $quantity, $options, 'Surcharge'); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * @return SurchargeInterface[] |
238 | 238 | */ |
239 | 239 | public function getSurcharges() { |
240 | - return $this->getItems( 'Surcharge' ); |
|
240 | + return $this->getItems('Surcharge'); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * @return SurchargeCartItem[] |
247 | 247 | */ |
248 | 248 | public function getSurchargeCartItems() { |
249 | - return $this->getCartItems( 'Surcharge' ); |
|
249 | + return $this->getCartItems('Surcharge'); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | |
@@ -260,23 +260,23 @@ discard block |
||
260 | 260 | * @return bool |
261 | 261 | * @throws \EE_Error |
262 | 262 | */ |
263 | - protected function addItem( $item, $quantity, $options, $type = 'Ticket' ) { |
|
264 | - $cartItemClass = $this->getCartItemClass( $type ); |
|
265 | - $cartItem = new $cartItemClass( $item, $this ); |
|
266 | - if ( ! $cartItem instanceof CartItem ) { |
|
263 | + protected function addItem($item, $quantity, $options, $type = 'Ticket') { |
|
264 | + $cartItemClass = $this->getCartItemClass($type); |
|
265 | + $cartItem = new $cartItemClass($item, $this); |
|
266 | + if ( ! $cartItem instanceof CartItem) { |
|
267 | 267 | throw new \EE_Error( |
268 | 268 | sprintf( |
269 | - __( '"%1$s" is not a valid CartItem class.', 'event_espresso' ), |
|
269 | + __('"%1$s" is not a valid CartItem class.', 'event_espresso'), |
|
270 | 270 | $cartItemClass |
271 | 271 | ) |
272 | 272 | ); |
273 | 273 | } |
274 | - foreach ( $options as $option ) { |
|
275 | - if ( $option instanceof CartItemOption ) { |
|
276 | - $cartItem->addCartItemOption( $option ); |
|
274 | + foreach ($options as $option) { |
|
275 | + if ($option instanceof CartItemOption) { |
|
276 | + $cartItem->addCartItemOption($option); |
|
277 | 277 | } |
278 | 278 | } |
279 | - return $this->items->addItem( $cartItem, $quantity ); |
|
279 | + return $this->items->addItem($cartItem, $quantity); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | |
@@ -287,11 +287,11 @@ discard block |
||
287 | 287 | * @return array |
288 | 288 | * @throws \EE_Error |
289 | 289 | */ |
290 | - protected function getItems( $type = 'Ticket' ) { |
|
291 | - $cartItemClass = $this->getCartItemClass( $type ); |
|
290 | + protected function getItems($type = 'Ticket') { |
|
291 | + $cartItemClass = $this->getCartItemClass($type); |
|
292 | 292 | $items = array(); |
293 | - foreach ( $this->items as $item ) { |
|
294 | - if ( $item instanceof $cartItemClass ) { |
|
293 | + foreach ($this->items as $item) { |
|
294 | + if ($item instanceof $cartItemClass) { |
|
295 | 295 | $items[] = $item->getItem(); |
296 | 296 | } |
297 | 297 | } |
@@ -306,11 +306,11 @@ discard block |
||
306 | 306 | * @return CartItem[] |
307 | 307 | * @throws \EE_Error |
308 | 308 | */ |
309 | - protected function getCartItems( $type = 'Ticket' ) { |
|
310 | - $cartItemClass = $this->getCartItemClass( $type ); |
|
309 | + protected function getCartItems($type = 'Ticket') { |
|
310 | + $cartItemClass = $this->getCartItemClass($type); |
|
311 | 311 | $cartItems = array(); |
312 | - foreach ( $this->items as $item ) { |
|
313 | - if ( $item instanceof $cartItemClass ) { |
|
312 | + foreach ($this->items as $item) { |
|
313 | + if ($item instanceof $cartItemClass) { |
|
314 | 314 | $cartItems[] = $item; |
315 | 315 | } |
316 | 316 | } |
@@ -324,12 +324,12 @@ discard block |
||
324 | 324 | * @return string |
325 | 325 | * @throws \EE_Error |
326 | 326 | */ |
327 | - public function getCartItemClass( $type = 'Ticket' ) { |
|
328 | - $itemClass = $type . 'CartItem'; |
|
329 | - if ( ! class_exists( $itemClass ) || ! is_subclass_of( $itemClass, 'CartItem' ) ) { |
|
327 | + public function getCartItemClass($type = 'Ticket') { |
|
328 | + $itemClass = $type.'CartItem'; |
|
329 | + if ( ! class_exists($itemClass) || ! is_subclass_of($itemClass, 'CartItem')) { |
|
330 | 330 | throw new \EE_Error( |
331 | 331 | sprintf( |
332 | - __( 'The "%1$s" class is either missing or not a valid CartItem class.', 'event_espresso' ), |
|
332 | + __('The "%1$s" class is either missing or not a valid CartItem class.', 'event_espresso'), |
|
333 | 333 | $itemClass |
334 | 334 | ) |
335 | 335 | ); |
@@ -348,8 +348,8 @@ discard block |
||
348 | 348 | protected function calculateCartTotal() { |
349 | 349 | // allow each cart calculator to modify the subtotals |
350 | 350 | $this->cartCalculators->rewind(); |
351 | - while ( $this->cartCalculators->valid() ) { |
|
352 | - $this->cartCalculators->current()->calculateTotal( $this, $this->cartTotal ); |
|
351 | + while ($this->cartCalculators->valid()) { |
|
352 | + $this->cartCalculators->current()->calculateTotal($this, $this->cartTotal); |
|
353 | 353 | $this->cartCalculators->next(); |
354 | 354 | } |
355 | 355 | // ya gotta ADD IT UP! ADD IT UP! |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | - $this->cartTotal->discountTotal |
360 | 360 | + $this->cartTotal->taxSubtotal; |
361 | 361 | // no negative values please |
362 | - $this->cartTotal->grandTotal = max( 0, $this->cartTotal->grandTotal ); |
|
362 | + $this->cartTotal->grandTotal = max(0, $this->cartTotal->grandTotal); |
|
363 | 363 | return $this->cartTotal; |
364 | 364 | } |
365 | 365 |
@@ -1,7 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\services\cart; |
3 | 3 | |
4 | -use EventEspresso\Core; |
|
5 | 4 | use EventEspresso\Core\Libraries\Repositories\EE_Object_Collection; |
6 | 5 | |
7 | 6 | if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | use EventEspresso\Core; |
5 | 5 | use EventEspresso\Core\Libraries\Repositories\EE_Object_Collection; |
6 | 6 | |
7 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
8 | - exit( 'No direct script access allowed' ); |
|
7 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
8 | + exit('No direct script access allowed'); |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | * @param int $quantity |
31 | 31 | * @return bool |
32 | 32 | */ |
33 | - public function addItem( CartItem $item, $quantity = 1 ) { |
|
34 | - if ( $this->has( $item ) ) { |
|
35 | - $item->setQuantity( $item->quantity() + $quantity ); |
|
33 | + public function addItem(CartItem $item, $quantity = 1) { |
|
34 | + if ($this->has($item)) { |
|
35 | + $item->setQuantity($item->quantity() + $quantity); |
|
36 | 36 | return true; |
37 | 37 | } |
38 | - $item->setQuantity( $quantity ); |
|
39 | - return $this->add( $item, $item->SKU() ); |
|
38 | + $item->setQuantity($quantity); |
|
39 | + return $this->add($item, $item->SKU()); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | * @return CartItem |
47 | 47 | * @throws \EE_Error |
48 | 48 | */ |
49 | - public function getItem( $SKU ) { |
|
50 | - $item = $this->get_by_info( $SKU ); |
|
51 | - if ( ! $item instanceof CartItem ) { |
|
52 | - throw new \EE_Error( 'Invalid or missing Item in cart.' ); |
|
49 | + public function getItem($SKU) { |
|
50 | + $item = $this->get_by_info($SKU); |
|
51 | + if ( ! $item instanceof CartItem) { |
|
52 | + throw new \EE_Error('Invalid or missing Item in cart.'); |
|
53 | 53 | } |
54 | - return $item->validateItem( $item ); |
|
54 | + return $item->validateItem($item); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | * @param mixed $SKU |
61 | 61 | * @return CartItem |
62 | 62 | */ |
63 | - public function getItemBySKU( $SKU ) { |
|
64 | - return $this->getItem( $SKU ); |
|
63 | + public function getItemBySKU($SKU) { |
|
64 | + return $this->getItem($SKU); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | * @param CartItem $item |
71 | 71 | * @return bool |
72 | 72 | */ |
73 | - public function hasItem( CartItem $item ) { |
|
74 | - return $this->has( $item ); |
|
73 | + public function hasItem(CartItem $item) { |
|
74 | + return $this->has($item); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | * @param mixed $SKU |
81 | 81 | * @return bool |
82 | 82 | */ |
83 | - public function hasItemBySKU( $SKU ) { |
|
84 | - $item = $this->get_by_info( $SKU ); |
|
85 | - return $this->has( $item ); |
|
83 | + public function hasItemBySKU($SKU) { |
|
84 | + $item = $this->get_by_info($SKU); |
|
85 | + return $this->has($item); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | * @param CartItem $item |
92 | 92 | * @return void |
93 | 93 | */ |
94 | - public function removeItem( CartItem $item ) { |
|
95 | - $this->remove( $item ); |
|
94 | + public function removeItem(CartItem $item) { |
|
95 | + $this->remove($item); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | * @param mixed $SKU |
102 | 102 | * @return void |
103 | 103 | */ |
104 | - public function removeItemBySKU( $SKU ) { |
|
105 | - $item = $this->get_by_info( $SKU ); |
|
106 | - $this->remove( $item ); |
|
104 | + public function removeItemBySKU($SKU) { |
|
105 | + $item = $this->get_by_info($SKU); |
|
106 | + $this->remove($item); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 |
@@ -47,7 +47,7 @@ |
||
47 | 47 | |
48 | 48 | /** |
49 | 49 | * @param $item |
50 | - * @return object |
|
50 | + * @return SurchargeInterface |
|
51 | 51 | * @throws \EE_Error |
52 | 52 | */ |
53 | 53 | public function validateItem( $item ) { |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | |
4 | 4 | use EventEspresso\core\interfaces\cart\SurchargeInterface; |
5 | 5 | |
6 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
7 | - exit( 'No direct script access allowed' ); |
|
6 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
7 | + exit('No direct script access allowed'); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | * @param SurchargeInterface $surcharge |
30 | 30 | * @param Cart $cart |
31 | 31 | */ |
32 | - public function __construct( SurchargeInterface $surcharge, Cart $cart ) { |
|
32 | + public function __construct(SurchargeInterface $surcharge, Cart $cart) { |
|
33 | 33 | $this->item = $surcharge; |
34 | - parent::__construct( $cart ); |
|
34 | + parent::__construct($cart); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @return string |
41 | 41 | */ |
42 | 42 | public function generateSKU() { |
43 | - return md5( $this->item->ID() . $this->item->description() ); |
|
43 | + return md5($this->item->ID().$this->item->description()); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | * @return object |
51 | 51 | * @throws \EE_Error |
52 | 52 | */ |
53 | - public function validateItem( $item ) { |
|
54 | - if ( ! $item instanceof SurchargeInterface ) { |
|
55 | - throw new \EE_Error( 'Invalid or missing surcharge in cart.' ); |
|
53 | + public function validateItem($item) { |
|
54 | + if ( ! $item instanceof SurchargeInterface) { |
|
55 | + throw new \EE_Error('Invalid or missing surcharge in cart.'); |
|
56 | 56 | } |
57 | 57 | return $item; |
58 | 58 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @return float |
64 | 64 | */ |
65 | 65 | public function calculatePrice() { |
66 | - return (float)( $this->getItem()->amount() * $this->quantity ); |
|
66 | + return (float) ($this->getItem()->amount() * $this->quantity); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | |
4 | 4 | use EventEspresso\core\interfaces\EEI_Ticket; |
5 | 5 | |
6 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
7 | - exit( 'No direct script access allowed' ); |
|
6 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
7 | + exit('No direct script access allowed'); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | * @param EEI_Ticket $ticket |
30 | 30 | * @param Cart $cart |
31 | 31 | */ |
32 | - public function __construct( EEI_Ticket $ticket, Cart $cart ) { |
|
32 | + public function __construct(EEI_Ticket $ticket, Cart $cart) { |
|
33 | 33 | $this->item = $ticket; |
34 | - parent::__construct( $cart ); |
|
34 | + parent::__construct($cart); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @return string |
41 | 41 | */ |
42 | 42 | public function generateSKU() { |
43 | - return md5( $this->item->ID() . $this->item->name_and_info() ); |
|
43 | + return md5($this->item->ID().$this->item->name_and_info()); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | * @return object |
51 | 51 | * @throws \EE_Error |
52 | 52 | */ |
53 | - public function validateItem( $item ) { |
|
54 | - if ( ! $item instanceof \EE_Ticket ) { |
|
55 | - throw new \EE_Error( 'Invalid or missing ticket in cart.' ); |
|
53 | + public function validateItem($item) { |
|
54 | + if ( ! $item instanceof \EE_Ticket) { |
|
55 | + throw new \EE_Error('Invalid or missing ticket in cart.'); |
|
56 | 56 | } |
57 | 57 | return $item; |
58 | 58 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @return float |
64 | 64 | */ |
65 | 65 | public function calculatePrice() { |
66 | - return (float)( $this->getItem()->ticket_price() * $this->quantity ); |
|
66 | + return (float) ($this->getItem()->ticket_price() * $this->quantity); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 |