@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | $this->max_num_pages = $maxPageCount; |
| 37 | 37 | $this->reviews = $reviews; |
| 38 | 38 | $this->pagination = $this->buildPagination(); |
| 39 | - parent::__construct( $reviews, ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS ); |
|
| 39 | + parent::__construct( $reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS ); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | 'pagination' => $this->getPagination(), |
| 55 | 55 | 'reviews' => $this->getReviews(), |
| 56 | 56 | ], |
| 57 | - ]); |
|
| 57 | + ] ); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public function getReviews() |
| 74 | 74 | { |
| 75 | - $html = empty( $this->reviews ) |
|
| 75 | + $html = empty($this->reviews) |
|
| 76 | 76 | ? $this->getReviewsFallback() |
| 77 | 77 | : implode( PHP_EOL, $this->reviews ); |
| 78 | 78 | $wrapper = '<div class="glsr-reviews">%s</div>'; |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | glsr()->deprecated[] = 'The $reviewsHtml->navigation property has been been deprecated. Please use the $reviewsHtml->pagination property instead.'; |
| 90 | 90 | return $this->pagination; |
| 91 | 91 | } |
| 92 | - if( property_exists( $this, $key )) { |
|
| 92 | + if( property_exists( $this, $key ) ) { |
|
| 93 | 93 | return $this->{$key}; |
| 94 | 94 | } |
| 95 | 95 | return array_key_exists( $key, $this->reviews ) |
@@ -106,8 +106,8 @@ discard block |
||
| 106 | 106 | 'baseUrl' => glsr_get( $this->args, 'pagedUrl' ), |
| 107 | 107 | 'current' => glsr_get( $this->args, 'paged' ), |
| 108 | 108 | 'total' => $this->max_num_pages, |
| 109 | - ]); |
|
| 110 | - $html.= sprintf( '<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json'] ); |
|
| 109 | + ] ); |
|
| 110 | + $html .= sprintf( '<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json'] ); |
|
| 111 | 111 | $wrapper = '<div class="glsr-pagination">%s</div>'; |
| 112 | 112 | $wrapper = apply_filters( 'site-reviews/reviews/pagination-wrapper', $wrapper ); |
| 113 | 113 | return sprintf( $wrapper, $html ); |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | $defaults[] = 'glsr-ajax-pagination'; |
| 126 | 126 | } |
| 127 | 127 | $classes = explode( ' ', $this->args['class'] ); |
| 128 | - $classes = array_unique( array_merge( $defaults, array_filter( $classes ))); |
|
| 128 | + $classes = array_unique( array_merge( $defaults, array_filter( $classes ) ) ); |
|
| 129 | 129 | return implode( ' ', $classes ); |
| 130 | 130 | } |
| 131 | 131 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | protected function getReviewsFallback() |
| 136 | 136 | { |
| 137 | - if( empty( $this->args['fallback'] ) && glsr( OptionManager::class )->getBool( 'settings.reviews.fallback' )) { |
|
| 137 | + if( empty($this->args['fallback']) && glsr( OptionManager::class )->getBool( 'settings.reviews.fallback' ) ) { |
|
| 138 | 138 | $this->args['fallback'] = __( 'There are no reviews yet. Be the first one to write one.', 'site-reviews' ); |
| 139 | 139 | } |
| 140 | 140 | $fallback = '<p class="glsr-no-margins">'.$this->args['fallback'].'</p>'; |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | $this->review = $review; |
| 24 | 24 | $this->values = $values; |
| 25 | - parent::__construct( $values, ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS ); |
|
| 25 | + parent::__construct( $values, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS ); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -30,11 +30,11 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | public function __toString() |
| 32 | 32 | { |
| 33 | - if( empty( $this->values ))return; |
|
| 33 | + if( empty($this->values) )return; |
|
| 34 | 34 | return glsr( Template::class )->build( 'templates/review', [ |
| 35 | 35 | 'context' => $this->values, |
| 36 | 36 | 'review' => $this->review, |
| 37 | - ]); |
|
| 37 | + ] ); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * @return mixed |
| 43 | 43 | */ |
| 44 | 44 | public function offsetGet( $key ) { |
| 45 | - if( property_exists( $this, $key )) { |
|
| 45 | + if( property_exists( $this, $key ) ) { |
|
| 46 | 46 | return $this->{$key}; |
| 47 | 47 | } |
| 48 | 48 | return array_key_exists( $key, $this->values ) |
@@ -10,13 +10,13 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | class Console |
| 12 | 12 | { |
| 13 | - const DEBUG = 0; // Detailed debug information |
|
| 14 | - const INFO = 1; // Interesting events |
|
| 15 | - const NOTICE = 2; // Normal but significant events |
|
| 16 | - const WARNING = 4; // Exceptional occurrences that are not errors |
|
| 17 | - const ERROR = 8; // Runtime errors that do not require immediate action |
|
| 18 | - const CRITICAL = 16; // Critical conditions |
|
| 19 | - const ALERT = 32; // Action must be taken immediately |
|
| 13 | + const DEBUG = 0; // Detailed debug information |
|
| 14 | + const INFO = 1; // Interesting events |
|
| 15 | + const NOTICE = 2; // Normal but significant events |
|
| 16 | + const WARNING = 4; // Exceptional occurrences that are not errors |
|
| 17 | + const ERROR = 8; // Runtime errors that do not require immediate action |
|
| 18 | + const CRITICAL = 16; // Critical conditions |
|
| 19 | + const ALERT = 32; // Action must be taken immediately |
|
| 20 | 20 | const EMERGENCY = 64; // System is unusable |
| 21 | 21 | |
| 22 | 22 | protected $file; |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | public function get() |
| 113 | 113 | { |
| 114 | - return empty( $this->log ) |
|
| 114 | + return empty($this->log) |
|
| 115 | 115 | ? __( 'Console is empty', 'site-reviews' ) |
| 116 | 116 | : $this->log; |
| 117 | 117 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function getLevel() |
| 123 | 123 | { |
| 124 | - return intval( apply_filters( 'site-reviews/console/level', static::INFO )); |
|
| 124 | + return intval( apply_filters( 'site-reviews/console/level', static::INFO ) ); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -129,8 +129,8 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | public function getLevels() |
| 131 | 131 | { |
| 132 | - $constants = ( new ReflectionClass( __CLASS__ ))->getConstants(); |
|
| 133 | - return array_map( 'strtolower', array_flip( $constants )); |
|
| 132 | + $constants = (new ReflectionClass( __CLASS__ ))->getConstants(); |
|
| 133 | + return array_map( 'strtolower', array_flip( $constants ) ); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | public function humanLevel() |
| 140 | 140 | { |
| 141 | 141 | $level = $this->getLevel(); |
| 142 | - return sprintf( '%s (%d)', strtoupper( glsr_get( $this->getLevels(), $level, 'unknown' )), $level ); |
|
| 142 | + return sprintf( '%s (%d)', strtoupper( glsr_get( $this->getLevels(), $level, 'unknown' ) ), $level ); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -149,11 +149,11 @@ discard block |
||
| 149 | 149 | public function humanSize( $valueIfEmpty = null ) |
| 150 | 150 | { |
| 151 | 151 | $bytes = $this->size(); |
| 152 | - if( empty( $bytes ) && is_string( $valueIfEmpty )) { |
|
| 152 | + if( empty($bytes) && is_string( $valueIfEmpty ) ) { |
|
| 153 | 153 | return $valueIfEmpty; |
| 154 | 154 | } |
| 155 | - $exponent = floor( log( max( $bytes, 1 ), 1024 )); |
|
| 156 | - return round( $bytes / pow( 1024, $exponent ), 2 ).' '.['bytes','KB','MB','GB'][$exponent]; |
|
| 155 | + $exponent = floor( log( max( $bytes, 1 ), 1024 ) ); |
|
| 156 | + return round( $bytes / pow( 1024, $exponent ), 2 ).' '.['bytes', 'KB', 'MB', 'GB'][$exponent]; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -177,16 +177,16 @@ discard block |
||
| 177 | 177 | */ |
| 178 | 178 | public function log( $level, $message, $context = [], $backtraceLine = '' ) |
| 179 | 179 | { |
| 180 | - if( empty( $backtraceLine )) { |
|
| 180 | + if( empty($backtraceLine) ) { |
|
| 181 | 181 | $backtraceLine = $this->getBacktraceLine(); |
| 182 | 182 | } |
| 183 | - if( $this->canLogEntry( $level, $backtraceLine )) { |
|
| 183 | + if( $this->canLogEntry( $level, $backtraceLine ) ) { |
|
| 184 | 184 | $levelName = glsr_get( $this->getLevels(), $level ); |
| 185 | 185 | $context = glsr( Helper::class )->consolidateArray( $context ); |
| 186 | 186 | $backtraceLine = $this->normalizeBacktraceLine( $backtraceLine ); |
| 187 | 187 | $message = $this->interpolate( $message, $context ); |
| 188 | 188 | $entry = $this->buildLogEntry( $levelName, $message, $backtraceLine ); |
| 189 | - file_put_contents( $this->file, $entry.PHP_EOL, FILE_APPEND|LOCK_EX ); |
|
| 189 | + file_put_contents( $this->file, $entry.PHP_EOL, FILE_APPEND | LOCK_EX ); |
|
| 190 | 190 | apply_filters( 'console', $message, $levelName, $backtraceLine ); // Show in Blackbar plugin if installed |
| 191 | 191 | $this->reset(); |
| 192 | 192 | } |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | $levels = $this->getLevels(); |
| 203 | 203 | foreach( $once as $entry ) { |
| 204 | 204 | $levelName = glsr_get( $entry, 'level' ); |
| 205 | - if( !in_array( $levelName, $levels ))continue; |
|
| 205 | + if( !in_array( $levelName, $levels ) )continue; |
|
| 206 | 206 | $level = glsr_get( array_flip( $levels ), $levelName ); |
| 207 | 207 | $message = glsr_get( $entry, 'message' ); |
| 208 | 208 | $backtraceLine = glsr_get( $entry, 'backtrace' ); |
@@ -231,11 +231,11 @@ discard block |
||
| 231 | 231 | public function once( $levelName, $handle, $data ) |
| 232 | 232 | { |
| 233 | 233 | $once = glsr( Helper::class )->consolidateArray( glsr()->{$this->logOnceKey} ); |
| 234 | - $filtered = array_filter( $once, function( $entry ) use( $levelName, $handle ) { |
|
| 234 | + $filtered = array_filter( $once, function( $entry ) use($levelName, $handle) { |
|
| 235 | 235 | return glsr_get( $entry, 'level' ) == $levelName |
| 236 | 236 | && glsr_get( $entry, 'handle' ) == $handle; |
| 237 | 237 | }); |
| 238 | - if( !empty( $filtered ))return; |
|
| 238 | + if( !empty($filtered) )return; |
|
| 239 | 239 | $once[] = [ |
| 240 | 240 | 'backtrace' => $this->getBacktraceLineFromData( $data ), |
| 241 | 241 | 'handle' => $handle, |
@@ -315,9 +315,9 @@ discard block |
||
| 315 | 315 | protected function getBacktraceLine() |
| 316 | 316 | { |
| 317 | 317 | $backtrace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 6 ); |
| 318 | - $search = array_search( 'log', glsr_array_column( $backtrace, 'function' )); |
|
| 318 | + $search = array_search( 'log', glsr_array_column( $backtrace, 'function' ) ); |
|
| 319 | 319 | if( $search !== false ) { |
| 320 | - $index = glsr_get( $backtrace, ( $search + 2 ).'.function' ) == '{closure}' |
|
| 320 | + $index = glsr_get( $backtrace, ($search + 2).'.function' ) == '{closure}' |
|
| 321 | 321 | ? $search + 4 |
| 322 | 322 | : $search + 1; |
| 323 | 323 | return $this->buildBacktraceLine( $backtrace, $index ); |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | */ |
| 357 | 357 | protected function interpolate( $message, $context = [] ) |
| 358 | 358 | { |
| 359 | - if( $this->isObjectOrArray( $message ) || !is_array( $context )) { |
|
| 359 | + if( $this->isObjectOrArray( $message ) || !is_array( $context ) ) { |
|
| 360 | 360 | return print_r( $message, true ); |
| 361 | 361 | } |
| 362 | 362 | $replace = []; |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | glsr()->path( 'plugin/' ), |
| 386 | 386 | glsr()->path( 'plugin/', false ), |
| 387 | 387 | trailingslashit( glsr()->path() ), |
| 388 | - trailingslashit( glsr()->path( '', false )), |
|
| 388 | + trailingslashit( glsr()->path( '', false ) ), |
|
| 389 | 389 | WP_CONTENT_DIR, |
| 390 | 390 | ABSPATH |
| 391 | 391 | ]; |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | if( $value instanceof DateTime ) { |
| 414 | 414 | $value = $value->format( 'Y-m-d H:i:s' ); |
| 415 | 415 | } |
| 416 | - else if( $this->isObjectOrArray( $value )) { |
|
| 416 | + else if( $this->isObjectOrArray( $value ) ) { |
|
| 417 | 417 | $value = json_encode( $value ); |
| 418 | 418 | } |
| 419 | 419 | return (string)$value; |