ReportReviewsTotalsController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 12
dl 0
loc 22
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A get_reports() 0 17 3
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\WooCommerce\Controllers\RestApi;
4
5
class ReportReviewsTotalsController extends \WC_REST_Report_Reviews_Totals_Controller
6
{
7
    /**
8
     * @return array
9
     */
10
    protected function get_reports()
11
    {
12
        $ratings = glsr_get_ratings([
13
            'assigned_posts' => 'product',
14
        ]);
15
        $data = [];
16
        foreach ($ratings->ratings as $rating => $total) {
17
            if ($rating < 1) {
18
                continue;
19
            }
20
            $data[] = [
21
                'slug' => sprintf('rated_%s_out_of_5', $rating),
22
                'name' => sprintf(__('Rated %s out of 5', 'woocommerce'), $rating),
23
                'total' => $total,
24
            ];
25
        }
26
        return $data;
27
    }
28
}
29