Completed
Push — master ( 18e7f9...711d1c )
by J.D.
03:02
created
src/includes/classes/hook/arg/current/user.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
 	 * @since 1.0.0
26 26
 	 */
27 27
 	public function get_title() {
28
-		return __( 'Visitor', 'wordpoints' );
28
+		return __('Visitor', 'wordpoints');
29 29
 	}
30 30
 }
31 31
 
Please login to merge, or discard this patch.
src/includes/classes/hook/condition.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -23,33 +23,33 @@  discard block
 block discarded – undo
23 23
 		WordPoints_Hook_Reaction_Validator $validator
24 24
 	) {
25 25
 
26
-		if ( ! isset( $settings['value'] ) || '' === $settings['value'] ) {
26
+		if ( ! isset($settings['value']) || '' === $settings['value']) {
27 27
 
28 28
 			$settings_fields = $this->get_settings_fields();
29 29
 
30 30
 			$validator->add_error(
31 31
 				sprintf(
32
-					__( '%s is required.', 'wordpoints' )
32
+					__('%s is required.', 'wordpoints')
33 33
 					, $settings_fields['value']['label']
34 34
 				)
35 35
 				, 'value'
36 36
 			);
37 37
 
38
-		} elseif ( $arg instanceof WordPoints_Entity_Attr ) {
38
+		} elseif ($arg instanceof WordPoints_Entity_Attr) {
39 39
 
40 40
 			$data_types = wordpoints_apps()->data_types;
41 41
 
42
-			$data_type = $data_types->get( $arg->get_data_type() );
42
+			$data_type = $data_types->get($arg->get_data_type());
43 43
 
44 44
 			// If this data type isn't recognized, that's probably OK. Validation is
45 45
 			// just to help the user know that they've made a mistake anyway.
46
-			if ( ! ( $data_type instanceof WordPoints_Data_TypeI ) ) {
46
+			if ( ! ($data_type instanceof WordPoints_Data_TypeI)) {
47 47
 				return $settings;
48 48
 			}
49 49
 
50
-			$validated_value = $data_type->validate_value( $settings['value'] );
50
+			$validated_value = $data_type->validate_value($settings['value']);
51 51
 
52
-			if ( is_wp_error( $validated_value ) ) {
52
+			if (is_wp_error($validated_value)) {
53 53
 
54 54
 				$settings_fields = $this->get_settings_fields();
55 55
 
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
 
67 67
 			$settings['value'] = $validated_value;
68 68
 
69
-		} elseif ( $arg instanceof WordPoints_Entity ) {
69
+		} elseif ($arg instanceof WordPoints_Entity) {
70 70
 
71
-			if ( ! $arg->exists( $settings['value'] ) ) {
71
+			if ( ! $arg->exists($settings['value'])) {
72 72
 				$validator->add_error(
73 73
 					sprintf(
74 74
 						// translators: 1. item type, 2. item ID/slug.
75
-						__( '%1$s “%2$s” not found.', 'wordpoints' )
75
+						__('%1$s “%2$s” not found.', 'wordpoints')
76 76
 						, $arg->get_title()
77 77
 						, $settings['value']
78 78
 					)
Please login to merge, or discard this patch.
src/includes/classes/hook/condition/entity/array/contains.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @since 1.0.0
57 57
 	 */
58 58
 	public function get_title() {
59
-		return __( 'Contains', 'wordpoints' );
59
+		return __('Contains', 'wordpoints');
60 60
 	}
61 61
 
62 62
 	/**
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
 		return array(
67 67
 			'min' => array(
68 68
 				'slug'  => 'min',
69
-				'label' => __( 'Minimum number of items', 'wordpoints' ),
69
+				'label' => __('Minimum number of items', 'wordpoints'),
70 70
 				'type'  => 'number',
71 71
 			),
72 72
 			'max' => array(
73 73
 				'slug'  => 'max',
74
-				'label' => __( 'Maximum number of items', 'wordpoints' ),
74
+				'label' => __('Maximum number of items', 'wordpoints'),
75 75
 				'type'  => 'number',
76 76
 			),
77 77
 		);
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
 
92 92
 		$this->validate_count();
93 93
 
94
-		if ( isset( $settings['conditions'] ) ) {
95
-			$this->validate_conditions( $arg );
94
+		if (isset($settings['conditions'])) {
95
+			$this->validate_conditions($arg);
96 96
 		}
97 97
 
98 98
 		return $this->settings;
@@ -106,21 +106,21 @@  discard block
 block discarded – undo
106 106
 	protected function validate_count() {
107 107
 
108 108
 		if (
109
-			! empty( $this->settings['max'] )
110
-			&& ! wordpoints_posint( $this->settings['max'] )
109
+			! empty($this->settings['max'])
110
+			&& ! wordpoints_posint($this->settings['max'])
111 111
 		) {
112 112
 			$this->validator->add_error(
113
-				__( 'The maximum must be a positive integer.', 'wordpoints' )
113
+				__('The maximum must be a positive integer.', 'wordpoints')
114 114
 				, 'max'
115 115
 			);
116 116
 		}
117 117
 
118 118
 		if (
119
-			! empty( $this->settings['min'] )
120
-			&& ! wordpoints_posint( $this->settings['min'] )
119
+			! empty($this->settings['min'])
120
+			&& ! wordpoints_posint($this->settings['min'])
121 121
 		) {
122 122
 			$this->validator->add_error(
123
-				__( 'The minimum must be a positive integer.', 'wordpoints' )
123
+				__('The minimum must be a positive integer.', 'wordpoints')
124 124
 				, 'min'
125 125
 			);
126 126
 		}
@@ -133,25 +133,25 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 * @param WordPoints_Entityish $current_arg The current arg.
135 135
 	 */
136
-	protected function validate_conditions( $current_arg ) {
136
+	protected function validate_conditions($current_arg) {
137 137
 
138
-		$args = new WordPoints_Hook_Event_Args( array() );
138
+		$args = new WordPoints_Hook_Event_Args(array());
139 139
 
140
-		if ( $current_arg instanceof WordPoints_Entity_Array ) {
140
+		if ($current_arg instanceof WordPoints_Entity_Array) {
141 141
 
142 142
 			$entity = wordpoints_entities()->get(
143 143
 				$current_arg->get_entity_slug()
144 144
 			);
145 145
 
146
-			if ( $entity instanceof WordPoints_Entity ) {
147
-				$args->add_entity( $entity );
146
+			if ($entity instanceof WordPoints_Entity) {
147
+				$args->add_entity($entity);
148 148
 			}
149 149
 		}
150 150
 
151
-		$args->set_validator( $this->validator );
151
+		$args->set_validator($this->validator);
152 152
 
153 153
 		$conditions = $this->conditions_extension->validate_settings(
154
-			array( 'conditions' => $this->settings['conditions'] )
154
+			array('conditions' => $this->settings['conditions'])
155 155
 			, $this->validator
156 156
 			, $args
157 157
 		);
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	/**
163 163
 	 * @since 1.0.0
164 164
 	 */
165
-	public function is_met( array $settings, WordPoints_Hook_Event_Args $args ) {
165
+	public function is_met(array $settings, WordPoints_Hook_Event_Args $args) {
166 166
 
167 167
 		$this->settings = $settings;
168 168
 
@@ -170,16 +170,16 @@  discard block
 block discarded – undo
170 170
 
171 171
 		$entities = array();
172 172
 
173
-		if ( $arg instanceof WordPoints_Entity_Array ) {
173
+		if ($arg instanceof WordPoints_Entity_Array) {
174 174
 
175 175
 			$entities = $arg->get_the_entities();
176 176
 
177
-			if ( isset( $this->settings['conditions'] ) ) {
178
-				$entities = $this->filter_entities( $entities );
177
+			if (isset($this->settings['conditions'])) {
178
+				$entities = $this->filter_entities($entities);
179 179
 			}
180 180
 		}
181 181
 
182
-		return $this->check_count( count( $entities ) );
182
+		return $this->check_count(count($entities));
183 183
 	}
184 184
 
185 185
 	/**
@@ -191,20 +191,20 @@  discard block
 block discarded – undo
191 191
 	 *
192 192
 	 * @return WordPoints_Entity[] The entities that matched the sub-conditions.
193 193
 	 */
194
-	protected function filter_entities( $entities ) {
194
+	protected function filter_entities($entities) {
195 195
 
196
-		foreach ( $entities as $index => $entity ) {
196
+		foreach ($entities as $index => $entity) {
197 197
 
198
-			$event_args = new WordPoints_Hook_Event_Args( array() );
199
-			$event_args->add_entity( $entity );
198
+			$event_args = new WordPoints_Hook_Event_Args(array());
199
+			$event_args->add_entity($entity);
200 200
 
201 201
 			$matches = $this->conditions_extension->conditions_are_met(
202 202
 				$this->settings['conditions']
203 203
 				, $event_args
204 204
 			);
205 205
 
206
-			if ( ! $matches ) {
207
-				unset( $entities[ $index ] );
206
+			if ( ! $matches) {
207
+				unset($entities[$index]);
208 208
 			}
209 209
 		}
210 210
 
@@ -220,13 +220,13 @@  discard block
 block discarded – undo
220 220
 	 *
221 221
 	 * @return bool Whether the count met the requirements.
222 222
 	 */
223
-	protected function check_count( $count ) {
223
+	protected function check_count($count) {
224 224
 
225
-		if ( isset( $this->settings['max'] ) && $count > $this->settings['max'] ) {
225
+		if (isset($this->settings['max']) && $count > $this->settings['max']) {
226 226
 			return false;
227 227
 		}
228 228
 
229
-		if ( isset( $this->settings['min'] ) && $count < $this->settings['min'] ) {
229
+		if (isset($this->settings['min']) && $count < $this->settings['min']) {
230 230
 			return false;
231 231
 		}
232 232
 
Please login to merge, or discard this patch.
src/includes/classes/hook/condition/equals.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 * @since 1.0.0
19 19
 	 */
20 20
 	public function get_title() {
21
-		return __( 'Equals', 'wordpoints' );
21
+		return __('Equals', 'wordpoints');
22 22
 	}
23 23
 
24 24
 	/**
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 		return array(
30 30
 			'value' => array(
31 31
 				'type' => 'text',
32
-				'label' => __( 'Equals', 'wordpoints' ), // TODO
32
+				'label' => __('Equals', 'wordpoints'), // TODO
33 33
 			),
34 34
 		);
35 35
 	}
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	/**
38 38
 	 * @since 1.0.0
39 39
 	 */
40
-	public function is_met( array $settings, WordPoints_Hook_Event_Args $args ) {
40
+	public function is_met(array $settings, WordPoints_Hook_Event_Args $args) {
41 41
 
42 42
 		return $settings['value'] === $args->get_current()->get_the_value();
43 43
 	}
Please login to merge, or discard this patch.
src/includes/classes/hook/condition/string/contains.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 * @since 1.0.0
19 19
 	 */
20 20
 	public function get_title() {
21
-		return __( 'Contains', 'wordpoints' );
21
+		return __('Contains', 'wordpoints');
22 22
 	}
23 23
 
24 24
 	/**
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 		return array(
29 29
 			'value' => array(
30 30
 				'type'     => 'text',
31
-				'label'    => __( 'Contains', 'wordpoints' ), // TODO
31
+				'label'    => __('Contains', 'wordpoints'), // TODO
32 32
 				'required' => true,
33 33
 			),
34 34
 		);
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	/**
38 38
 	 * @since 1.0.0
39 39
 	 */
40
-	public function is_met( array $settings, WordPoints_Hook_Event_Args $args ) {
40
+	public function is_met(array $settings, WordPoints_Hook_Event_Args $args) {
41 41
 
42 42
 		return false !== strpos(
43 43
 			$args->get_current()->get_the_value()
Please login to merge, or discard this patch.
src/includes/classes/hook/conditioni.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
 	 *
65 65
 	 * @return bool Whether this condition is met.
66 66
 	 */
67
-	public function is_met( array $settings, WordPoints_Hook_Event_Args $args );
67
+	public function is_met(array $settings, WordPoints_Hook_Event_Args $args);
68 68
 }
69 69
 
70 70
 // EOF
Please login to merge, or discard this patch.
src/includes/classes/hook/event.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
 	/**
27 27
 	 * @since 1.0.0
28 28
 	 */
29
-	public function __construct( $slug ) {
29
+	public function __construct($slug) {
30 30
 
31 31
 		$this->slug = $slug;
32 32
 	}
Please login to merge, or discard this patch.
src/includes/classes/hook/event/args.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -45,16 +45,16 @@  discard block
 block discarded – undo
45 45
 	 *
46 46
 	 * @param WordPoints_Hook_Arg[] $args The hook args.
47 47
 	 */
48
-	public function __construct( array $args ) {
48
+	public function __construct(array $args) {
49 49
 
50 50
 		parent::__construct();
51 51
 
52
-		foreach ( $args as $arg ) {
52
+		foreach ($args as $arg) {
53 53
 
54 54
 			$entity = $arg->get_entity();
55 55
 
56
-			if ( $entity instanceof WordPoints_Entity ) {
57
-				$this->entities[ $arg->get_slug() ] = $entity;
56
+			if ($entity instanceof WordPoints_Entity) {
57
+				$this->entities[$arg->get_slug()] = $entity;
58 58
 			}
59 59
 		}
60 60
 	}
@@ -66,54 +66,54 @@  discard block
 block discarded – undo
66 66
 	 *
67 67
 	 * @param WordPoints_Hook_Reaction_Validator $validator The validator.
68 68
 	 */
69
-	public function set_validator( WordPoints_Hook_Reaction_Validator $validator ) {
69
+	public function set_validator(WordPoints_Hook_Reaction_Validator $validator) {
70 70
 		$this->validator = $validator;
71 71
 	}
72 72
 
73 73
 	/**
74 74
 	 * @since 1.0.0
75 75
 	 */
76
-	public function descend( $child_slug ) {
76
+	public function descend($child_slug) {
77 77
 
78
-		$result = parent::descend( $child_slug );
78
+		$result = parent::descend($child_slug);
79 79
 
80 80
 		// Just in case no validator has been set.
81
-		if ( ! $this->validator ) {
81
+		if ( ! $this->validator) {
82 82
 			return $result;
83 83
 		}
84 84
 
85
-		if ( ! $result ) {
85
+		if ( ! $result) {
86 86
 
87
-			if ( ! isset( $this->current ) ) {
87
+			if ( ! isset($this->current)) {
88 88
 
89 89
 				$this->validator->add_error(
90 90
 					sprintf(
91
-						__( 'The %s arg is not registered for this event.', 'wordpoints' ) // TODO message
91
+						__('The %s arg is not registered for this event.', 'wordpoints') // TODO message
92 92
 						, $child_slug
93 93
 					)
94 94
 				);
95 95
 
96
-			} elseif ( ! ( $this->current instanceof WordPoints_Entity_ParentI ) ) {
96
+			} elseif ( ! ($this->current instanceof WordPoints_Entity_ParentI)) {
97 97
 
98 98
 				$this->validator->add_error(
99
-					__( 'Cannot get descendant of %s: not a parent.', 'wordpoints' ) // TODO message
99
+					__('Cannot get descendant of %s: not a parent.', 'wordpoints') // TODO message
100 100
 				);
101 101
 
102 102
 			} else {
103 103
 
104
-				$child_arg = $this->current->get_child( $child_slug );
104
+				$child_arg = $this->current->get_child($child_slug);
105 105
 
106
-				if ( ! $child_arg ) {
106
+				if ( ! $child_arg) {
107 107
 					$this->validator->add_error(
108
-						__( '%s does not have a child "%s".', 'wordpoints' ) // TODO message
108
+						__('%s does not have a child "%s".', 'wordpoints') // TODO message
109 109
 						, $this->push_on_descend ? $child_slug : null
110 110
 					);
111 111
 				}
112 112
 			}
113 113
 
114
-		} elseif ( $this->push_on_descend ) {
114
+		} elseif ($this->push_on_descend) {
115 115
 
116
-			$this->validator->push_field( $child_slug );
116
+			$this->validator->push_field($child_slug);
117 117
 		}
118 118
 
119 119
 		return $result;
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
 		$ascended = parent::ascend();
128 128
 
129
-		if ( $ascended && $this->validator ) {
129
+		if ($ascended && $this->validator) {
130 130
 			$this->validator->pop_field();
131 131
 		}
132 132
 
@@ -136,10 +136,10 @@  discard block
 block discarded – undo
136 136
 	/**
137 137
 	 * @since 1.0.0
138 138
 	 */
139
-	public function get_from_hierarchy( array $hierarchy ) {
139
+	public function get_from_hierarchy(array $hierarchy) {
140 140
 
141 141
 		$this->push_on_descend = false;
142
-		$entityish = parent::get_from_hierarchy( $hierarchy );
142
+		$entityish = parent::get_from_hierarchy($hierarchy);
143 143
 		$this->push_on_descend = true;
144 144
 
145 145
 		return $entityish;
Please login to merge, or discard this patch.
src/includes/classes/hook/event/comment/leave.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,14 +18,14 @@
 block discarded – undo
18 18
 	 * @since 1.0.0
19 19
 	 */
20 20
 	public function get_title() {
21
-		return __( 'Comment', 'wordpoints' );
21
+		return __('Comment', 'wordpoints');
22 22
 	}
23 23
 
24 24
 	/**
25 25
 	 * @since 1.0.0
26 26
 	 */
27 27
 	public function get_description() {
28
-		return __( 'When a user leaves a reply to a Post or other type of content.', 'wordpoints' );
28
+		return __('When a user leaves a reply to a Post or other type of content.', 'wordpoints');
29 29
 	}
30 30
 }
31 31
 
Please login to merge, or discard this patch.