Completed
Push — master ( 1fa88f...ea9096 )
by James
03:22
created
src/Http/Guard.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @param array $options
39 39
 	 */
40
-	public function __construct( array $options = array() ) {
41
-		$this->options = $this->set_defaults( $options );
40
+	public function __construct(array $options = array()) {
41
+		$this->options = $this->set_defaults($options);
42 42
 	}
43 43
 
44 44
 	/**
@@ -48,23 +48,23 @@  discard block
 block discarded – undo
48 48
 	 */
49 49
 	public function authorized() {
50 50
 		// if the rule is public, always authorized
51
-		if ( 'public' === $this->options['rule'] ) {
51
+		if ('public' === $this->options['rule']) {
52 52
 			return true;
53 53
 		}
54 54
 
55 55
 		// enable passing in callback
56
-		if ( 'callback' === $this->options['rule'] && is_callable( $this->options['callback'] ) ) {
57
-			return call_user_func( $this->options['callback'] );
56
+		if ('callback' === $this->options['rule'] && is_callable($this->options['callback'])) {
57
+			return call_user_func($this->options['callback']);
58 58
 		}
59 59
 
60 60
 		// map rule to method
61
-		if ( method_exists( $this, $method = $this->options['rule'] ) ) {
61
+		if (method_exists($this, $method = $this->options['rule'])) {
62 62
 			return $this->{$method}();
63 63
 		}
64 64
 
65 65
 		// disable in rule is misconfigused
66 66
 		// @todo set up internal translations
67
-		return new WP_Error( 'misconfigured_guard', __( 'Misconfigured guard rule', 'jaxion' ), [ 'status' => 500 ] );
67
+		return new WP_Error('misconfigured_guard', __('Misconfigured guard rule', 'jaxion'), ['status' => 500]);
68 68
 	}
69 69
 
70 70
 	/**
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 * @return bool|WP_Error
74 74
 	 */
75 75
 	protected function can_edit_others_posts() {
76
-		return current_user_can( 'edit_others_posts' ) ?: $this->make_error();
76
+		return current_user_can('edit_others_posts') ?: $this->make_error();
77 77
 	}
78 78
 
79 79
 	/**
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 * @return bool|WP_Error
92 92
 	 */
93 93
 	protected function can_manage_options() {
94
-		return current_user_can( 'manage_options' ) ?: $this->make_error();
94
+		return current_user_can('manage_options') ?: $this->make_error();
95 95
 	}
96 96
 
97 97
 	/**
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
 	 *
102 102
 	 * @return array
103 103
 	 */
104
-	protected function set_defaults( $options ) {
104
+	protected function set_defaults($options) {
105 105
 		// these are the valid options
106
-		return wp_parse_args( $options, $this->defaults );
106
+		return wp_parse_args($options, $this->defaults);
107 107
 	}
108 108
 
109 109
 	/**
@@ -112,6 +112,6 @@  discard block
 block discarded – undo
112 112
 	 * @return WP_Error
113 113
 	 */
114 114
 	protected function make_error() {
115
-		return new WP_Error( 'unauthorized', __( 'Unauthorized user', 'jaxion' ), array( 'status' => 401 ) );
115
+		return new WP_Error('unauthorized', __('Unauthorized user', 'jaxion'), array('status' => 401));
116 116
 	}
117 117
 }
Please login to merge, or discard this patch.