@@ -16,11 +16,11 @@ discard block |
||
16 | 16 | { |
17 | 17 | $queries = []; |
18 | 18 | foreach( $keys as $key ) { |
19 | - if( !array_key_exists( $key, $values ))continue; |
|
19 | + if( !array_key_exists( $key, $values ) )continue; |
|
20 | 20 | $methodName = glsr( Helper::class )->buildMethodName( $key, $prefix = __METHOD__ ); |
21 | - if( !method_exists( $this, $methodName ))continue; |
|
21 | + if( !method_exists( $this, $methodName ) )continue; |
|
22 | 22 | $query = call_user_func( [$this, $methodName], $values[$key] ); |
23 | - if( is_array( $query )) { |
|
23 | + if( is_array( $query ) ) { |
|
24 | 24 | $queries[] = $query; |
25 | 25 | } |
26 | 26 | } |
@@ -35,11 +35,11 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function buildSqlOr( $values, $sprintfFormat ) |
37 | 37 | { |
38 | - if( !is_array( $values )) { |
|
38 | + if( !is_array( $values ) ) { |
|
39 | 39 | $values = explode( ',', $values ); |
40 | 40 | } |
41 | - $values = array_filter( array_map( 'trim', (array)$values )); |
|
42 | - $values = array_map( function( $value ) use( $sprintfFormat ) { |
|
41 | + $values = array_filter( array_map( 'trim', (array)$values ) ); |
|
42 | + $values = array_map( function( $value ) use($sprintfFormat) { |
|
43 | 43 | return sprintf( $sprintfFormat, $value ); |
44 | 44 | }, $values ); |
45 | 45 | return implode( ' OR ', $values ); |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function filterSearchByTitle( $search, WP_Query $query ) |
56 | 56 | { |
57 | - if( empty( $search ) || empty( $query->get( 'search_terms' ))) { |
|
57 | + if( empty($search) || empty($query->get( 'search_terms' )) ) { |
|
58 | 58 | return $search; |
59 | 59 | } |
60 | 60 | global $wpdb; |
61 | - $n = empty( $query->get( 'exact' )) |
|
61 | + $n = empty($query->get( 'exact' )) |
|
62 | 62 | ? '%' |
63 | 63 | : ''; |
64 | 64 | $search = []; |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | public function getPaged( $isEnabled = true ) |
80 | 80 | { |
81 | 81 | $paged = $isEnabled |
82 | - ? intval( get_query_var( is_front_page() ? 'page' : Application::PAGED_QUERY_VAR )) |
|
82 | + ? intval( get_query_var( is_front_page() ? 'page' : Application::PAGED_QUERY_VAR ) ) |
|
83 | 83 | : 1; |
84 | 84 | return max( 1, $paged ); |
85 | 85 | } |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | */ |
91 | 91 | protected function buildQueryAssignedTo( $value ) |
92 | 92 | { |
93 | - if( empty( $value ))return; |
|
93 | + if( empty($value) )return; |
|
94 | 94 | return [ |
95 | 95 | 'compare' => 'IN', |
96 | 96 | 'key' => 'assigned_to', |
97 | - 'value' => array_filter( array_map( 'trim', explode( ',', $value )), 'is_numeric' ), |
|
97 | + 'value' => array_filter( array_map( 'trim', explode( ',', $value ) ), 'is_numeric' ), |
|
98 | 98 | ]; |
99 | 99 | } |
100 | 100 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | protected function buildQueryCategory( $value ) |
106 | 106 | { |
107 | - if( empty( $value ))return; |
|
107 | + if( empty($value) )return; |
|
108 | 108 | return [ |
109 | 109 | 'field' => 'term_id', |
110 | 110 | 'taxonomy' => Application::TAXONOMY, |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | protected function buildQueryRating( $value ) |
120 | 120 | { |
121 | - if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 )))return; |
|
121 | + if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 ) ) )return; |
|
122 | 122 | return [ |
123 | 123 | 'compare' => '>=', |
124 | 124 | 'key' => 'rating', |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | protected function buildQueryType( $value ) |
134 | 134 | { |
135 | - if( in_array( $value, ['','all'] ))return; |
|
135 | + if( in_array( $value, ['', 'all'] ) )return; |
|
136 | 136 | return [ |
137 | 137 | 'key' => 'review_type', |
138 | 138 | 'value' => $value, |
@@ -16,7 +16,7 @@ |
||
16 | 16 | 'author' => '', |
17 | 17 | 'avatar' => '', |
18 | 18 | 'content' => '', |
19 | - 'date' => get_date_from_gmt( gmdate( 'Y-m-d H:i:s' )), |
|
19 | + 'date' => get_date_from_gmt( gmdate( 'Y-m-d H:i:s' ) ), |
|
20 | 20 | 'email' => '', |
21 | 21 | 'ip_address' => '', |
22 | 22 | 'pinned' => false, |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | defined( 'WPINC' ) || die; |
4 | 4 | |
5 | -require_once( ABSPATH.WPINC.'/class-phpass.php' ); |
|
5 | +require_once(ABSPATH.WPINC.'/class-phpass.php'); |
|
6 | 6 | |
7 | 7 | spl_autoload_register( function( $className ) { |
8 | 8 | $namespaces = [ |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | foreach( $namespaces as $prefix => $base_dir ) { |
17 | 17 | $len = strlen( $prefix ); |
18 | 18 | if( strncmp( $prefix, $className, $len ) !== 0 )continue; |
19 | - $file = $base_dir.str_replace( '\\', '/', substr( $className, $len )).'.php'; |
|
20 | - if( !file_exists( $file ))continue; |
|
19 | + $file = $base_dir.str_replace( '\\', '/', substr( $className, $len ) ).'.php'; |
|
20 | + if( !file_exists( $file ) )continue; |
|
21 | 21 | require $file; |
22 | 22 | break; |
23 | 23 | } |
@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public static function isPhpValid( $version = '' ) |
34 | 34 | { |
35 | - if( !empty( $version )) { |
|
36 | - static::normalize( array( 'php' => $version )); |
|
35 | + if( !empty($version) ) { |
|
36 | + static::normalize( array( 'php' => $version ) ); |
|
37 | 37 | } |
38 | 38 | return !version_compare( PHP_VERSION, static::$versions->php, '<' ); |
39 | 39 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public static function isValid( array $args = array() ) |
45 | 45 | { |
46 | - if( !empty( $args )) { |
|
46 | + if( !empty($args) ) { |
|
47 | 47 | static::normalize( $args ); |
48 | 48 | } |
49 | 49 | return static::isPhpValid() && static::isWpValid(); |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | public static function isWpValid( $version = '' ) |
57 | 57 | { |
58 | 58 | global $wp_version; |
59 | - if( !empty( $version )) { |
|
60 | - static::normalize( array( 'wordpress' => $version )); |
|
59 | + if( !empty($version) ) { |
|
60 | + static::normalize( array( 'wordpress' => $version ) ); |
|
61 | 61 | } |
62 | 62 | return !version_compare( $wp_version, static::$versions->wordpress, '<' ); |
63 | 63 | } |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public static function shouldDeactivate( $file, array $args = array() ) |
70 | 70 | { |
71 | - if( empty( static::$instance )) { |
|
71 | + if( empty(static::$instance) ) { |
|
72 | 72 | static::$file = realpath( $file ); |
73 | 73 | static::$instance = new static; |
74 | 74 | static::$versions = static::normalize( $args ); |
75 | 75 | } |
76 | 76 | if( !static::isValid() ) { |
77 | - add_action( 'activated_plugin', array( static::$instance, 'deactivate' )); |
|
78 | - add_action( 'admin_notices', array( static::$instance, 'deactivate' )); |
|
77 | + add_action( 'activated_plugin', array( static::$instance, 'deactivate' ) ); |
|
78 | + add_action( 'admin_notices', array( static::$instance, 'deactivate' ) ); |
|
79 | 79 | return true; |
80 | 80 | } |
81 | 81 | return false; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | return (object)wp_parse_args( $args, array( |
106 | 106 | 'php' => static::MIN_PHP_VERSION, |
107 | 107 | 'wordpress' => static::MIN_WORDPRESS_VERSION, |
108 | - )); |
|
108 | + ) ); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | filter_input( INPUT_GET, 'plugin_status' ), |
118 | 118 | filter_input( INPUT_GET, 'paged' ), |
119 | 119 | filter_input( INPUT_GET, 's' ) |
120 | - ))); |
|
120 | + ) ) ); |
|
121 | 121 | exit; |
122 | 122 | } |
123 | 123 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | { |
24 | 24 | wp_send_json( glsr( Html::class )->renderPartial( 'link', [ |
25 | 25 | 'post_id' => $request['ID'], |
26 | - ])); |
|
26 | + ] ) ); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function changeReviewStatus( array $request ) |
33 | 33 | { |
34 | - wp_send_json( $this->execute( new ChangeStatus( $request ))); |
|
34 | + wp_send_json( $this->execute( new ChangeStatus( $request ) ) ); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | public function clearLog() |
41 | 41 | { |
42 | 42 | glsr( AdminController::class )->routerClearLog(); |
43 | - wp_send_json([ |
|
43 | + wp_send_json( [ |
|
44 | 44 | 'logger' => glsr( Logger::class )->get(), |
45 | 45 | 'notices' => glsr( Notice::class )->get(), |
46 | - ]); |
|
46 | + ] ); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | { |
54 | 54 | $shortcode = $request['shortcode']; |
55 | 55 | $response = false; |
56 | - if( array_key_exists( $shortcode, glsr()->mceShortcodes )) { |
|
56 | + if( array_key_exists( $shortcode, glsr()->mceShortcodes ) ) { |
|
57 | 57 | $data = glsr()->mceShortcodes[$shortcode]; |
58 | - if( !empty( $data['errors'] )) { |
|
58 | + if( !empty($data['errors']) ) { |
|
59 | 59 | $data['btn_okay'] = [esc_html__( 'Okay', 'site-reviews' )]; |
60 | 60 | } |
61 | 61 | $response = [ |
@@ -75,10 +75,10 @@ discard block |
||
75 | 75 | public function searchPosts( array $request ) |
76 | 76 | { |
77 | 77 | $results = glsr_db()->searchPosts( $request['search'] ); |
78 | - wp_send_json_success([ |
|
78 | + wp_send_json_success( [ |
|
79 | 79 | 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
80 | 80 | 'items' => $results, |
81 | - ]); |
|
81 | + ] ); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function searchTranslations( array $request ) |
88 | 88 | { |
89 | - if( empty( $request['exclude'] )) { |
|
89 | + if( empty($request['exclude']) ) { |
|
90 | 90 | $request['exclude'] = []; |
91 | 91 | } |
92 | 92 | $results = glsr( Translator::class ) |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | ->exclude() |
95 | 95 | ->exclude( $request['exclude'] ) |
96 | 96 | ->renderResults(); |
97 | - wp_send_json_success([ |
|
97 | + wp_send_json_success( [ |
|
98 | 98 | 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
99 | 99 | 'items' => $results, |
100 | - ]); |
|
100 | + ] ); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | { |
108 | 108 | $response = glsr( PublicController::class )->routerCreateReview( $request ); |
109 | 109 | $session = glsr( Session::class ); |
110 | - wp_send_json([ |
|
110 | + wp_send_json( [ |
|
111 | 111 | 'errors' => $session->get( $request['form_id'].'-errors', false, true ), |
112 | 112 | 'message' => $response, |
113 | 113 | 'recaptcha' => $session->get( $request['form_id'].'-recaptcha', false, true ), |
114 | - ]); |
|
114 | + ] ); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function togglePinned( array $request ) |
121 | 121 | { |
122 | - wp_send_json([ |
|
122 | + wp_send_json( [ |
|
123 | 123 | 'notices' => glsr( Notice::class )->get(), |
124 | - 'pinned' => $this->execute( new TogglePinned( $request )), |
|
125 | - ]); |
|
124 | + 'pinned' => $this->execute( new TogglePinned( $request ) ), |
|
125 | + ] ); |
|
126 | 126 | } |
127 | 127 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | public function __construct( $input ) |
25 | 25 | { |
26 | - $this->ajaxRequest = isset( $input['ajax_request'] ); |
|
26 | + $this->ajaxRequest = isset($input['ajax_request']); |
|
27 | 27 | $this->assignedTo = is_numeric( $input['assign_to'] ) |
28 | 28 | ? $input['assign_to'] |
29 | 29 | : ''; |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $this->rating = intval( $input['rating'] ); |
38 | 38 | $this->referrer = $input['_wp_http_referer']; |
39 | 39 | $this->request = $input; |
40 | - $this->terms = isset( $input['terms'] ); |
|
40 | + $this->terms = isset($input['terms']); |
|
41 | 41 | $this->title = sanitize_text_field( $input['title'] ); |
42 | 42 | } |
43 | 43 | } |
@@ -12,11 +12,11 @@ discard block |
||
12 | 12 | */ |
13 | 13 | public function handle( Command $command ) |
14 | 14 | { |
15 | - $postId = wp_update_post([ |
|
15 | + $postId = wp_update_post( [ |
|
16 | 16 | 'ID' => $command->id, |
17 | 17 | 'post_status' => $command->status, |
18 | - ]); |
|
19 | - if( is_wp_error( $postId )) { |
|
18 | + ] ); |
|
19 | + if( is_wp_error( $postId ) ) { |
|
20 | 20 | glsr_log()->error( $postId->get_error_message() ); |
21 | 21 | return []; |
22 | 22 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | 'href' => get_edit_post_link( $postId ), |
38 | 38 | 'class' => 'row-title', |
39 | 39 | 'title' => __( 'Edit', 'site-reviews' ).' “'.esc_attr( $title ).'”', |
40 | - ]); |
|
40 | + ] ); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | protected function getPostState( $postId ) |
48 | 48 | { |
49 | 49 | ob_start(); |
50 | - _post_states( get_post( $postId )); |
|
50 | + _post_states( get_post( $postId ) ); |
|
51 | 51 | return ob_get_clean(); |
52 | 52 | } |
53 | 53 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | 'label' => '['.$tag.']', |
48 | 48 | 'required' => $this->required, |
49 | 49 | 'title' => esc_html__( 'Shortcode', 'site-reviews' ), |
50 | - ]); |
|
50 | + ] ); |
|
51 | 51 | return $this; |
52 | 52 | } |
53 | 53 | |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | protected function generateFields( array $fields ) |
58 | 58 | { |
59 | 59 | $generatedFields = array_map( function( $field ) { |
60 | - if( empty( $field ))return; |
|
60 | + if( empty($field) )return; |
|
61 | 61 | $field = $this->normalize( $field ); |
62 | - if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] )))return; |
|
62 | + if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] ) ) )return; |
|
63 | 63 | return $this->$method( $field ); |
64 | 64 | }, $fields ); |
65 | - return array_values( array_filter( $generatedFields )); |
|
65 | + return array_values( array_filter( $generatedFields ) ); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -71,15 +71,15 @@ discard block |
||
71 | 71 | protected function getFields() |
72 | 72 | { |
73 | 73 | $fields = $this->generateFields( $this->fields() ); |
74 | - if( !empty( $this->errors )) { |
|
74 | + if( !empty($this->errors) ) { |
|
75 | 75 | $errors = []; |
76 | 76 | foreach( $this->required as $name => $alert ) { |
77 | - if( false !== array_search( $name, array_column( $fields, 'name' )))continue; |
|
77 | + if( false !== array_search( $name, array_column( $fields, 'name' ) ) )continue; |
|
78 | 78 | $errors[] = $this->errors[$name]; |
79 | 79 | } |
80 | 80 | $this->errors = $errors; |
81 | 81 | } |
82 | - return empty( $this->errors ) |
|
82 | + return empty($this->errors) |
|
83 | 83 | ? $fields |
84 | 84 | : $this->errors; |
85 | 85 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | return wp_parse_args( $field, [ |
93 | 93 | 'items' => [], |
94 | 94 | 'type' => '', |
95 | - ]); |
|
95 | + ] ); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | 'tooltip' => '', |
111 | 111 | 'type' => '', |
112 | 112 | 'value' => '', |
113 | - ]); |
|
113 | + ] ); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | protected function normalizeContainer( array $field ) |
120 | 120 | { |
121 | - if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field ))return; |
|
121 | + if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field ) )return; |
|
122 | 122 | $field['items'] = $this->generateFields( $field['items'] ); |
123 | 123 | return $field; |
124 | 124 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | protected function normalizeField( array $field, array $defaults ) |
130 | 130 | { |
131 | - if( !$this->validate( $field ))return; |
|
131 | + if( !$this->validate( $field ) )return; |
|
132 | 132 | return array_filter( shortcode_atts( $defaults, $field ), function( $value ) { |
133 | 133 | return $value !== ''; |
134 | 134 | }); |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | 'tooltip' => '', |
149 | 149 | 'type' => '', |
150 | 150 | 'value' => '', |
151 | - ]); |
|
152 | - if( !is_array( $listbox ))return; |
|
153 | - if( !array_key_exists( '', $listbox['options'] )) { |
|
151 | + ] ); |
|
152 | + if( !is_array( $listbox ) )return; |
|
153 | + if( !array_key_exists( '', $listbox['options'] ) ) { |
|
154 | 154 | $listbox['options'] = ['' => $listbox['placeholder']] + $listbox['options']; |
155 | 155 | } |
156 | 156 | foreach( $listbox['options'] as $value => $text ) { |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | */ |
168 | 168 | protected function normalizePost( array $field ) |
169 | 169 | { |
170 | - if( !is_array( $field['query_args'] )) { |
|
170 | + if( !is_array( $field['query_args'] ) ) { |
|
171 | 171 | $field['query_args'] = []; |
172 | 172 | } |
173 | 173 | $posts = get_posts( wp_parse_args( $field['query_args'], [ |
@@ -175,8 +175,8 @@ discard block |
||
175 | 175 | 'orderby' => 'title', |
176 | 176 | 'post_type' => 'post', |
177 | 177 | 'posts_per_page' => 30, |
178 | - ])); |
|
179 | - if( !empty( $posts )) { |
|
178 | + ] ) ); |
|
179 | + if( !empty($posts) ) { |
|
180 | 180 | $options = []; |
181 | 181 | foreach( $posts as $post ) { |
182 | 182 | $options[$post->ID] = esc_html( $post->post_title ); |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | 'tooltip' => '', |
207 | 207 | 'type' => '', |
208 | 208 | 'value' => '', |
209 | - ]); |
|
209 | + ] ); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | */ |
215 | 215 | protected function validate( array $field ) |
216 | 216 | { |
217 | - $args = shortcode_atts([ |
|
217 | + $args = shortcode_atts( [ |
|
218 | 218 | 'label' => '', |
219 | 219 | 'name' => false, |
220 | 220 | 'required' => false, |
@@ -230,13 +230,13 @@ discard block |
||
230 | 230 | */ |
231 | 231 | protected function validateErrors( array $args ) |
232 | 232 | { |
233 | - if( !isset( $args['required']['error'] )) { |
|
233 | + if( !isset($args['required']['error']) ) { |
|
234 | 234 | return true; |
235 | 235 | } |
236 | - $this->errors[$args['name']] = $this->normalizeContainer([ |
|
236 | + $this->errors[$args['name']] = $this->normalizeContainer( [ |
|
237 | 237 | 'html' => $args['required']['error'], |
238 | 238 | 'type' => 'container', |
239 | - ]); |
|
239 | + ] ); |
|
240 | 240 | return false; |
241 | 241 | } |
242 | 242 | |
@@ -249,10 +249,10 @@ discard block |
||
249 | 249 | return true; |
250 | 250 | } |
251 | 251 | $alert = esc_html__( 'Some of the shortcode options are required.', 'site-reviews' ); |
252 | - if( isset( $args['required']['alert'] )) { |
|
252 | + if( isset($args['required']['alert']) ) { |
|
253 | 253 | $alert = $args['required']['alert']; |
254 | 254 | } |
255 | - else if( !empty( $args['label'] )) { |
|
255 | + else if( !empty($args['label']) ) { |
|
256 | 256 | $alert = sprintf( |
257 | 257 | esc_html_x( 'The "%s" option is required.', 'the option label', 'site-reviews' ), |
258 | 258 | str_replace( ':', '', $args['label'] ) |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | foreach( $this->rules as $attribute => $rules ) { |
74 | 74 | foreach( $rules as $rule ) { |
75 | 75 | $this->validateAttribute( $attribute, $rule ); |
76 | - if( $this->shouldStopValidating( $attribute ))break; |
|
76 | + if( $this->shouldStopValidating( $attribute ) )break; |
|
77 | 77 | } |
78 | 78 | } |
79 | 79 | return $this->errors; |
@@ -88,14 +88,14 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function validateAttribute( $attribute, $rule ) |
90 | 90 | { |
91 | - list( $rule, $parameters ) = $this->parseRule( $rule ); |
|
91 | + list($rule, $parameters) = $this->parseRule( $rule ); |
|
92 | 92 | if( $rule == '' )return; |
93 | 93 | $value = $this->getValue( $attribute ); |
94 | 94 | $this->validateRequired( $attribute, $value ) || in_array( $rule, $this->implicitRules ); |
95 | - if( !method_exists( $this, $method = 'validate'.$rule )) { |
|
95 | + if( !method_exists( $this, $method = 'validate'.$rule ) ) { |
|
96 | 96 | throw new BadMethodCallException( "Method [$method] does not exist." ); |
97 | 97 | } |
98 | - if( !$this->$method( $attribute, $value, $parameters )) { |
|
98 | + if( !$this->$method( $attribute, $value, $parameters ) ) { |
|
99 | 99 | $this->addFailure( $attribute, $rule, $parameters ); |
100 | 100 | } |
101 | 101 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | { |
111 | 111 | $message = $this->getMessage( $attribute, $rule, $parameters ); |
112 | 112 | $this->errors[$attribute]['errors'][] = $message; |
113 | - if( !isset( $this->errors[$attribute]['value'] )) { |
|
113 | + if( !isset($this->errors[$attribute]['value']) ) { |
|
114 | 114 | $this->errors[$attribute]['value'] = $this->getValue( $attribute ); |
115 | 115 | } |
116 | 116 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | */ |
148 | 148 | protected function getMessage( $attribute, $rule, array $parameters ) |
149 | 149 | { |
150 | - if( in_array( $rule, $this->sizeRules )) { |
|
150 | + if( in_array( $rule, $this->sizeRules ) ) { |
|
151 | 151 | return $this->getSizeMessage( $attribute, $rule, $parameters ); |
152 | 152 | } |
153 | 153 | $lowerRule = glsr( Helper::class )->snakeCase( $rule ); |
@@ -162,11 +162,11 @@ discard block |
||
162 | 162 | */ |
163 | 163 | protected function getRule( $attribute, $rules ) |
164 | 164 | { |
165 | - if( !array_key_exists( $attribute, $this->rules ))return; |
|
166 | - $rules = (array) $rules; |
|
165 | + if( !array_key_exists( $attribute, $this->rules ) )return; |
|
166 | + $rules = (array)$rules; |
|
167 | 167 | foreach( $this->rules[$attribute] as $rule ) { |
168 | - list( $rule, $parameters ) = $this->parseRule( $rule ); |
|
169 | - if( in_array( $rule, $rules )) { |
|
168 | + list($rule, $parameters) = $this->parseRule( $rule ); |
|
169 | + if( in_array( $rule, $rules ) ) { |
|
170 | 170 | return [$rule, $parameters]; |
171 | 171 | } |
172 | 172 | } |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | if( is_numeric( $value ) && $hasNumeric ) { |
185 | 185 | return $value; |
186 | 186 | } |
187 | - elseif( is_array( $value )) { |
|
187 | + elseif( is_array( $value ) ) { |
|
188 | 188 | return count( $value ); |
189 | 189 | } |
190 | 190 | return mb_strlen( $value ); |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | */ |
212 | 212 | protected function getValue( $attribute ) |
213 | 213 | { |
214 | - if( isset( $this->data[$attribute] )) { |
|
214 | + if( isset($this->data[$attribute]) ) { |
|
215 | 215 | return $this->data[$attribute]; |
216 | 216 | } |
217 | 217 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | */ |
225 | 225 | protected function hasRule( $attribute, $rules ) |
226 | 226 | { |
227 | - return !is_null( $this->getRule( $attribute, $rules )); |
|
227 | + return !is_null( $this->getRule( $attribute, $rules ) ); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | /** |
@@ -264,11 +264,11 @@ discard block |
||
264 | 264 | $parameters = []; |
265 | 265 | // example: {rule}:{parameters} |
266 | 266 | if( strpos( $rule, ':' ) !== false ) { |
267 | - list( $rule, $parameter ) = explode( ':', $rule, 2 ); |
|
267 | + list($rule, $parameter) = explode( ':', $rule, 2 ); |
|
268 | 268 | // example: {parameter1,parameter2,...} |
269 | 269 | $parameters = $this->parseParameters( $rule, $parameter ); |
270 | 270 | } |
271 | - $rule = ucwords( str_replace( ['-', '_'], ' ', trim( $rule ))); |
|
271 | + $rule = ucwords( str_replace( ['-', '_'], ' ', trim( $rule ) ) ); |
|
272 | 272 | $rule = str_replace( ' ', '', $rule ); |
273 | 273 | return [$rule, $parameters]; |
274 | 274 | } |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | protected function shouldStopValidating( $attribute ) |
297 | 297 | { |
298 | 298 | return $this->hasRule( $attribute, $this->implicitRules ) |
299 | - && isset( $this->failedRules[$attribute] ) |
|
299 | + && isset($this->failedRules[$attribute]) |
|
300 | 300 | && array_intersect( array_keys( $this->failedRules[$attribute] ), $this->implicitRules ); |
301 | 301 | } |
302 | 302 | |
@@ -321,12 +321,12 @@ discard block |
||
321 | 321 | 'regex' => _x( 'The :attribute format is invalid.', ':attribute is a placeholder and should not be translated.', 'site-reviews' ), |
322 | 322 | 'required' => _x( 'The :attribute field is required.', ':attribute is a placeholder and should not be translated.', 'site-reviews' ), |
323 | 323 | ]; |
324 | - $message = isset( $strings[$key] ) |
|
324 | + $message = isset($strings[$key]) |
|
325 | 325 | ? $strings[$key] |
326 | 326 | : false; |
327 | 327 | if( !$message )return; |
328 | 328 | $message = str_replace( ':attribute', $attribute, $message ); |
329 | - if( method_exists( $this, $replacer = 'replace'.$rule )) { |
|
329 | + if( method_exists( $this, $replacer = 'replace'.$rule ) ) { |
|
330 | 330 | $message = $this->$replacer( $message, $parameters ); |
331 | 331 | } |
332 | 332 | return $message; |