Passed
Push — master ( dd57fd...bbdbbd )
by Paul
04:15
created
plugin/Modules/Html/ReviewsHtml.php 2 patches
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -8,135 +8,135 @@
 block discarded – undo
8 8
 
9 9
 class ReviewsHtml extends ArrayObject
10 10
 {
11
-    /**
12
-     * @var array
13
-     */
14
-    public $args;
11
+	/**
12
+	 * @var array
13
+	 */
14
+	public $args;
15 15
 
16
-    /**
17
-     * @var int
18
-     */
19
-    public $max_num_pages;
16
+	/**
17
+	 * @var int
18
+	 */
19
+	public $max_num_pages;
20 20
 
21
-    /**
22
-     * @var string
23
-     */
24
-    public $pagination;
21
+	/**
22
+	 * @var string
23
+	 */
24
+	public $pagination;
25 25
 
26
-    /**
27
-     * @var array
28
-     */
29
-    public $reviews;
26
+	/**
27
+	 * @var array
28
+	 */
29
+	public $reviews;
30 30
 
31
-    public function __construct(array $renderedReviews, $maxPageCount, array $args)
32
-    {
33
-        $this->args = $args;
34
-        $this->max_num_pages = $maxPageCount;
35
-        $this->reviews = $renderedReviews;
36
-        $this->pagination = $this->buildPagination();
37
-        parent::__construct($renderedReviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
38
-    }
31
+	public function __construct(array $renderedReviews, $maxPageCount, array $args)
32
+	{
33
+		$this->args = $args;
34
+		$this->max_num_pages = $maxPageCount;
35
+		$this->reviews = $renderedReviews;
36
+		$this->pagination = $this->buildPagination();
37
+		parent::__construct($renderedReviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
38
+	}
39 39
 
40
-    /**
41
-     * @return string
42
-     */
43
-    public function __toString()
44
-    {
45
-        return glsr(Template::class)->build('templates/reviews', [
46
-            'args' => $this->args,
47
-            'context' => [
48
-                'assigned_to' => $this->args['assigned_to'],
49
-                'category' => $this->args['category'],
50
-                'class' => $this->getClass(),
51
-                'id' => $this->args['id'],
52
-                'pagination' => $this->getPagination(),
53
-                'reviews' => $this->getReviews(),
54
-            ],
55
-        ]);
56
-    }
40
+	/**
41
+	 * @return string
42
+	 */
43
+	public function __toString()
44
+	{
45
+		return glsr(Template::class)->build('templates/reviews', [
46
+			'args' => $this->args,
47
+			'context' => [
48
+				'assigned_to' => $this->args['assigned_to'],
49
+				'category' => $this->args['category'],
50
+				'class' => $this->getClass(),
51
+				'id' => $this->args['id'],
52
+				'pagination' => $this->getPagination(),
53
+				'reviews' => $this->getReviews(),
54
+			],
55
+		]);
56
+	}
57 57
 
58
-    /**
59
-     * @return string
60
-     */
61
-    public function getPagination()
62
-    {
63
-        return wp_validate_boolean($this->args['pagination'])
64
-            ? $this->pagination
65
-            : '';
66
-    }
58
+	/**
59
+	 * @return string
60
+	 */
61
+	public function getPagination()
62
+	{
63
+		return wp_validate_boolean($this->args['pagination'])
64
+			? $this->pagination
65
+			: '';
66
+	}
67 67
 
68
-    /**
69
-     * @return string
70
-     */
71
-    public function getReviews()
72
-    {
73
-        $html = empty($this->reviews)
74
-            ? $this->getReviewsFallback()
75
-            : implode(PHP_EOL, $this->reviews);
76
-        $wrapper = '<div class="glsr-reviews">%s</div>';
77
-        $wrapper = apply_filters('site-reviews/reviews/reviews-wrapper', $wrapper);
78
-        return sprintf($wrapper, $html);
79
-    }
68
+	/**
69
+	 * @return string
70
+	 */
71
+	public function getReviews()
72
+	{
73
+		$html = empty($this->reviews)
74
+			? $this->getReviewsFallback()
75
+			: implode(PHP_EOL, $this->reviews);
76
+		$wrapper = '<div class="glsr-reviews">%s</div>';
77
+		$wrapper = apply_filters('site-reviews/reviews/reviews-wrapper', $wrapper);
78
+		return sprintf($wrapper, $html);
79
+	}
80 80
 
81
-    /**
82
-     * @param mixed $key
83
-     * @return mixed
84
-     */
85
-    public function offsetGet($key)
86
-    {
87
-        if ('navigation' == $key) {
88
-            glsr()->deprecated[] = 'The $reviewsHtml->navigation property has been been deprecated. Please use the $reviewsHtml->pagination property instead.';
89
-            return $this->pagination;
90
-        }
91
-        if (array_key_exists($key, $this->reviews)) {
92
-            return $this->reviews[$key];
93
-        }
94
-        return property_exists($this, $key)
95
-            ? $this->$key
96
-            : null;
97
-    }
81
+	/**
82
+	 * @param mixed $key
83
+	 * @return mixed
84
+	 */
85
+	public function offsetGet($key)
86
+	{
87
+		if ('navigation' == $key) {
88
+			glsr()->deprecated[] = 'The $reviewsHtml->navigation property has been been deprecated. Please use the $reviewsHtml->pagination property instead.';
89
+			return $this->pagination;
90
+		}
91
+		if (array_key_exists($key, $this->reviews)) {
92
+			return $this->reviews[$key];
93
+		}
94
+		return property_exists($this, $key)
95
+			? $this->$key
96
+			: null;
97
+	}
98 98
 
99
-    /**
100
-     * @return string
101
-     */
102
-    protected function buildPagination()
103
-    {
104
-        $html = glsr(Partial::class)->build('pagination', [
105
-            'baseUrl' => Arr::get($this->args, 'pagedUrl'),
106
-            'current' => Arr::get($this->args, 'paged'),
107
-            'total' => $this->max_num_pages,
108
-        ]);
109
-        $html.= sprintf('<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json']);
110
-        $wrapper = '<div class="glsr-pagination">%s</div>';
111
-        $wrapper = apply_filters('site-reviews/reviews/pagination-wrapper', $wrapper);
112
-        return sprintf($wrapper, $html);
113
-    }
99
+	/**
100
+	 * @return string
101
+	 */
102
+	protected function buildPagination()
103
+	{
104
+		$html = glsr(Partial::class)->build('pagination', [
105
+			'baseUrl' => Arr::get($this->args, 'pagedUrl'),
106
+			'current' => Arr::get($this->args, 'paged'),
107
+			'total' => $this->max_num_pages,
108
+		]);
109
+		$html.= sprintf('<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json']);
110
+		$wrapper = '<div class="glsr-pagination">%s</div>';
111
+		$wrapper = apply_filters('site-reviews/reviews/pagination-wrapper', $wrapper);
112
+		return sprintf($wrapper, $html);
113
+	}
114 114
 
115
-    /**
116
-     * @return string
117
-     */
118
-    protected function getClass()
119
-    {
120
-        $defaults = [
121
-            'glsr-default',
122
-        ];
123
-        if ('ajax' == $this->args['pagination']) {
124
-            $defaults[] = 'glsr-ajax-pagination';
125
-        }
126
-        $classes = explode(' ', $this->args['class']);
127
-        $classes = array_unique(array_merge($defaults, array_filter($classes)));
128
-        return implode(' ', $classes);
129
-    }
115
+	/**
116
+	 * @return string
117
+	 */
118
+	protected function getClass()
119
+	{
120
+		$defaults = [
121
+			'glsr-default',
122
+		];
123
+		if ('ajax' == $this->args['pagination']) {
124
+			$defaults[] = 'glsr-ajax-pagination';
125
+		}
126
+		$classes = explode(' ', $this->args['class']);
127
+		$classes = array_unique(array_merge($defaults, array_filter($classes)));
128
+		return implode(' ', $classes);
129
+	}
130 130
 
131
-    /**
132
-     * @return string
133
-     */
134
-    protected function getReviewsFallback()
135
-    {
136
-        if (empty($this->args['fallback']) && glsr(OptionManager::class)->getBool('settings.reviews.fallback')) {
137
-            $this->args['fallback'] = __('There are no reviews yet. Be the first one to write one.', 'site-reviews');
138
-        }
139
-        $fallback = '<p class="glsr-no-margins">'.$this->args['fallback'].'</p>';
140
-        return apply_filters('site-reviews/reviews/fallback', $fallback, $this->args);
141
-    }
131
+	/**
132
+	 * @return string
133
+	 */
134
+	protected function getReviewsFallback()
135
+	{
136
+		if (empty($this->args['fallback']) && glsr(OptionManager::class)->getBool('settings.reviews.fallback')) {
137
+			$this->args['fallback'] = __('There are no reviews yet. Be the first one to write one.', 'site-reviews');
138
+		}
139
+		$fallback = '<p class="glsr-no-margins">'.$this->args['fallback'].'</p>';
140
+		return apply_filters('site-reviews/reviews/fallback', $fallback, $this->args);
141
+	}
142 142
 }
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -28,13 +28,13 @@  discard block
 block discarded – undo
28 28
      */
29 29
     public $reviews;
30 30
 
