SummarySchema   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 36
dl 0
loc 57
ccs 0
cts 45
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A schema() 0 9 1
A properties() 0 38 1
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Controllers\Api\Version1\Schema;
4
5
class SummarySchema
6
{
7
    /**
8
     * @return array
9
     */
10
    public function schema()
11
    {
12
        $schema = [
13
            '$schema' => 'http://json-schema.org/draft-04/schema#',
14
            'properties' => $this->properties(),
15
            'title' => 'rating-summary',
16
            'type' => 'object',
17
        ];
18
        return $schema;
19
    }
20
21
    /**
22
     * @return array
23
     */
24
    protected function properties()
25
    {
26
        $properties = [
27
            'average' => [
28
                'context' => ['view'],
29
                'description' => _x('The average rating.', 'admin-text', 'site-reviews'),
30
                'type' => 'number',
31
            ],
32
            'maximum' => [
33
                'context' => ['view'],
34
                'description' => _x('The defined maximum rating.', 'admin-text', 'site-reviews'),
35
                'type' => 'integer',
36
            ],
37
            'minimum' => [
38
                'context' => ['view'],
39
                'description' => _x('The defined minimum rating.', 'admin-text', 'site-reviews'),
40
                'type' => 'integer',
41
            ],
42
            'ranking' => [
43
                'context' => ['view'],
44
                'description' => _x('The bayesian ranking number.', 'admin-text', 'site-reviews'),
45
                'type' => 'number',
46
            ],
47
            'ratings' => [
48
                'context' => ['view'],
49
                'description' => _x('The total number of reviews for each rating level from zero to maximum rating.', 'admin-text', 'site-reviews'),
50
                'items' => ['type' => 'integer'],
51
                'type' => 'array',
52
            ],
53
            'reviews' => [
54
                'context' => ['view'],
55
                'description' => _x('The total number of reviews used to calculate the average.', 'admin-text', 'site-reviews'),
56
                'type' => 'integer',
57
            ],
58
        ];
59
        $properties = glsr()->filterArray('rest-api/summary/schema/properties', $properties);
60
        ksort($properties);
61
        return $properties;
62
    }
63
}
64