Test Failed
Push — master ( 31c635...ef6440 )
by Paul
07:17 queued 01:32
created

StarRatingDefaults   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 13
dl 0
loc 33
ccs 0
cts 13
cp 0
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A normalize() 0 4 1
A defaults() 0 7 2
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Defaults;
4
5
use GeminiLabs\SiteReviews\Defaults\DefaultsAbstract as Defaults;
6
use GeminiLabs\SiteReviews\Helpers\Arr;
7
8
class StarRatingDefaults extends Defaults
9
{
10
    /**
11
     * @var array
12
     */
13
    public $casts = [
14
        'args' => 'array',
15
        'count' => 'int',
16
        'prefix' => 'string',
17
        'rating' => 'float',
18
    ];
19
20
    /**
21
     * @return array
22
     */
23
    protected function defaults()
24
    {
25
        return [
26
            'args' => [],
27
            'count' => 0,
28
            'prefix' => glsr()->isAdmin() ? '' : 'glsr-',
29
            'rating' => 0,
30
        ];
31
    }
32
33
    /**
34
     * Normalize provided values, this always runs first.
35
     * @return array
36
     */
37
    protected function normalize(array $values = [])
38
    {
39
        $values['rating'] = sprintf('%g', Arr::get($values,'rating', 0));
40
        return $values;
41
    }
42
}
43