31
-    public function __construct(array $renderedReviews, $maxPageCount, array $args)
31
+    public function __construct( array $renderedReviews, $maxPageCount, array $args )
32 32
     {
33 33
         $this->args = $args;
34 34
         $this->max_num_pages = $maxPageCount;
35 35
         $this->reviews = $renderedReviews;
36 36
         $this->pagination = $this->buildPagination();
37
-        parent::__construct($renderedReviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
37
+        parent::__construct( $renderedReviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS );
38 38
     }
39 39
 
40 40
     /**
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function __toString()
44 44
     {
45
-        return glsr(Template::class)->build('templates/reviews', [
45
+        return glsr( Template::class )->build( 'templates/reviews', [
46 46
             'args' => $this->args,
47 47
             'context' => [
48 48
                 'assigned_to' => $this->args['assigned_to'],
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
                 'pagination' => $this->getPagination(),
53 53
                 'reviews' => $this->getReviews(),
54 54
             ],
55
-        ]);
55
+        ] );
56 56
     }
57 57
 
58 58
     /**
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      */
61 61
     public function getPagination()
62 62
     {
63
-        return wp_validate_boolean($this->args['pagination'])
63
+        return wp_validate_boolean( $this->args['pagination'] )
64 64
             ? $this->pagination
65 65
             : '';
66 66
     }
@@ -72,26 +72,26 @@  discard block
 block discarded – undo
72 72
     {
73 73
         $html = empty($this->reviews)
74 74
             ? $this->getReviewsFallback()
75
-            : implode(PHP_EOL, $this->reviews);
75
+            : implode( PHP_EOL, $this->reviews );
76 76
         $wrapper = '<div class="glsr-reviews">%s</div>';
77
-        $wrapper = apply_filters('site-reviews/reviews/reviews-wrapper', $wrapper);
78
-        return sprintf($wrapper, $html);
77
+        $wrapper = apply_filters( 'site-reviews/reviews/reviews-wrapper', $wrapper );
78
+        return sprintf( $wrapper, $html );
79 79
     }
80 80
 
81 81
     /**
82 82
      * @param mixed $key
83 83
      * @return mixed
84 84
      */
85
-    public function offsetGet($key)
85
+    public function offsetGet( $key )
86 86
     {
87
-        if ('navigation' == $key) {
87
+        if( 'navigation' == $key ) {
88 88
             glsr()->deprecated[] = 'The $reviewsHtml->navigation property has been been deprecated. Please use the $reviewsHtml->pagination property instead.';
89 89
             return $this->pagination;
90 90
         }
91
-        if (array_key_exists($key, $this->reviews)) {
91
+        if( array_key_exists( $key, $this->reviews ) ) {
92 92
             return $this->reviews[$key];
93 93
         }
94
-        return property_exists($this, $key)
94
+        return property_exists( $this, $key )
95 95
             ? $this->$key
96 96
             : null;
97 97
     }
@@ -101,15 +101,15 @@  discard block
 block discarded – undo
101 101
      */
102 102
     protected function buildPagination()
103 103
     {
104
-        $html = glsr(Partial::class)->build('pagination', [
105
-            'baseUrl' => Arr::get($this->args, 'pagedUrl'),
106
-            'current' => Arr::get($this->args, 'paged'),
104
+        $html = glsr( Partial::class )->build( 'pagination', [
105
+            'baseUrl' => Arr::get( $this->args, 'pagedUrl' ),
106
+            'current' => Arr::get( $this->args, 'paged' ),
107 107
             'total' => $this->max_num_pages,
108
-        ]);
109
-        $html.= sprintf('<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json']);
108
+        ] );
109
+        $html .= sprintf( '<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json'] );
110 110
         $wrapper = '<div class="glsr-pagination">%s</div>';
111
-        $wrapper = apply_filters('site-reviews/reviews/pagination-wrapper', $wrapper);
112
-        return sprintf($wrapper, $html);
111
+        $wrapper = apply_filters( 'site-reviews/reviews/pagination-wrapper', $wrapper );
112
+        return sprintf( $wrapper, $html );
113 113
     }
114 114
 
115 115
     /**
@@ -120,12 +120,12 @@  discard block
 block discarded – undo
120 120
         $defaults = [
121 121
             'glsr-default',
122 122
         ];
123
-        if ('ajax' == $this->args['pagination']) {
123
+        if( 'ajax' == $this->args['pagination'] ) {
124 124
             $defaults[] = 'glsr-ajax-pagination';
125 125
         }
126
-        $classes = explode(' ', $this->args['class']);
127
-        $classes = array_unique(array_merge($defaults, array_filter($classes)));
128
-        return implode(' ', $classes);
126
+        $classes = explode( ' ', $this->args['class'] );
127
+        $classes = array_unique( array_merge( $defaults, array_filter( $classes ) ) );
128
+        return implode( ' ', $classes );
129 129
     }
130 130
 
131 131
     /**
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
      */
134 134
     protected function getReviewsFallback()
135 135
     {
136
-        if (empty($this->args['fallback']) && glsr(OptionManager::class)->getBool('settings.reviews.fallback')) {
137
-            $this->args['fallback'] = __('There are no reviews yet. Be the first one to write one.', 'site-reviews');
136
+        if( empty($this->args['fallback']) && glsr( OptionManager::class )->getBool( 'settings.reviews.fallback' ) ) {
137
+            $this->args['fallback'] = __( 'There are no reviews yet. Be the first one to write one.', 'site-reviews' );
138 138
         }
139 139
         $fallback = '<p class="glsr-no-margins">'.$this->args['fallback'].'</p>';
140
-        return apply_filters('site-reviews/reviews/fallback', $fallback, $this->args);
140
+        return apply_filters( 'site-reviews/reviews/fallback', $fallback, $this->args );
141 141
     }
142 142
 }
Please login to merge, or discard this patch.
plugin/Contracts/PartialContract.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
 
5 5
 interface PartialContract
6 6
 {
7
-    /**
8
-     * @return string
9
-     */
10
-    public function build(array $args = []);
7
+	/**
8
+	 * @return string
9
+	 */
10
+	public function build(array $args = []);
11 11
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,5 +7,5 @@
 block discarded – undo
7 7
     /**
8 8
      * @return string
9 9
      */
10
-    public function build(array $args = []);
10
+    public function build( array $args = [] );
11 11
 }
Please login to merge, or discard this patch.
uninstall.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
 require_once $file;
7 7
 
8 8
 if (!(new GL_Plugin_Check_v4($file))->isValid()) {
9
-    return;
9
+	return;
10 10
 }
11 11
 delete_option(GeminiLabs\SiteReviews\Database\OptionManager::databaseKey(3));
12 12
 delete_option(GeminiLabs\SiteReviews\Database\OptionManager::databaseKey(4));
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,23 +1,23 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-defined('WP_UNINSTALL_PLUGIN') || die;
3
+defined( 'WP_UNINSTALL_PLUGIN' ) || die;
4 4
 
5 5
 $file = __DIR__.'/site-reviews.php';
6 6
 require_once $file;
7 7
 
8
-if (!(new GL_Plugin_Check_v4($file))->isValid()) {
8
+if( !(new GL_Plugin_Check_v4( $file ))->isValid() ) {
9 9
     return;
10 10
 }
11
-delete_option(GeminiLabs\SiteReviews\Database\OptionManager::databaseKey(3));
12
-delete_option(GeminiLabs\SiteReviews\Database\OptionManager::databaseKey(4));
13
-delete_option('_glsr_trustalyze');
14
-delete_option('widget_'.glsr()->id.'_site-reviews');
15
-delete_option('widget_'.glsr()->id.'_site-reviews-form');
16
-delete_option('widget_'.glsr()->id.'_site-reviews-summary');
17
-delete_transient(glsr()->id.'_cloudflare_ips');
18
-delete_transient(glsr()->id.'_remote_post_test');
19
-wp_cache_delete(glsr()->id);
11
+delete_option( GeminiLabs\SiteReviews\Database\OptionManager::databaseKey( 3 ) );
12
+delete_option( GeminiLabs\SiteReviews\Database\OptionManager::databaseKey( 4 ) );
13
+delete_option( '_glsr_trustalyze' );
14
+delete_option( 'widget_'.glsr()->id.'_site-reviews' );
15
+delete_option( 'widget_'.glsr()->id.'_site-reviews-form' );
16
+delete_option( 'widget_'.glsr()->id.'_site-reviews-summary' );
17
+delete_transient( glsr()->id.'_cloudflare_ips' );
18
+delete_transient( glsr()->id.'_remote_post_test' );
19
+wp_cache_delete( glsr()->id );
20 20
 
21 21
 global $wpdb;
22 22
 
23
-$wpdb->query("DELETE FROM {$wpdb->usermeta} WHERE meta_key = '_glsr_notices'");
23
+$wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key = '_glsr_notices'" );
Please login to merge, or discard this patch.
plugin/Modules/Html/Partials/StarRating.php 2 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -8,54 +8,54 @@
 block discarded – undo
8 8
 
9 9
 class StarRating implements PartialContract
10 10
 {
11
-    protected $prefix;
12
-    protected $rating;
11
+	protected $prefix;
12
+	protected $rating;
13 13
 
14
-    /**
15
-     * @return string
16
-     */
17
-    public function build(array $args = [])
18
-    {
19
-        $this->setProperties($args);
20
-        $fullStars = intval(floor($this->rating));
21
-        $halfStars = intval(ceil($this->rating - $fullStars));
22
-        $emptyStars = max(0, glsr()->constant('MAX_RATING', Rating::class) - $fullStars - $halfStars);
23
-        return glsr(Template::class)->build('templates/rating/stars', [
24
-            'context' => [
25
-                'empty_stars' => $this->getTemplate('empty-star', $emptyStars),
26
-                'full_stars' => $this->getTemplate('full-star', $fullStars),
27
-                'half_stars' => $this->getTemplate('half-star', $halfStars),
28
-                'prefix' => $this->prefix,
29
-                'title' => sprintf(__('%s rating', 'site-reviews'), number_format_i18n($this->rating, 1)),
30
-            ],
31
-        ]);
32
-    }
14
+	/**
15
+	 * @return string
16
+	 */
17
+	public function build(array $args = [])
18
+	{
19
+		$this->setProperties($args);
20
+		$fullStars = intval(floor($this->rating));
21
+		$halfStars = intval(ceil($this->rating - $fullStars));
22
+		$emptyStars = max(0, glsr()->constant('MAX_RATING', Rating::class) - $fullStars - $halfStars);
23
+		return glsr(Template::class)->build('templates/rating/stars', [
24
+			'context' => [
25
+				'empty_stars' => $this->getTemplate('empty-star', $emptyStars),
26
+				'full_stars' => $this->getTemplate('full-star', $fullStars),
27
+				'half_stars' => $this->getTemplate('half-star', $halfStars),
28
+				'prefix' => $this->prefix,
29
+				'title' => sprintf(__('%s rating', 'site-reviews'), number_format_i18n($this->rating, 1)),
30
+			],
31
+		]);
32
+	}
33 33
 
34
-    /**
35
-     * @param string $templateName
36
-     * @param int $timesRepeated
37
-     * @return string
38
-     */
39
-    protected function getTemplate($templateName, $timesRepeated)
40
-    {
41
-        $template = glsr(Template::class)->build('templates/rating/'.$templateName, [
42
-            'context' => [
43
-                'prefix' => $this->prefix,
44
-            ],
45
-        ]);
46
-        return str_repeat($template, $timesRepeated);
47
-    }
34
+	/**
35
+	 * @param string $templateName
36
+	 * @param int $timesRepeated
37
+	 * @return string
38
+	 */
39
+	protected function getTemplate($templateName, $timesRepeated)
40
+	{
41
+		$template = glsr(Template::class)->build('templates/rating/'.$templateName, [
42
+			'context' => [
43
+				'prefix' => $this->prefix,
44
+			],
45
+		]);
46
+		return str_repeat($template, $timesRepeated);
47
+	}
48 48
 
49
-    /**
50
-     * @return array
51
-     */
52
-    protected function setProperties(array $args)
53
-    {
54
-        $args = wp_parse_args($args, [
55
-            'prefix' => glsr()->isAdmin() ? '' : 'glsr-',
56
-            'rating' => 0,
57
-        ]);
58
-        $this->prefix = $args['prefix'];
59
-        $this->rating = (float) str_replace(',', '.', $args['rating']);
60
-    }
49
+	/**
50
+	 * @return array
51
+	 */
52
+	protected function setProperties(array $args)
53
+	{
54
+		$args = wp_parse_args($args, [
55
+			'prefix' => glsr()->isAdmin() ? '' : 'glsr-',
56
+			'rating' => 0,
57
+		]);
58
+		$this->prefix = $args['prefix'];
59
+		$this->rating = (float) str_replace(',', '.', $args['rating']);
60
+	}
61 61
 }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -14,21 +14,21 @@  discard block
 block discarded – undo
14 14
     /**
15 15
      * @return string
16 16
      */
17
-    public function build(array $args = [])
17
+    public function build( array $args = [] )
18 18
     {
19
-        $this->setProperties($args);
20
-        $fullStars = intval(floor($this->rating));
21
-        $halfStars = intval(ceil($this->rating - $fullStars));
22
-        $emptyStars = max(0, glsr()->constant('MAX_RATING', Rating::class) - $fullStars - $halfStars);
23
-        return glsr(Template::class)->build('templates/rating/stars', [
19
+        $this->setProperties( $args );
20
+        $fullStars = intval( floor( $this->rating ) );
21
+        $halfStars = intval( ceil( $this->rating - $fullStars ) );
22
+        $emptyStars = max( 0, glsr()->constant( 'MAX_RATING', Rating::class ) - $fullStars - $halfStars );
23
+        return glsr( Template::class )->build( 'templates/rating/stars', [
24 24
             'context' => [
25
-                'empty_stars' => $this->getTemplate('empty-star', $emptyStars),
26
-                'full_stars' => $this->getTemplate('full-star', $fullStars),
27
-                'half_stars' => $this->getTemplate('half-star', $halfStars),
25
+                'empty_stars' => $this->getTemplate( 'empty-star', $emptyStars ),
26
+                'full_stars' => $this->getTemplate( 'full-star', $fullStars ),
27
+                'half_stars' => $this->getTemplate( 'half-star', $halfStars ),
28 28
                 'prefix' => $this->prefix,
29
-                'title' => sprintf(__('%s rating', 'site-reviews'), number_format_i18n($this->rating, 1)),
29
+                'title' => sprintf( __( '%s rating', 'site-reviews' ), number_format_i18n( $this->rating, 1 ) ),
30 30
             ],
31
-        ]);
31
+        ] );
32 32
     }
33 33
 
34 34
     /**
@@ -36,26 +36,26 @@  discard block
 block discarded – undo
36 36
      * @param int $timesRepeated
37 37
      * @return string
38 38
      */
39
-    protected function getTemplate($templateName, $timesRepeated)
39
+    protected function getTemplate( $templateName, $timesRepeated )
40 40
     {
41
-        $template = glsr(Template::class)->build('templates/rating/'.$templateName, [
41
+        $template = glsr( Template::class )->build( 'templates/rating/'.$templateName, [
42 42
             'context' => [
43 43
                 'prefix' => $this->prefix,
44 44
             ],
45
-        ]);
46
-        return str_repeat($template, $timesRepeated);
45
+        ] );
46
+        return str_repeat( $template, $timesRepeated );
47 47
     }
48 48
 
49 49
     /**
50 50
      * @return array
51 51
      */
52
-    protected function setProperties(array $args)
52
+    protected function setProperties( array $args )
53 53
     {
54
-        $args = wp_parse_args($args, [
54
+        $args = wp_parse_args( $args, [
55 55
             'prefix' => glsr()->isAdmin() ? '' : 'glsr-',
56 56
             'rating' => 0,
57
-        ]);
57
+        ] );
58 58
         $this->prefix = $args['prefix'];
59
-        $this->rating = (float) str_replace(',', '.', $args['rating']);
59
+        $this->rating = (float)str_replace( ',', '.', $args['rating'] );
60 60
     }
61 61
 }
Please login to merge, or discard this patch.
plugin/Blocks/SiteReviewsFormBlock.php 2 patches
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -7,115 +7,115 @@
 block discarded – undo
7 7
 
8 8
 class SiteReviewsFormBlock extends BlockGenerator
9 9
 {
10
-    /**
11
-     * @return array
12
-     */
13
-    public function attributes()
14
-    {
15
-        return [
16
-            'assign_to' => [
17
-                'default' => '',
18
-                'type' => 'string',
19
-            ],
20
-            'category' => [
21
-                'default' => '',
22
-                'type' => 'string',
23
-            ],
24
-            'className' => [
25
-                'default' => '',
26
-                'type' => 'string',
27
-            ],
28
-            'hide' => [
29
-                'default' => '',
30
-                'type' => 'string',
31
-            ],
32
-            'id' => [
33
-                'default' => '',
34
-                'type' => 'string',
35
-            ],
36
-        ];
37
-    }
10
+	/**
11
+	 * @return array
12
+	 */
13
+	public function attributes()
14
+	{
15
+		return [
16
+			'assign_to' => [
17
+				'default' => '',
18
+				'type' => 'string',
19
+			],
20
+			'category' => [
21
+				'default' => '',
22
+				'type' => 'string',
23
+			],
24
+			'className' => [
25
+				'default' => '',
26
+				'type' => 'string',
27
+			],
28
+			'hide' => [
29
+				'default' => '',
30
+				'type' => 'string',
31
+			],
32
+			'id' => [
33
+				'default' => '',
34
+				'type' => 'string',
35
+			],
36
+		];
37
+	}
38 38
 
39
-    /**
40
-     * @return string
41
-     */
42
-    public function render(array $attributes)
43
-    {
44
-        $attributes['class'] = $attributes['className'];
45
-        $shortcode = glsr(Shortcode::class);
46
-        if ('edit' == filter_input(INPUT_GET, 'context')) {
47
-            $this->filterFormFields();
48
-            $this->filterRatingField();
49
-            $this->filterShortcodeClass();
50
-            $this->filterSubmitButton();
51
-            if (!$this->hasVisibleFields($shortcode, $attributes)) {
52
-                $this->filterInterpolation();
53
-            }
54
-        }
55
-        return $shortcode->buildShortcode($attributes);
56
-    }
39
+	/**
40
+	 * @return string
41
+	 */
42
+	public function render(array $attributes)
43
+	{
44
+		$attributes['class'] = $attributes['className'];
45
+		$shortcode = glsr(Shortcode::class);
46
+		if ('edit' == filter_input(INPUT_GET, 'context')) {
47
+			$this->filterFormFields();
48
+			$this->filterRatingField();
49
+			$this->filterShortcodeClass();
50
+			$this->filterSubmitButton();
51
+			if (!$this->hasVisibleFields($shortcode, $attributes)) {
52
+				$this->filterInterpolation();
53
+			}
54
+		}
55
+		return $shortcode->buildShortcode($attributes);
56
+	}
57 57
 
58
-    /**
59
-     * @return void
60
-     */
61
-    protected function filterFormFields()
62
-    {
63
-        add_filter('site-reviews/config/forms/submission-form', function (array $config) {
64
-            array_walk($config, function (&$field) {
65
-                $field['disabled'] = true;
66
-                $field['tabindex'] = '-1';
67
-            });
68
-            return $config;
69
-        });
70
-    }
58
+	/**
59
+	 * @return void
60
+	 */
61
+	protected function filterFormFields()
62
+	{
63
+		add_filter('site-reviews/config/forms/submission-form', function (array $config) {
64
+			array_walk($config, function (&$field) {
65
+				$field['disabled'] = true;
66
+				$field['tabindex'] = '-1';
67
+			});
68
+			return $config;
69
+		});
70
+	}
71 71
 
72
-    /**
73
-     * @return void
74
-     */
75
-    protected function filterInterpolation()
76
-    {
77
-        add_filter('site-reviews/interpolate/reviews-form', function ($context) {
78
-            $context['class'] = 'glsr-default glsr-block-disabled';
79
-            $context['fields'] = __('You have hidden all of the fields for this block.', 'site-reviews');
80
-            $context['response'] = '';
81
-            $context['submit_button'] = '';
82
-            return $context;
83
-        });
84
-    }
72
+	/**
73
+	 * @return void
74
+	 */
75
+	protected function filterInterpolation()
76
+	{
77
+		add_filter('site-reviews/interpolate/reviews-form', function ($context) {
78
+			$context['class'] = 'glsr-default glsr-block-disabled';
79
+			$context['fields'] = __('You have hidden all of the fields for this block.', 'site-reviews');
80
+			$context['response'] = '';
81
+			$context['submit_button'] = '';
82
+			return $context;
83
+		});
84
+	}
85 85
 
86
-    /**
87
-     * @return void
88
-     */
89
-    protected function filterRatingField()
90
-    {
91
-        add_filter('site-reviews/rendered/field', function ($html, $type, $args) {
92
-            if ('rating' == $args['path']) {
93
-                $stars = '<span class="glsr-stars">';
94
-                $stars.= str_repeat('<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', (int) glsr()->constant('MAX_RATING', Rating::class));
95
-                $stars.= '</span>';
96
-                $html = preg_replace('/(.*)(<select.*)(<\/select>)(.*)/', '$1'.$stars.'$4', $html);
97
-            }
98
-            return $html;
99
-        }, 10, 3);
100
-    }
86
+	/**
87
+	 * @return void
88
+	 */
89
+	protected function filterRatingField()
90
+	{
91
+		add_filter('site-reviews/rendered/field', function ($html, $type, $args) {
92
+			if ('rating' == $args['path']) {
93
+				$stars = '<span class="glsr-stars">';
94
+				$stars.= str_repeat('<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', (int) glsr()->constant('MAX_RATING', Rating::class));
95
+				$stars.= '</span>';
96
+				$html = preg_replace('/(.*)(<select.*)(<\/select>)(.*)/', '$1'.$stars.'$4', $html);
97
+			}
98
+			return $html;
99
+		}, 10, 3);
100
+	}
101 101
 
102
-    /**
103
-     * @return void
104
-     */
105
-    protected function filterShortcodeClass()
106
-    {
107
-        add_filter('site-reviews/style', function () {
108
-            return 'default';
109
-        });
110
-    }
102
+	/**
103
+	 * @return void
104
+	 */
105
+	protected function filterShortcodeClass()
106
+	{
107
+		add_filter('site-reviews/style', function () {
108
+			return 'default';
109
+		});
110
+	}
111 111
 
112
-    /**
113
-     * @return void
114
-     */
115
-    protected function filterSubmitButton()
116
-    {
117
-        add_filter('site-reviews/rendered/template/form/submit-button', function ($template) {
118
-            return str_replace('type="submit"', 'tabindex="-1"', $template);
119
-        });
120
-    }
112
+	/**
113
+	 * @return void
114
+	 */
115
+	protected function filterSubmitButton()
116
+	{
117
+		add_filter('site-reviews/rendered/template/form/submit-button', function ($template) {
118
+			return str_replace('type="submit"', 'tabindex="-1"', $template);
119
+		});
120
+	}
121 121
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -39,20 +39,20 @@  discard block
 block discarded – undo
39 39
     /**
40 40
      * @return string
41 41
      */
42
-    public function render(array $attributes)
42
+    public function render( array $attributes )
43 43
     {
44 44
         $attributes['class'] = $attributes['className'];
45
-        $shortcode = glsr(Shortcode::class);
46
-        if ('edit' == filter_input(INPUT_GET, 'context')) {
45
+        $shortcode = glsr( Shortcode::class );
46
+        if( 'edit' == filter_input( INPUT_GET, 'context' ) ) {
47 47
             $this->filterFormFields();
48 48
             $this->filterRatingField();
49 49
             $this->filterShortcodeClass();
50 50
             $this->filterSubmitButton();
51
-            if (!$this->hasVisibleFields($shortcode, $attributes)) {
51
+            if( !$this->hasVisibleFields( $shortcode, $attributes ) ) {
52 52
                 $this->filterInterpolation();
53 53
             }
54 54
         }
55
-        return $shortcode->buildShortcode($attributes);
55
+        return $shortcode->buildShortcode( $attributes );
56 56
     }
57 57
 
58 58
     /**
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
      */
61 61
     protected function filterFormFields()
62 62
     {
63
-        add_filter('site-reviews/config/forms/submission-form', function (array $config) {
64
-            array_walk($config, function (&$field) {
63
+        add_filter( 'site-reviews/config/forms/submission-form', function( array $config ) {
64
+            array_walk( $config, function( &$field ) {
65 65
                 $field['disabled'] = true;
66 66
                 $field['tabindex'] = '-1';
67 67
             });
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
      */
75 75
     protected function filterInterpolation()
76 76
     {
77
-        add_filter('site-reviews/interpolate/reviews-form', function ($context) {
77
+        add_filter( 'site-reviews/interpolate/reviews-form', function( $context ) {
78 78
             $context['class'] = 'glsr-default glsr-block-disabled';
79
-            $context['fields'] = __('You have hidden all of the fields for this block.', 'site-reviews');
79
+            $context['fields'] = __( 'You have hidden all of the fields for this block.', 'site-reviews' );
80 80
             $context['response'] = '';
81 81
             $context['submit_button'] = '';
82 82
             return $context;
@@ -88,15 +88,15 @@  discard block
 block discarded – undo
88 88
      */
89 89
     protected function filterRatingField()
90 90
     {
91
-        add_filter('site-reviews/rendered/field', function ($html, $type, $args) {
92
-            if ('rating' == $args['path']) {
91
+        add_filter( 'site-reviews/rendered/field', function( $html, $type, $args ) {
92
+            if( 'rating' == $args['path'] ) {
93 93
                 $stars = '<span class="glsr-stars">';
94
-                $stars.= str_repeat('<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', (int) glsr()->constant('MAX_RATING', Rating::class));
95
-                $stars.= '</span>';
96
-                $html = preg_replace('/(.*)(<select.*)(<\/select>)(.*)/', '$1'.$stars.'$4', $html);
94
+                $stars .= str_repeat( '<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', (int)glsr()->constant( 'MAX_RATING', Rating::class ) );
95
+                $stars .= '</span>';
96
+                $html = preg_replace( '/(.*)(<select.*)(<\/select>)(.*)/', '$1'.$stars.'$4', $html );
97 97
             }
98 98
             return $html;
99
-        }, 10, 3);
99
+        }, 10, 3 );
100 100
     }
101 101
 
102 102
     /**
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
      */
105 105
     protected function filterShortcodeClass()
106 106
     {
107
-        add_filter('site-reviews/style', function () {
107
+        add_filter( 'site-reviews/style', function() {
108 108
             return 'default';
109 109
         });
110 110
     }
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
      */
115 115
     protected function filterSubmitButton()
116 116
     {
117
-        add_filter('site-reviews/rendered/template/form/submit-button', function ($template) {
118
-            return str_replace('type="submit"', 'tabindex="-1"', $template);
117
+        add_filter( 'site-reviews/rendered/template/form/submit-button', function( $template ) {
118
+            return str_replace( 'type="submit"', 'tabindex="-1"', $template );
119 119
         });
120 120
     }
121 121
 }
Please login to merge, or discard this patch.
views/pages/welcome/whatsnew.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php defined('WPINC') || die; ?>
1
+<?php defined( 'WPINC' ) || die; ?>
2 2
 
3 3
 <p class="about-description">We hope you love the changes in this new release!</p>
4 4
 <div class="is-fullwidth">
Please login to merge, or discard this patch.
plugin/Modules/Updater.php 3 patches
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -139,7 +139,8 @@  discard block
 block discarded – undo
139 139
         foreach (glsr()->addons as $addon) {
140 140
             try {
141 141
                 glsr($addon)->updater->getPluginUpdate(true);
142
-            } catch (\Exception $e) {
142
+            }
143
+            catch (\Exception $e) {
143 144
                 glsr_log()->error($e->getMessage());
144 145
             }
145 146
         }
@@ -198,7 +199,8 @@  discard block
 block discarded – undo
198 199
             unset($transient->no_update[$this->plugin]);
199 200
             $updateInfo->update = true;
200 201
             $transient->response[$this->plugin] = $updateInfo;
201
-        } else {
202
+        }
203
+        else {
202 204
             unset($transient->response[$this->plugin]);
203 205
             $transient->no_update[$this->plugin] = $updateInfo;
204 206
         }
Please login to merge, or discard this patch.
Indentation   +244 added lines, -244 removed lines patch added patch discarded remove patch
@@ -8,266 +8,266 @@
 block discarded – undo
8 8
 
9 9
 class Updater
10 10
 {
11
-    /**
12
-     * @var string
13
-     */
14
-    protected $apiUrl;
15
-    /**
16
-     * @var array
17
-     */
18
-    protected $data;
19
-    /**
20
-     * @var string
21
-     */
22
-    protected $plugin;
23
-    /**
24
-     * @var string
25
-     */
26
-    protected $transientName;
11
+	/**
12
+	 * @var string
13
+	 */
14
+	protected $apiUrl;
15
+	/**
16
+	 * @var array
17
+	 */
18
+	protected $data;
19
+	/**
20
+	 * @var string
21
+	 */
22
+	protected $plugin;
23
+	/**
24
+	 * @var string
25
+	 */
26
+	protected $transientName;
27 27
 
28
-    /**
29
-     * @param string $apiUrl
30
-     * @param string $file
31
-     */
32
-    public function __construct($apiUrl, $file, array $data = [])
33
-    {
34
-        if (!function_exists('get_plugin_data')) {
35
-            require_once ABSPATH.WPINC.'/plugin.php';
36
-        }
37
-        $this->apiUrl = trailingslashit(apply_filters('site-reviews/addon/api-url', $apiUrl));
38
-        $this->data = wp_parse_args($data, get_plugin_data($file));
39
-        $this->plugin = plugin_basename($file);
40
-        $this->transientName = Application::PREFIX.md5(Arr::get($data, 'TextDomain'));
41
-    }
28
+	/**
29
+	 * @param string $apiUrl
30
+	 * @param string $file
31
+	 */
32
+	public function __construct($apiUrl, $file, array $data = [])
33
+	{
34
+		if (!function_exists('get_plugin_data')) {
35
+			require_once ABSPATH.WPINC.'/plugin.php';
36
+		}
37
+		$this->apiUrl = trailingslashit(apply_filters('site-reviews/addon/api-url', $apiUrl));
38
+		$this->data = wp_parse_args($data, get_plugin_data($file));
39
+		$this->plugin = plugin_basename($file);
40
+		$this->transientName = Application::PREFIX.md5(Arr::get($data, 'TextDomain'));
41
+	}
42 42
 
43
-    /**
44
-     * @return object
45
-     */
46
-    public function activateLicense(array $data = [])
47
-    {
48
-        return $this->request('activate_license', $data);
49
-    }
43
+	/**
44
+	 * @return object
45
+	 */
46
+	public function activateLicense(array $data = [])
47
+	{
48
+		return $this->request('activate_license', $data);
49
+	}
50 50
 
51
-    /**
52
-     * @return object
53
-     */
54
-    public function checkLicense(array $data = [])
55
-    {
56
-        $response = $this->request('check_license', $data);
57
-        if ('valid' === Arr::get($response, 'license')) {
58
-            $this->getPluginUpdate(true);
59
-        }
60
-        return $response;
61
-    }
51
+	/**
52
+	 * @return object
53
+	 */
54
+	public function checkLicense(array $data = [])
55
+	{
56
+		$response = $this->request('check_license', $data);
57
+		if ('valid' === Arr::get($response, 'license')) {
58
+			$this->getPluginUpdate(true);
59
+		}
60
+		return $response;
61
+	}
62 62
 
63
-    /**
64
-     * @return object
65
-     */
66
-    public function deactivateLicense(array $data = [])
67
-    {
68
-        return $this->request('deactivate_license', $data);
69
-    }
63
+	/**
64
+	 * @return object
65
+	 */
66
+	public function deactivateLicense(array $data = [])
67
+	{
68
+		return $this->request('deactivate_license', $data);
69
+	}
70 70
 
71
-    /**
72
-     * @param false|object|array $result
73
-     * @param string $action
74
-     * @param object $args
75
-     * @return mixed
76
-     */
77
-    public function filterPluginUpdateDetails($result, $action, $args)
78
-    {
79
-        if ('plugin_information' != $action
80
-            || Arr::get($this->data, 'TextDomain') != Arr::get($args, 'slug')) {
81
-            return $result;
82
-        }
83
-        if ($updateInfo = $this->getPluginUpdate()) {
84
-            return $this->modifyUpdateDetails($updateInfo);
85
-        }
86
-        return $result;
87
-    }
71
+	/**
72
+	 * @param false|object|array $result
73
+	 * @param string $action
74
+	 * @param object $args
75
+	 * @return mixed
76
+	 */
77
+	public function filterPluginUpdateDetails($result, $action, $args)
78
+	{
79
+		if ('plugin_information' != $action
80
+			|| Arr::get($this->data, 'TextDomain') != Arr::get($args, 'slug')) {
81
+			return $result;
82
+		}
83
+		if ($updateInfo = $this->getPluginUpdate()) {
84
+			return $this->modifyUpdateDetails($updateInfo);
85
+		}
86
+		return $result;
87
+	}
88 88
 
89
-    /**
90
-     * @param object $transient
91
-     * @return object
92
-     */
93
-    public function filterPluginUpdates($transient)
94
-    {
95
-        if ($updateInfo = $this->getPluginUpdate()) {
96
-            return $this->modifyPluginUpdates($transient, $updateInfo);
97
-        }
98
-        return $transient;
99
-    }
89
+	/**
90
+	 * @param object $transient
91
+	 * @return object
92
+	 */
93
+	public function filterPluginUpdates($transient)
94
+	{
95
+		if ($updateInfo = $this->getPluginUpdate()) {
96
+			return $this->modifyPluginUpdates($transient, $updateInfo);
97
+		}
98
+		return $transient;
99
+	}
100 100
 
101
-    /**
102
-     * @return object
103
-     */
104
-    public function getVersion(array $data = [])
105
-    {
106
-        return $this->request('get_version', $data);
107
-    }
101
+	/**
102
+	 * @return object
103
+	 */
104
+	public function getVersion(array $data = [])
105
+	{
106
+		return $this->request('get_version', $data);
107
+	}
108 108
 
109
-    /**
110
-     * @return void
111
-     */
112
-    public function init()
113
-    {
114
-        if ($this->apiUrl === trailingslashit(home_url())) {
115
-            return;
116
-        }
117
-        add_filter('plugins_api',                             [$this, 'filterPluginUpdateDetails'], 10, 3);
118
-        add_filter('pre_set_site_transient_update_plugins',   [$this, 'filterPluginUpdates'], 999);
119
-        add_action('load-update-core.php',                    [$this, 'onForceUpdateCheck'], 9);
120
-        add_action('in_plugin_update_message-'.$this->plugin, [$this, 'renderLicenseMissingLink']);
121
-    }
109
+	/**
110
+	 * @return void
111
+	 */
112
+	public function init()
113
+	{
114
+		if ($this->apiUrl === trailingslashit(home_url())) {
115
+			return;
116
+		}
117
+		add_filter('plugins_api',                             [$this, 'filterPluginUpdateDetails'], 10, 3);
118
+		add_filter('pre_set_site_transient_update_plugins',   [$this, 'filterPluginUpdates'], 999);
119
+		add_action('load-update-core.php',                    [$this, 'onForceUpdateCheck'], 9);
120
+		add_action('in_plugin_update_message-'.$this->plugin, [$this, 'renderLicenseMissingLink']);
121
+	}
122 122
 
123
-    /**
124
-     * @return bool
125
-     */
126
-    public function isLicenseValid()
127
-    {
128
-        $result = $this->checkLicense();
129
-        return 'valid' === Arr::get($result, 'license');
130
-    }
123
+	/**
124
+	 * @return bool
125
+	 */
126
+	public function isLicenseValid()
127
+	{
128
+		$result = $this->checkLicense();
129
+		return 'valid' === Arr::get($result, 'license');
130
+	}
131 131
 
132
-    /**
133
-     * @return void
134
-     */
135
-    public function onForceUpdateCheck()
136
-    {
137
-        if (!filter_input(INPUT_GET, 'force-check')) {
138
-            return;
139
-        }
140
-        foreach (glsr()->addons as $addon) {
141
-            try {
142
-                glsr($addon)->updater->getPluginUpdate(true);
143
-            } catch (\Exception $e) {
144
-                glsr_log()->error($e->getMessage());
145
-            }
146
-        }
147
-    }
132
+	/**
133
+	 * @return void
134
+	 */
135
+	public function onForceUpdateCheck()
136
+	{
137
+		if (!filter_input(INPUT_GET, 'force-check')) {
138
+			return;
139
+		}
140
+		foreach (glsr()->addons as $addon) {
141
+			try {
142
+				glsr($addon)->updater->getPluginUpdate(true);
143
+			} catch (\Exception $e) {
144
+				glsr_log()->error($e->getMessage());
145
+			}
146
+		}
147
+	}
148 148
 
149
-    /**
150
-     * @return void
151
-     */
152
-    public function renderLicenseMissingLink()
153
-    {
154
-        if (!$this->isLicenseValid()) {
155
-            glsr()->render('partials/addons/license-missing');
156
-        }
157
-    }
149
+	/**
150
+	 * @return void
151
+	 */
152
+	public function renderLicenseMissingLink()
153
+	{
154
+		if (!$this->isLicenseValid()) {
155
+			glsr()->render('partials/addons/license-missing');
156
+		}
157
+	}
158 158
 
159
-    /**
160
-     * @return false|object
161
-     */
162
-    protected function getCachedVersion()
163
-    {
164
-        return get_transient($this->transientName);
165
-    }
159
+	/**
160
+	 * @return false|object
161
+	 */
162
+	protected function getCachedVersion()
163
+	{
164
+		return get_transient($this->transientName);
165
+	}
166 166
 
167
-    /**
168
-     * @param bool $force
169
-     * @return false|object
170
-     */
171
-    protected function getPluginUpdate($force = false)
172
-    {
173
-        $version = $this->getCachedVersion();
174
-        if (false === $version || $force) {
175
-            $version = $this->getVersion();
176
-            $this->setCachedVersion($version);
177
-        }
178
-        if (isset($version->error)) {
179
-            glsr_log()->error($version->error);
180
-            return false;
181
-        }
182
-        return $version;
183
-    }
167
+	/**
168
+	 * @param bool $force
169
+	 * @return false|object
170
+	 */
171
+	protected function getPluginUpdate($force = false)
172
+	{
173
+		$version = $this->getCachedVersion();
174
+		if (false === $version || $force) {
175
+			$version = $this->getVersion();
176
+			$this->setCachedVersion($version);
177
+		}
178
+		if (isset($version->error)) {
179
+			glsr_log()->error($version->error);
180
+			return false;
181
+		}
182
+		return $version;
183
+	}
184 184
 
185
-    /**
186
-     * @param object $transient
187
-     * @param object $updateInfo
188
-     * @return object
189
-     */
190
-    protected function modifyPluginUpdates($transient, $updateInfo)
191
-    {
192
-        $updateInfo->id = Application::ID.'/'.Arr::get($this->data, 'TextDomain');
193
-        $updateInfo->plugin = $this->plugin;
194
-        $updateInfo->requires_php = Arr::get($this->data, 'RequiresPHP');
195
-        $updateInfo->tested = Arr::get($this->data, 'testedTo');
196
-        $transient->checked[$this->plugin] = Arr::get($this->data, 'Version');
197
-        $transient->last_checked = time();
198
-        if (Helper::isGreaterThan($updateInfo->new_version, Arr::get($this->data, 'Version'))) {
199
-            unset($transient->no_update[$this->plugin]);
200
-            $updateInfo->update = true;
201
-            $transient->response[$this->plugin] = $updateInfo;
202
-        } else {
203
-            unset($transient->response[$this->plugin]);
204
-            $transient->no_update[$this->plugin] = $updateInfo;
205
-        }
206
-        return $transient;
207
-    }
185
+	/**
186
+	 * @param object $transient
187
+	 * @param object $updateInfo
188
+	 * @return object
189
+	 */
190
+	protected function modifyPluginUpdates($transient, $updateInfo)
191
+	{
192
+		$updateInfo->id = Application::ID.'/'.Arr::get($this->data, 'TextDomain');
193
+		$updateInfo->plugin = $this->plugin;
194
+		$updateInfo->requires_php = Arr::get($this->data, 'RequiresPHP');
195
+		$updateInfo->tested = Arr::get($this->data, 'testedTo');
196
+		$transient->checked[$this->plugin] = Arr::get($this->data, 'Version');
197
+		$transient->last_checked = time();
198
+		if (Helper::isGreaterThan($updateInfo->new_version, Arr::get($this->data, 'Version'))) {
199
+			unset($transient->no_update[$this->plugin]);
200
+			$updateInfo->update = true;
201
+			$transient->response[$this->plugin] = $updateInfo;
202
+		} else {
203
+			unset($transient->response[$this->plugin]);
204
+			$transient->no_update[$this->plugin] = $updateInfo;
205
+		}
206
+		return $transient;
207
+	}
208 208
 
209
-    /**
210
-     * @param object $updateInfo
211
-     * @return object
212
-     */
213
-    protected function modifyUpdateDetails($updateInfo)
214
-    {
215
-        $updateInfo->author = Arr::get($this->data, 'Author');
216
-        $updateInfo->author_profile = Arr::get($this->data, 'AuthorURI');
217
-        $updateInfo->requires = Arr::get($this->data, 'RequiresWP');
218
-        $updateInfo->requires_php = Arr::get($this->data, 'RequiresPHP');
219
-        $updateInfo->tested = Arr::get($this->data, 'testedTo');
220
-        $updateInfo->version = $updateInfo->new_version;
221
-        return $updateInfo;
222
-    }
209
+	/**
210
+	 * @param object $updateInfo
211
+	 * @return object
212
+	 */
213
+	protected function modifyUpdateDetails($updateInfo)
214
+	{
215
+		$updateInfo->author = Arr::get($this->data, 'Author');
216
+		$updateInfo->author_profile = Arr::get($this->data, 'AuthorURI');
217
+		$updateInfo->requires = Arr::get($this->data, 'RequiresWP');
218
+		$updateInfo->requires_php = Arr::get($this->data, 'RequiresPHP');
219
+		$updateInfo->tested = Arr::get($this->data, 'testedTo');
220
+		$updateInfo->version = $updateInfo->new_version;
221
+		return $updateInfo;
222
+	}
223 223
 
224
-    /**
225
-     * @param \WP_Error|array $response
226
-     * @return object
227
-     */
228
-    protected function normalizeResponse($response)
229
-    {
230
-        $body = wp_remote_retrieve_body($response);
231
-        if ($data = json_decode($body)) {
232
-            $data = array_map('maybe_unserialize', (array) $data);
233
-            return (object) $data;
234
-        }
235
-        $error = is_wp_error($response)
236
-            ? $response->get_error_message()
237
-            : 'Update server not responding ('.Arr::get($this->data, 'TextDomain').')';
238
-        return (object) ['error' => $error];
239
-    }
224
+	/**
225
+	 * @param \WP_Error|array $response
226
+	 * @return object
227
+	 */
228
+	protected function normalizeResponse($response)
229
+	{
230
+		$body = wp_remote_retrieve_body($response);
231
+		if ($data = json_decode($body)) {
232
+			$data = array_map('maybe_unserialize', (array) $data);
233
+			return (object) $data;
234
+		}
235
+		$error = is_wp_error($response)
236
+			? $response->get_error_message()
237
+			: 'Update server not responding ('.Arr::get($this->data, 'TextDomain').')';
238
+		return (object) ['error' => $error];
239
+	}
240 240
 
241
-    /**
242
-     * @param string $action activate_license|check_license|deactivate_license|get_version
243
-     * @return object
244
-     */
245
-    protected function request($action, array $data = [])
246
-    {
247
-        $data = wp_parse_args($data, $this->data);
248
-        $response = wp_remote_post($this->apiUrl, [
249
-            'body' => [
250
-                'edd_action' => $action,
251
-                'item_id' => Arr::get($data, 'item_id'),
252
-                'item_name' => Arr::get($data, 'Name'),
253
-                'license' => Arr::get($data, 'license'),
254
-                'slug' => Arr::get($data, 'TextDomain'),
255
-                'url' => home_url(),
256
-            ],
257
-            'sslverify' => apply_filters('site-reviews/sslverify/post', false),
258
-            'timeout' => 15,
259
-        ]);
260
-        return $this->normalizeResponse($response);
261
-    }
241
+	/**
242
+	 * @param string $action activate_license|check_license|deactivate_license|get_version
243
+	 * @return object
244
+	 */
245
+	protected function request($action, array $data = [])
246
+	{
247
+		$data = wp_parse_args($data, $this->data);
248
+		$response = wp_remote_post($this->apiUrl, [
249
+			'body' => [
250
+				'edd_action' => $action,
251
+				'item_id' => Arr::get($data, 'item_id'),
252
+				'item_name' => Arr::get($data, 'Name'),
253
+				'license' => Arr::get($data, 'license'),
254
+				'slug' => Arr::get($data, 'TextDomain'),
255
+				'url' => home_url(),
256
+			],
257
+			'sslverify' => apply_filters('site-reviews/sslverify/post', false),
258
+			'timeout' => 15,
259
+		]);
260
+		return $this->normalizeResponse($response);
261
+	}
262 262
 
263
-    /**
264
-     * @param object $version
265
-     * @return void
266
-     */
267
-    protected function setCachedVersion($version)
268
-    {
269
-        if (!isset($version->error)) {
270
-            set_transient($this->transientName, $version, 3 * HOUR_IN_SECONDS);
271
-        }
272
-    }
263
+	/**
264
+	 * @param object $version
265
+	 * @return void
266
+	 */
267
+	protected function setCachedVersion($version)
268
+	{
269
+		if (!isset($version->error)) {
270
+			set_transient($this->transientName, $version, 3 * HOUR_IN_SECONDS);
271
+		}
272
+	}
273 273
 }
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -29,33 +29,33 @@  discard block
 block discarded – undo
29 29
      * @param string $apiUrl
30 30
      * @param string $file
31 31
      */
32
-    public function __construct($apiUrl, $file, array $data = [])
32
+    public function __construct( $apiUrl, $file, array $data = [] )
33 33
     {
34
-        if (!function_exists('get_plugin_data')) {
34
+        if( !function_exists( 'get_plugin_data' ) ) {
35 35
             require_once ABSPATH.WPINC.'/plugin.php';
36 36
         }
37
-        $this->apiUrl = trailingslashit(apply_filters('site-reviews/addon/api-url', $apiUrl));
38
-        $this->data = wp_parse_args($data, get_plugin_data($file));
39
-        $this->plugin = plugin_basename($file);
40
-        $this->transientName = Application::PREFIX.md5(Arr::get($data, 'TextDomain'));
37
+        $this->apiUrl = trailingslashit( apply_filters( 'site-reviews/addon/api-url', $apiUrl ) );
38
+        $this->data = wp_parse_args( $data, get_plugin_data( $file ) );
39
+        $this->plugin = plugin_basename( $file );
40
+        $this->transientName = Application::PREFIX.md5( Arr::get( $data, 'TextDomain' ) );
41 41
     }
42 42
 
43 43
     /**
44 44
      * @return object
45 45
      */
46
-    public function activateLicense(array $data = [])
46
+    public function activateLicense( array $data = [] )
47 47
     {
48
-        return $this->request('activate_license', $data);
48
+        return $this->request( 'activate_license', $data );
49 49
     }
50 50
 
51 51
     /**
52 52
      * @return object
53 53
      */
54
-    public function checkLicense(array $data = [])
54
+    public function checkLicense( array $data = [] )
55 55
     {
56
-        $response = $this->request('check_license', $data);
57
-        if ('valid' === Arr::get($response, 'license')) {
58
-            $this->getPluginUpdate(true);
56
+        $response = $this->request( 'check_license', $data );
57
+        if( 'valid' === Arr::get( $response, 'license' ) ) {
58
+            $this->getPluginUpdate( true );
59 59
         }
60 60
         return $response;
61 61
     }
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
     /**
64 64
      * @return object
65 65
      */
66
-    public function deactivateLicense(array $data = [])
66
+    public function deactivateLicense( array $data = [] )
67 67
     {
68
-        return $this->request('deactivate_license', $data);
68
+        return $this->request( 'deactivate_license', $data );
69 69
     }
70 70
 
71 71
     /**
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
      * @param object $args
75 75
      * @return mixed
76 76
      */
77
-    public function filterPluginUpdateDetails($result, $action, $args)
77
+    public function filterPluginUpdateDetails( $result, $action, $args )
78 78
     {
79
-        if ('plugin_information' != $action
80
-            || Arr::get($this->data, 'TextDomain') != Arr::get($args, 'slug')) {
79
+        if( 'plugin_information' != $action
80
+            || Arr::get( $this->data, 'TextDomain' ) != Arr::get( $args, 'slug' ) ) {
81 81
             return $result;
82 82
         }
83
-        if ($updateInfo = $this->getPluginUpdate()) {
84
-            return $this->modifyUpdateDetails($updateInfo);
83
+        if( $updateInfo = $this->getPluginUpdate() ) {
84
+            return $this->modifyUpdateDetails( $updateInfo );
85 85
         }
86 86
         return $result;
87 87
     }
@@ -90,10 +90,10 @@  discard block
 block discarded – undo
90 90
      * @param object $transient
91 91
      * @return object
92 92
      */
93
-    public function filterPluginUpdates($transient)
93
+    public function filterPluginUpdates( $transient )
94 94
     {
95
-        if ($updateInfo = $this->getPluginUpdate()) {
96
-            return $this->modifyPluginUpdates($transient, $updateInfo);
95
+        if( $updateInfo = $this->getPluginUpdate() ) {
96
+            return $this->modifyPluginUpdates( $transient, $updateInfo );
97 97
         }
98 98
         return $transient;
99 99
     }
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
     /**
102 102
      * @return object
103 103
      */
104
-    public function getVersion(array $data = [])
104
+    public function getVersion( array $data = [] )
105 105
     {
106
-        return $this->request('get_version', $data);
106
+        return $this->request( 'get_version', $data );
107 107
     }
108 108
 
109 109
     /**
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
      */
112 112
     public function init()
113 113
     {
114
-        if ($this->apiUrl === trailingslashit(home_url())) {
114
+        if( $this->apiUrl === trailingslashit( home_url() ) ) {
115 115
             return;
116 116
         }
117
-        add_filter('plugins_api',                             [$this, 'filterPluginUpdateDetails'], 10, 3);
118
-        add_filter('pre_set_site_transient_update_plugins',   [$this, 'filterPluginUpdates'], 999);
119
-        add_action('load-update-core.php',                    [$this, 'onForceUpdateCheck'], 9);
120
-        add_action('in_plugin_update_message-'.$this->plugin, [$this, 'renderLicenseMissingLink']);
117
+        add_filter( 'plugins_api', [$this, 'filterPluginUpdateDetails'], 10, 3 );
118
+        add_filter( 'pre_set_site_transient_update_plugins', [$this, 'filterPluginUpdates'], 999 );
119
+        add_action( 'load-update-core.php', [$this, 'onForceUpdateCheck'], 9 );
120
+        add_action( 'in_plugin_update_message-'.$this->plugin, [$this, 'renderLicenseMissingLink'] );
121 121
     }
122 122
 
123 123
     /**
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     public function isLicenseValid()
127 127
     {
128 128
         $result = $this->checkLicense();
129
-        return 'valid' === Arr::get($result, 'license');
129
+        return 'valid' === Arr::get( $result, 'license' );
130 130
     }
131 131
 
132 132
     /**
@@ -134,14 +134,14 @@  discard block
 block discarded – undo
134 134
      */
135 135
     public function onForceUpdateCheck()
136 136
     {
137
-        if (!filter_input(INPUT_GET, 'force-check')) {
137
+        if( !filter_input( INPUT_GET, 'force-check' ) ) {
138 138
             return;
139 139
         }
140
-        foreach (glsr()->addons as $addon) {
140
+        foreach( glsr()->addons as $addon ) {
141 141
             try {
142
-                glsr($addon)->updater->getPluginUpdate(true);
143
-            } catch (\Exception $e) {
144
-                glsr_log()->error($e->getMessage());
142
+                glsr( $addon )->updater->getPluginUpdate( true );
143
+            } catch( \Exception $e ) {
144
+                glsr_log()->error( $e->getMessage() );
145 145
             }
146 146
         }
147 147
     }
@@ -151,8 +151,8 @@  discard block
 block discarded – undo
151 151
      */
152 152
     public function renderLicenseMissingLink()
153 153
     {
154
-        if (!$this->isLicenseValid()) {
155
-            glsr()->render('partials/addons/license-missing');
154
+        if( !$this->isLicenseValid() ) {
155
+            glsr()->render( 'partials/addons/license-missing' );
156 156
         }
157 157
     }
158 158
 
@@ -161,22 +161,22 @@  discard block
 block discarded – undo
161 161
      */
162 162
     protected function getCachedVersion()
163 163
     {
164
-        return get_transient($this->transientName);
164
+        return get_transient( $this->transientName );
165 165
     }
166 166
 
167 167
     /**
168 168
      * @param bool $force
169 169
      * @return false|object
170 170
      */
171
-    protected function getPluginUpdate($force = false)
171
+    protected function getPluginUpdate( $force = false )
172 172
     {
173 173
         $version = $this->getCachedVersion();
174
-        if (false === $version || $force) {
174
+        if( false === $version || $force ) {
175 175
             $version = $this->getVersion();
176
-            $this->setCachedVersion($version);
176
+            $this->setCachedVersion( $version );
177 177
         }
178
-        if (isset($version->error)) {
179
-            glsr_log()->error($version->error);
178
+        if( isset($version->error) ) {
179
+            glsr_log()->error( $version->error );
180 180
             return false;
181 181
         }
182 182
         return $version;
@@ -187,15 +187,15 @@  discard block
 block discarded – undo
187 187
      * @param object $updateInfo
188 188
      * @return object
189 189
      */
190
-    protected function modifyPluginUpdates($transient, $updateInfo)
190
+    protected function modifyPluginUpdates( $transient, $updateInfo )
191 191
     {
192
-        $updateInfo->id = Application::ID.'/'.Arr::get($this->data, 'TextDomain');
192
+        $updateInfo->id = Application::ID.'/'.Arr::get( $this->data, 'TextDomain' );
193 193
         $updateInfo->plugin = $this->plugin;
194
-        $updateInfo->requires_php = Arr::get($this->data, 'RequiresPHP');
195
-        $updateInfo->tested = Arr::get($this->data, 'testedTo');
196
-        $transient->checked[$this->plugin] = Arr::get($this->data, 'Version');
194
+        $updateInfo->requires_php = Arr::get( $this->data, 'RequiresPHP' );
195
+        $updateInfo->tested = Arr::get( $this->data, 'testedTo' );
196
+        $transient->checked[$this->plugin] = Arr::get( $this->data, 'Version' );
197 197
         $transient->last_checked = time();
198
-        if (Helper::isGreaterThan($updateInfo->new_version, Arr::get($this->data, 'Version'))) {
198
+        if( Helper::isGreaterThan( $updateInfo->new_version, Arr::get( $this->data, 'Version' ) ) ) {
199 199
             unset($transient->no_update[$this->plugin]);
200 200
             $updateInfo->update = true;
201 201
             $transient->response[$this->plugin] = $updateInfo;
@@ -210,13 +210,13 @@  discard block
 block discarded – undo
210 210
      * @param object $updateInfo
211 211
      * @return object
212 212
      */
213
-    protected function modifyUpdateDetails($updateInfo)
213
+    protected function modifyUpdateDetails( $updateInfo )
214 214
     {
215
-        $updateInfo->author = Arr::get($this->data, 'Author');
216
-        $updateInfo->author_profile = Arr::get($this->data, 'AuthorURI');
217
-        $updateInfo->requires = Arr::get($this->data, 'RequiresWP');
218
-        $updateInfo->requires_php = Arr::get($this->data, 'RequiresPHP');
219
-        $updateInfo->tested = Arr::get($this->data, 'testedTo');
215
+        $updateInfo->author = Arr::get( $this->data, 'Author' );
216
+        $updateInfo->author_profile = Arr::get( $this->data, 'AuthorURI' );
217
+        $updateInfo->requires = Arr::get( $this->data, 'RequiresWP' );
218
+        $updateInfo->requires_php = Arr::get( $this->data, 'RequiresPHP' );
219
+        $updateInfo->tested = Arr::get( $this->data, 'testedTo' );
220 220
         $updateInfo->version = $updateInfo->new_version;
221 221
         return $updateInfo;
222 222
     }
@@ -225,49 +225,49 @@  discard block
 block discarded – undo
225 225
      * @param \WP_Error|array $response
226 226
      * @return object
227 227
      */
228
-    protected function normalizeResponse($response)
228
+    protected function normalizeResponse( $response )
229 229
     {
230
-        $body = wp_remote_retrieve_body($response);
231
-        if ($data = json_decode($body)) {
232
-            $data = array_map('maybe_unserialize', (array) $data);
233
-            return (object) $data;
230
+        $body = wp_remote_retrieve_body( $response );
231
+        if( $data = json_decode( $body ) ) {
232
+            $data = array_map( 'maybe_unserialize', (array)$data );
233
+            return (object)$data;
234 234
         }
235
-        $error = is_wp_error($response)
235
+        $error = is_wp_error( $response )
236 236
             ? $response->get_error_message()
237
-            : 'Update server not responding ('.Arr::get($this->data, 'TextDomain').')';
238
-        return (object) ['error' => $error];
237
+            : 'Update server not responding ('.Arr::get( $this->data, 'TextDomain' ).')';
238
+        return (object)['error' => $error];
239 239
     }
240 240
 
241 241
     /**
242 242
      * @param string $action activate_license|check_license|deactivate_license|get_version
243 243
      * @return object
244 244
      */
245
-    protected function request($action, array $data = [])
245
+    protected function request( $action, array $data = [] )
246 246
     {
247
-        $data = wp_parse_args($data, $this->data);
248
-        $response = wp_remote_post($this->apiUrl, [
247
+        $data = wp_parse_args( $data, $this->data );
248
+        $response = wp_remote_post( $this->apiUrl, [
249 249
             'body' => [
250 250
                 'edd_action' => $action,
251
-                'item_id' => Arr::get($data, 'item_id'),
252
-                'item_name' => Arr::get($data, 'Name'),
253
-                'license' => Arr::get($data, 'license'),
254
-                'slug' => Arr::get($data, 'TextDomain'),
251
+                'item_id' => Arr::get( $data, 'item_id' ),
252
+                'item_name' => Arr::get( $data, 'Name' ),
253
+                'license' => Arr::get( $data, 'license' ),
254
+                'slug' => Arr::get( $data, 'TextDomain' ),
255 255
                 'url' => home_url(),
256 256
             ],
257
-            'sslverify' => apply_filters('site-reviews/sslverify/post', false),
257
+            'sslverify' => apply_filters( 'site-reviews/sslverify/post', false ),
258 258
             'timeout' => 15,
259
-        ]);
260
-        return $this->normalizeResponse($response);
259
+        ] );
260
+        return $this->normalizeResponse( $response );
261 261
     }
262 262
 
263 263
     /**
264 264
      * @param object $version
265 265
      * @return void
266 266
      */
267
-    protected function setCachedVersion($version)
267
+    protected function setCachedVersion( $version )
268 268
     {
269
-        if (!isset($version->error)) {
270
-            set_transient($this->transientName, $version, 3 * HOUR_IN_SECONDS);
269
+        if( !isset($version->error) ) {
270
+            set_transient( $this->transientName, $version, 3 * HOUR_IN_SECONDS );
271 271
         }
272 272
     }
273 273
 }
Please login to merge, or discard this patch.
plugin/Controllers/ReviewController.php 3 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,8 @@
 block discarded – undo
64 64
         $review = glsr_get_review($post);
65 65
         if ('publish' == $post->post_status) {
66 66
             glsr(CountsManager::class)->increaseAll($review);
67
-        } else {
67
+        }
68
+        else {
68 69
             glsr(CountsManager::class)->decreaseAll($review);
69 70
         }
70 71
     }
Please login to merge, or discard this patch.
Indentation   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -16,159 +16,159 @@
 block discarded – undo
16 16
 
17 17
 class ReviewController extends Controller
18 18
 {
19
-    /**
20
-     * Triggered when a category is added to a review.
21
-     *
22
-     * @param int $postId
23
-     * @param array $terms
24
-     * @param array $newTTIds
25
-     * @param string $taxonomy
26
-     * @param bool $append
27
-     * @param array $oldTTIds
28
-     * @return void
29
-     * @action set_object_terms
30
-     */
31
-    public function onAfterChangeCategory($postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds)
32
-    {
33
-        sort($newTTIds);
34
-        sort($oldTTIds);
35
-        if ($newTTIds === $oldTTIds || !$this->isReviewPostId($postId)) {
36
-            return;
37
-        }
38
-        $review = glsr_get_review($postId);
39
-        if ('publish' !== $review->status) {
40
-            return;
41
-        }
42
-        $ignoredIds = array_intersect($oldTTIds, $newTTIds);
43
-        $decreasedIds = array_diff($oldTTIds, $ignoredIds);
44
-        $increasedIds = array_diff($newTTIds, $ignoredIds);
45
-        if ($review->term_ids = glsr(Database::class)->getTermIds($decreasedIds, 'term_taxonomy_id')) {
46
-            glsr(TermCountsManager::class)->decrease($review);
47
-        }
48
-        if ($review->term_ids = glsr(Database::class)->getTermIds($increasedIds, 'term_taxonomy_id')) {
49
-            glsr(TermCountsManager::class)->increase($review);
50
-        }
51
-    }
19
+	/**
20
+	 * Triggered when a category is added to a review.
21
+	 *
22
+	 * @param int $postId
23
+	 * @param array $terms
24
+	 * @param array $newTTIds
25
+	 * @param string $taxonomy
26
+	 * @param bool $append
27
+	 * @param array $oldTTIds
28
+	 * @return void
29
+	 * @action set_object_terms
30
+	 */
31
+	public function onAfterChangeCategory($postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds)
32
+	{
33
+		sort($newTTIds);
34
+		sort($oldTTIds);
35
+		if ($newTTIds === $oldTTIds || !$this->isReviewPostId($postId)) {
36
+			return;
37
+		}
38
+		$review = glsr_get_review($postId);
39
+		if ('publish' !== $review->status) {
40
+			return;
41
+		}
42
+		$ignoredIds = array_intersect($oldTTIds, $newTTIds);
43
+		$decreasedIds = array_diff($oldTTIds, $ignoredIds);
44
+		$increasedIds = array_diff($newTTIds, $ignoredIds);
45
+		if ($review->term_ids = glsr(Database::class)->getTermIds($decreasedIds, 'term_taxonomy_id')) {
46
+			glsr(TermCountsManager::class)->decrease($review);
47
+		}
48
+		if ($review->term_ids = glsr(Database::class)->getTermIds($increasedIds, 'term_taxonomy_id')) {
49
+			glsr(TermCountsManager::class)->increase($review);
50
+		}
51
+	}
52 52
 
53
-    /**
54
-     * Triggered when an existing review is approved|unapproved.
55
-     *
56
-     * @param string $oldStatus
57
-     * @param string $newStatus
58
-     * @param \WP_Post $post
59
-     * @return void
60
-     * @action transition_post_status
61
-     */
62
-    public function onAfterChangeStatus($newStatus, $oldStatus, $post)
63
-    {
64
-        if (Application::POST_TYPE != Arr::get($post, 'post_type') 
65
-            || in_array($oldStatus, ['new', $newStatus])) {
66
-            return;
67
-        }
68
-        $review = glsr_get_review($post);
69
-        if ('publish' == $post->post_status) {
70
-            glsr(CountsManager::class)->increaseAll($review);
71
-        } else {
72
-            glsr(CountsManager::class)->decreaseAll($review);
73
-        }
74
-    }
53
+	/**
54
+	 * Triggered when an existing review is approved|unapproved.
55
+	 *
56
+	 * @param string $oldStatus
57
+	 * @param string $newStatus
58
+	 * @param \WP_Post $post
59
+	 * @return void
60
+	 * @action transition_post_status
61
+	 */
62
+	public function onAfterChangeStatus($newStatus, $oldStatus, $post)
63
+	{
64
+		if (Application::POST_TYPE != Arr::get($post, 'post_type') 
65
+			|| in_array($oldStatus, ['new', $newStatus])) {
66
+			return;
67
+		}
68
+		$review = glsr_get_review($post);
69
+		if ('publish' == $post->post_status) {
70
+			glsr(CountsManager::class)->increaseAll($review);
71
+		} else {
72
+			glsr(CountsManager::class)->decreaseAll($review);
73
+		}
74
+	}
75 75
 
76
-    /**
77
-     * Triggered when a review is first created.
78
-     *
79
-     * @return void
80
-     * @action site-reviews/review/created
81
-     */
82
-    public function onAfterCreate(Review $review)
83
-    {
84
-        if ('publish' !== $review->status) {
85
-            return;
86
-        }
87
-        glsr(GlobalCountsManager::class)->increase($review);
88
-        glsr(PostCountsManager::class)->increase($review);
89
-    }
76
+	/**
77
+	 * Triggered when a review is first created.
78
+	 *
79
+	 * @return void
80
+	 * @action site-reviews/review/created
81
+	 */
82
+	public function onAfterCreate(Review $review)
83
+	{
84
+		if ('publish' !== $review->status) {
85
+			return;
86
+		}
87
+		glsr(GlobalCountsManager::class)->increase($review);
88
+		glsr(PostCountsManager::class)->increase($review);
89
+	}
90 90
 
91
-    /**
92
-     * Triggered when a review is deleted.
93
-     *
94
-     * @param int $postId
95
-     * @return void
96
-     * @action before_delete_post
97
-     */
98
-    public function onBeforeDelete($postId)
99
-    {
100
-        if (!$this->isReviewPostId($postId)) {
101
-            return;
102
-        }
103
-        $review = glsr_get_review($postId);
104
-        if ('trash' !== $review->status) { // do not run for trashed posts
105
-            glsr(CountsManager::class)->decreaseAll($review);
106
-        }
107
-    }
91
+	/**
92
+	 * Triggered when a review is deleted.
93
+	 *
94
+	 * @param int $postId
95
+	 * @return void
96
+	 * @action before_delete_post
97
+	 */
98
+	public function onBeforeDelete($postId)
99
+	{
100
+		if (!$this->isReviewPostId($postId)) {
101
+			return;
102
+		}
103
+		$review = glsr_get_review($postId);
104
+		if ('trash' !== $review->status) { // do not run for trashed posts
105
+			glsr(CountsManager::class)->decreaseAll($review);
106
+		}
107
+	}
108 108
 
109
-    /**
110
-     * Triggered when a review's rating, assigned_to, or review_type is changed.
111
-     *
112
-     * @param int $metaId
113
-     * @param int $postId
114
-     * @param string $metaKey
115
-     * @param mixed $metaValue
116
-     * @return void
117
-     * @action update_postmeta
118
-     */
119
-    public function onBeforeUpdate($metaId, $postId, $metaKey, $metaValue)
120
-    {
121
-        if (!$this->isReviewPostId($postId)) {
122
-            return;
123
-        }
124
-        $metaKey = Str::removePrefix('_', $metaKey);
125
-        if (!in_array($metaKey, ['assigned_to', 'rating', 'review_type'])) {
126
-            return;
127
-        }
128
-        $review = glsr_get_review($postId);
129
-        if ($review->$metaKey == $metaValue) {
130
-            return;
131
-        }
132
-        $method = Helper::buildMethodName($metaKey, 'onBeforeChange');
133
-        call_user_func([$this, $method], $review, $metaValue);
134
-    }
109
+	/**
110
+	 * Triggered when a review's rating, assigned_to, or review_type is changed.
111
+	 *
112
+	 * @param int $metaId
113
+	 * @param int $postId
114
+	 * @param string $metaKey
115
+	 * @param mixed $metaValue
116
+	 * @return void
117
+	 * @action update_postmeta
118
+	 */
119
+	public function onBeforeUpdate($metaId, $postId, $metaKey, $metaValue)
120
+	{
121
+		if (!$this->isReviewPostId($postId)) {
122
+			return;
123
+		}
124
+		$metaKey = Str::removePrefix('_', $metaKey);
125
+		if (!in_array($metaKey, ['assigned_to', 'rating', 'review_type'])) {
126
+			return;
127
+		}
128
+		$review = glsr_get_review($postId);
129
+		if ($review->$metaKey == $metaValue) {
130
+			return;
131
+		}
132
+		$method = Helper::buildMethodName($metaKey, 'onBeforeChange');
133
+		call_user_func([$this, $method], $review, $metaValue);
134
+	}
135 135
 
136
-    /**
137
-     * Triggered by the onBeforeUpdate method.
138
-     *
139
-     * @param string|int $assignedTo
140
-     * @return void
141
-     */
142
-    protected function onBeforeChangeAssignedTo(Review $review, $assignedTo)
143
-    {
144
-        glsr(PostCountsManager::class)->decrease($review);
145
-        $review->assigned_to = $assignedTo;
146
-        glsr(PostCountsManager::class)->increase($review);
147
-    }
136
+	/**
137
+	 * Triggered by the onBeforeUpdate method.
138
+	 *
139
+	 * @param string|int $assignedTo
140
+	 * @return void
141
+	 */
142
+	protected function onBeforeChangeAssignedTo(Review $review, $assignedTo)
143
+	{
144
+		glsr(PostCountsManager::class)->decrease($review);
145
+		$review->assigned_to = $assignedTo;
146
+		glsr(PostCountsManager::class)->increase($review);
147
+	}
148 148
 
149
-    /**
150
-     * Triggered by the onBeforeUpdate method.
151
-     *
152
-     * @param string|int $rating
153
-     * @return void
154
-     */
155
-    protected function onBeforeChangeRating(Review $review, $rating)
156
-    {
157
-        glsr(CountsManager::class)->decreaseAll($review);
158
-        $review->rating = $rating;
159
-        glsr(CountsManager::class)->increaseAll($review);
160
-    }
149
+	/**
150
+	 * Triggered by the onBeforeUpdate method.
151
+	 *
152
+	 * @param string|int $rating
153
+	 * @return void
154
+	 */
155
+	protected function onBeforeChangeRating(Review $review, $rating)
156
+	{
157
+		glsr(CountsManager::class)->decreaseAll($review);
158
+		$review->rating = $rating;
159
+		glsr(CountsManager::class)->increaseAll($review);
160
+	}
161 161
 
162
-    /**
163
-     * Triggered by the onBeforeUpdate method.
164
-     *
165
-     * @param string $reviewType
166
-     * @return void
167
-     */
168
-    protected function onBeforeChangeReviewType(Review $review, $reviewType)
169
-    {
170
-        glsr(CountsManager::class)->decreaseAll($review);
171
-        $review->review_type = $reviewType;
172
-        glsr(CountsManager::class)->increaseAll($review);
173
-    }
162
+	/**
163
+	 * Triggered by the onBeforeUpdate method.
164
+	 *
165
+	 * @param string $reviewType
166
+	 * @return void
167
+	 */
168
+	protected function onBeforeChangeReviewType(Review $review, $reviewType)
169
+	{
170
+		glsr(CountsManager::class)->decreaseAll($review);
171
+		$review->review_type = $reviewType;
172
+		glsr(CountsManager::class)->increaseAll($review);
173
+	}
174 174
 }
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -28,25 +28,25 @@  discard block
 block discarded – undo
28 28
      * @return void
29 29
      * @action set_object_terms
30 30
      */
31
-    public function onAfterChangeCategory($postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds)
31
+    public function onAfterChangeCategory( $postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds )
32 32
     {
33
-        sort($newTTIds);
34
-        sort($oldTTIds);
35
-        if ($newTTIds === $oldTTIds || !$this->isReviewPostId($postId)) {
33
+        sort( $newTTIds );
34
+        sort( $oldTTIds );
35
+        if( $newTTIds === $oldTTIds || !$this->isReviewPostId( $postId ) ) {
36 36
             return;
37 37
         }
38
-        $review = glsr_get_review($postId);
39
-        if ('publish' !== $review->status) {
38
+        $review = glsr_get_review( $postId );
39
+        if( 'publish' !== $review->status ) {
40 40
             return;
41 41
         }
42
-        $ignoredIds = array_intersect($oldTTIds, $newTTIds);
43
-        $decreasedIds = array_diff($oldTTIds, $ignoredIds);
44
-        $increasedIds = array_diff($newTTIds, $ignoredIds);
45
-        if ($review->term_ids = glsr(Database::class)->getTermIds($decreasedIds, 'term_taxonomy_id')) {
46
-            glsr(TermCountsManager::class)->decrease($review);
42
+        $ignoredIds = array_intersect( $oldTTIds, $newTTIds );
43
+        $decreasedIds = array_diff( $oldTTIds, $ignoredIds );
44
+        $increasedIds = array_diff( $newTTIds, $ignoredIds );
45
+        if( $review->term_ids = glsr( Database::class )->getTermIds( $decreasedIds, 'term_taxonomy_id' ) ) {
46
+            glsr( TermCountsManager::class )->decrease( $review );
47 47
         }
48
-        if ($review->term_ids = glsr(Database::class)->getTermIds($increasedIds, 'term_taxonomy_id')) {
49
-            glsr(TermCountsManager::class)->increase($review);
48
+        if( $review->term_ids = glsr( Database::class )->getTermIds( $increasedIds, 'term_taxonomy_id' ) ) {
49
+            glsr( TermCountsManager::class )->increase( $review );
50 50
         }
51 51
     }
52 52
 
@@ -59,17 +59,17 @@  discard block
 block discarded – undo
59 59
      * @return void
60 60
      * @action transition_post_status
61 61
      */
62
-    public function onAfterChangeStatus($newStatus, $oldStatus, $post)
62
+    public function onAfterChangeStatus( $newStatus, $oldStatus, $post )
63 63
     {
64
-        if (Application::POST_TYPE != Arr::get($post, 'post_type') 
65
-            || in_array($oldStatus, ['new', $newStatus])) {
64
+        if( Application::POST_TYPE != Arr::get( $post, 'post_type' ) 
65
+            || in_array( $oldStatus, ['new', $newStatus] ) ) {
66 66
             return;
67 67
         }
68
-        $review = glsr_get_review($post);
69
-        if ('publish' == $post->post_status) {
70
-            glsr(CountsManager::class)->increaseAll($review);
68
+        $review = glsr_get_review( $post );
69
+        if( 'publish' == $post->post_status ) {
70
+            glsr( CountsManager::class )->increaseAll( $review );
71 71
         } else {
72
-            glsr(CountsManager::class)->decreaseAll($review);
72
+            glsr( CountsManager::class )->decreaseAll( $review );
73 73
         }
74 74
     }
75 75
 
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
      * @return void
80 80
      * @action site-reviews/review/created
81 81
      */
82
-    public function onAfterCreate(Review $review)
82
+    public function onAfterCreate( Review $review )
83 83
     {
84
-        if ('publish' !== $review->status) {
84
+        if( 'publish' !== $review->status ) {
85 85
             return;
86 86
         }
87
-        glsr(GlobalCountsManager::class)->increase($review);
88
-        glsr(PostCountsManager::class)->increase($review);
87
+        glsr( GlobalCountsManager::class )->increase( $review );
88
+        glsr( PostCountsManager::class )->increase( $review );
89 89
     }
90 90
 
91 91
     /**
@@ -95,14 +95,14 @@  discard block
 block discarded – undo
95 95
      * @return void
96 96
      * @action before_delete_post
97 97
      */
98
-    public function onBeforeDelete($postId)
98
+    public function onBeforeDelete( $postId )
99 99
     {
100
-        if (!$this->isReviewPostId($postId)) {
100
+        if( !$this->isReviewPostId( $postId ) ) {
101 101
             return;
102 102
         }
103
-        $review = glsr_get_review($postId);
104
-        if ('trash' !== $review->status) { // do not run for trashed posts
105
-            glsr(CountsManager::class)->decreaseAll($review);
103
+        $review = glsr_get_review( $postId );
104
+        if( 'trash' !== $review->status ) { // do not run for trashed posts
105
+            glsr( CountsManager::class )->decreaseAll( $review );
106 106
         }
107 107
     }
108 108
 
@@ -116,21 +116,21 @@  discard block
 block discarded – undo
116 116
      * @return void
117 117
      * @action update_postmeta
118 118
      */
119
-    public function onBeforeUpdate($metaId, $postId, $metaKey, $metaValue)
119
+    public function onBeforeUpdate( $metaId, $postId, $metaKey, $metaValue )
120 120
     {
121
-        if (!$this->isReviewPostId($postId)) {
121
+        if( !$this->isReviewPostId( $postId ) ) {
122 122
             return;
123 123
         }
124
-        $metaKey = Str::removePrefix('_', $metaKey);
125
-        if (!in_array($metaKey, ['assigned_to', 'rating', 'review_type'])) {
124
+        $metaKey = Str::removePrefix( '_', $metaKey );
125
+        if( !in_array( $metaKey, ['assigned_to', 'rating', 'review_type'] ) ) {
126 126
             return;
127 127
         }
128
-        $review = glsr_get_review($postId);
129
-        if ($review->$metaKey == $metaValue) {
128
+        $review = glsr_get_review( $postId );
129
+        if( $review->$metaKey == $metaValue ) {
130 130
             return;
131 131
         }
132
-        $method = Helper::buildMethodName($metaKey, 'onBeforeChange');
133
-        call_user_func([$this, $method], $review, $metaValue);
132
+        $method = Helper::buildMethodName( $metaKey, 'onBeforeChange' );
133
+        call_user_func( [$this, $method], $review, $metaValue );
134 134
     }
135 135
 
136 136
     /**
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
      * @param string|int $assignedTo
140 140
      * @return void
141 141
      */
142
-    protected function onBeforeChangeAssignedTo(Review $review, $assignedTo)
142
+    protected function onBeforeChangeAssignedTo( Review $review, $assignedTo )
143 143
     {
144
-        glsr(PostCountsManager::class)->decrease($review);
144
+        glsr( PostCountsManager::class )->decrease( $review );
145 145
         $review->assigned_to = $assignedTo;
146
-        glsr(PostCountsManager::class)->increase($review);
146
+        glsr( PostCountsManager::class )->increase( $review );
147 147
     }
148 148
 
149 149
     /**
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
      * @param string|int $rating
153 153
      * @return void
154 154
      */
155
-    protected function onBeforeChangeRating(Review $review, $rating)
155
+    protected function onBeforeChangeRating( Review $review, $rating )
156 156
     {
157
-        glsr(CountsManager::class)->decreaseAll($review);
157
+        glsr( CountsManager::class )->decreaseAll( $review );
158 158
         $review->rating = $rating;
159
-        glsr(CountsManager::class)->increaseAll($review);
159
+        glsr( CountsManager::class )->increaseAll( $review );
160 160
     }
161 161
 
162 162
     /**
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
      * @param string $reviewType
166 166
      * @return void
167 167
      */
168
-    protected function onBeforeChangeReviewType(Review $review, $reviewType)
168
+    protected function onBeforeChangeReviewType( Review $review, $reviewType )
169 169
     {
170
-        glsr(CountsManager::class)->decreaseAll($review);
170
+        glsr( CountsManager::class )->decreaseAll( $review );
171 171
         $review->review_type = $reviewType;
172
-        glsr(CountsManager::class)->increaseAll($review);
172
+        glsr( CountsManager::class )->increaseAll( $review );
173 173
     }
174 174
 }
Please login to merge, or discard this patch.
plugin/Database/TermCountsManager.php 2 patches
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -9,92 +9,92 @@
 block discarded – undo
9 9
 
10 10
 class TermCountsManager
11 11
 {
12
-    /**
13
-     * @var CountsManager
14
-     */
15
-    protected $manager;
12
+	/**
13
+	 * @var CountsManager
14
+	 */
15
+	protected $manager;
16 16
 
17
-    public function __construct()
18
-    {
19
-        $this->manager = glsr(CountsManager::class);
20
-    }
17
+	public function __construct()
18
+	{
19
+		$this->manager = glsr(CountsManager::class);
20
+	}
21 21
 
22
-    /**
23
-     * @param int $termTaxonomyId
24
-     * @return array
25
-     */
26
-    public function build($termTaxonomyId)
27
-    {
28
-        return $this->manager->buildCounts([
29
-            'term_ids' => [$termTaxonomyId],
30
-        ]);
31
-    }
22
+	/**
23
+	 * @param int $termTaxonomyId
24
+	 * @return array
25
+	 */
26
+	public function build($termTaxonomyId)
27
+	{
28
+		return $this->manager->buildCounts([
29
+			'term_ids' => [$termTaxonomyId],
30
+		]);
31
+	}
32 32
 
33
-    /**
34
-     * @return void
35
-     */
36
-    public function decrease(Review $review)
37
-    {
38
-        foreach ($review->term_ids as $termId) {
39
-            if (empty($counts = $this->get($termId))) {
40
-                continue;
41
-            }
42
-            $this->update($termId,
43
-                $this->manager->decreaseRating($counts, $review->review_type, $review->rating)
44
-            );
45
-        }
46
-    }
33
+	/**
34
+	 * @return void
35
+	 */
36
+	public function decrease(Review $review)
37
+	{
38
+		foreach ($review->term_ids as $termId) {
39
+			if (empty($counts = $this->get($termId))) {
40
+				continue;
41
+			}
42
+			$this->update($termId,
43
+				$this->manager->decreaseRating($counts, $review->review_type, $review->rating)
44
+			);
45
+		}
46
+	}
47 47
 
48
-    /**
49
-     * @param int $termId
50
-     * @return array
51
-     */
52
-    public function get($termId)
53
-    {
54
-        return array_filter((array) get_term_meta($termId, CountsManager::META_COUNT, true));
55
-    }
48
+	/**
49
+	 * @param int $termId
50
+	 * @return array
51
+	 */
52
+	public function get($termId)
53
+	{
54
+		return array_filter((array) get_term_meta($termId, CountsManager::META_COUNT, true));
55
+	}
56 56
 
57
-    /**
58
-     * @return void
59
-     */
60
-    public function increase(Review $review)
61
-    {
62
-        $terms = glsr(ReviewManager::class)->normalizeTerms(implode(',', $review->term_ids));
63
-        foreach ($terms as $term) {
64
-            $counts = $this->get($term['term_id']);
65
-            $counts = empty($counts)
66
-                ? $this->build($term['term_taxonomy_id'])
67
-                : $this->manager->increaseRating($counts, $review->review_type, $review->rating);
68
-            $this->update($term['term_id'], $counts);
69
-        }
70
-    }
57
+	/**
58
+	 * @return void
59
+	 */
60
+	public function increase(Review $review)
61
+	{
62
+		$terms = glsr(ReviewManager::class)->normalizeTerms(implode(',', $review->term_ids));
63
+		foreach ($terms as $term) {
64
+			$counts = $this->get($term['term_id']);
65
+			$counts = empty($counts)
66
+				? $this->build($term['term_taxonomy_id'])
67
+				: $this->manager->increaseRating($counts, $review->review_type, $review->rating);
68
+			$this->update($term['term_id'], $counts);
69
+		}
70
+	}
71 71
 
72
-    /**
73
-     * @param int $termId
74
-     * @return void
75
-     */
76
-    public function update($termId, array $reviewCounts)
77
-    {
78
-        $term = get_term($termId, Application::TAXONOMY);
79
-        if (!isset($term->term_id)) {
80
-            return;
81
-        }
82
-        $ratingCounts = $this->manager->flatten($reviewCounts);
83
-        update_term_meta($termId, CountsManager::META_COUNT, $reviewCounts);
84
-        update_term_meta($termId, CountsManager::META_AVERAGE, glsr(Rating::class)->getAverage($ratingCounts));
85
-        update_term_meta($termId, CountsManager::META_RANKING, glsr(Rating::class)->getRanking($ratingCounts));
86
-    }
72
+	/**
73
+	 * @param int $termId
74
+	 * @return void
75
+	 */
76
+	public function update($termId, array $reviewCounts)
77
+	{
78
+		$term = get_term($termId, Application::TAXONOMY);
79
+		if (!isset($term->term_id)) {
80
+			return;
81
+		}
82
+		$ratingCounts = $this->manager->flatten($reviewCounts);
83
+		update_term_meta($termId, CountsManager::META_COUNT, $reviewCounts);
84
+		update_term_meta($termId, CountsManager::META_AVERAGE, glsr(Rating::class)->getAverage($ratingCounts));
85
+		update_term_meta($termId, CountsManager::META_RANKING, glsr(Rating::class)->getRanking($ratingCounts));
86
+	}
87 87
 
88
-    /**
89
-     * @return void
90
-     */
91
-    public function updateAll()
92
-    {
93
-        $terms = glsr(Database::class)->getTerms([
94
-            'fields' => 'all',
95
-        ]);
96
-        foreach ($terms as $term) {
97
-            $this->update($term->term_id, $this->build($term->term_taxonomy_id));
98
-        }
99
-    }
88
+	/**
89
+	 * @return void
90
+	 */
91
+	public function updateAll()
92
+	{
93
+		$terms = glsr(Database::class)->getTerms([
94
+			'fields' => 'all',
95
+		]);
96
+		foreach ($terms as $term) {
97
+			$this->update($term->term_id, $this->build($term->term_taxonomy_id));
98
+		}
99
+	}
100 100
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -16,31 +16,31 @@  discard block
 block discarded – undo
16 16
 
17 17
     public function __construct()
18 18
     {
19
-        $this->manager = glsr(CountsManager::class);
19
+        $this->manager = glsr( CountsManager::class );
20 20
     }
21 21
 
22 22
     /**
23 23
      * @param int $termTaxonomyId
24 24
      * @return array
25 25
      */
26
-    public function build($termTaxonomyId)
26
+    public function build( $termTaxonomyId )
27 27
     {
28
-        return $this->manager->buildCounts([
28
+        return $this->manager->buildCounts( [
29 29
             'term_ids' => [$termTaxonomyId],
30
-        ]);
30
+        ] );
31 31
     }
32 32
 
33 33
     /**
34 34
      * @return void
35 35
      */
36
-    public function decrease(Review $review)
36
+    public function decrease( Review $review )
37 37
     {
38
-        foreach ($review->term_ids as $termId) {
39
-            if (empty($counts = $this->get($termId))) {
38
+        foreach( $review->term_ids as $termId ) {
39
+            if( empty($counts = $this->get( $termId )) ) {
40 40
                 continue;
41 41
             }
42
-            $this->update($termId,
43
-                $this->manager->decreaseRating($counts, $review->review_type, $review->rating)
42
+            $this->update( $termId,
43
+                $this->manager->decreaseRating( $counts, $review->review_type, $review->rating )
44 44
             );
45 45
         }
46 46
     }
@@ -49,23 +49,23 @@  discard block
 block discarded – undo
49 49
      * @param int $termId
50 50
      * @return array
51 51
      */
52
-    public function get($termId)
52
+    public function get( $termId )
53 53
     {
54
-        return array_filter((array) get_term_meta($termId, CountsManager::META_COUNT, true));
54
+        return array_filter( (array)get_term_meta( $termId, CountsManager::META_COUNT, true ) );
55 55
     }
56 56
 
57 57
     /**
58 58
      * @return void
59 59
      */
60
-    public function increase(Review $review)
60
+    public function increase( Review $review )
61 61
     {
62
-        $terms = glsr(ReviewManager::class)->normalizeTerms(implode(',', $review->term_ids));
63
-        foreach ($terms as $term) {
64
-            $counts = $this->get($term['term_id']);
62
+        $terms = glsr( ReviewManager::class )->normalizeTerms( implode( ',', $review->term_ids ) );
63
+        foreach( $terms as $term ) {
64
+            $counts = $this->get( $term['term_id'] );
65 65
             $counts = empty($counts)
66
-                ? $this->build($term['term_taxonomy_id'])
67
-                : $this->manager->increaseRating($counts, $review->review_type, $review->rating);
68
-            $this->update($term['term_id'], $counts);
66
+                ? $this->build( $term['term_taxonomy_id'] )
67
+                : $this->manager->increaseRating( $counts, $review->review_type, $review->rating );
68
+            $this->update( $term['term_id'], $counts );
69 69
         }
70 70
     }
71 71
 
@@ -73,16 +73,16 @@  discard block
 block discarded – undo
73 73
      * @param int $termId
74 74
      * @return void
75 75
      */
76
-    public function update($termId, array $reviewCounts)
76
+    public function update( $termId, array $reviewCounts )
77 77
     {
78
-        $term = get_term($termId, Application::TAXONOMY);
79
-        if (!isset($term->term_id)) {
78
+        $term = get_term( $termId, Application::TAXONOMY );
79
+        if( !isset($term->term_id) ) {
80 80
             return;
81 81
         }
82
-        $ratingCounts = $this->manager->flatten($reviewCounts);
83
-        update_term_meta($termId, CountsManager::META_COUNT, $reviewCounts);
84
-        update_term_meta($termId, CountsManager::META_AVERAGE, glsr(Rating::class)->getAverage($ratingCounts));
85
-        update_term_meta($termId, CountsManager::META_RANKING, glsr(Rating::class)->getRanking($ratingCounts));
82
+        $ratingCounts = $this->manager->flatten( $reviewCounts );
83
+        update_term_meta( $termId, CountsManager::META_COUNT, $reviewCounts );
84
+        update_term_meta( $termId, CountsManager::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ) );
85
+        update_term_meta( $termId, CountsManager::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ) );
86 86
     }
87 87
 
88 88
     /**
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
      */
91 91
     public function updateAll()
92 92
     {
93
-        $terms = glsr(Database::class)->getTerms([
93
+        $terms = glsr( Database::class )->getTerms( [
94 94
             'fields' => 'all',
95
-        ]);
96
-        foreach ($terms as $term) {
97
-            $this->update($term->term_id, $this->build($term->term_taxonomy_id));
95
+        ] );
96
+        foreach( $terms as $term ) {
97
+            $this->update( $term->term_id, $this->build( $term->term_taxonomy_id ) );
98 98
         }
99 99
     }
100 100
 }
Please login to merge, or discard this patch.