Passed
Push — master ( ece31d...41b8a6 )
by Paul
10:20 queued 04:17
created

SiteReviewsFormShortcode   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 58.33%

Importance

Changes 0
Metric Value
eloc 12
c 0
b 0
f 0
dl 0
loc 26
ccs 7
cts 12
cp 0.5833
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A normalizeAtts() 0 7 2
A hideOptions() 0 9 1
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Shortcodes;
4
5
class SiteReviewsFormShortcode extends Shortcode
6
{
7 1
    protected function hideOptions()
8
    {
9
        return [
10 1
            'rating' => __('Hide the rating field', 'site-reviews'),
11 1
            'title' => __('Hide the title field', 'site-reviews'),
12 1
            'content' => __('Hide the review field', 'site-reviews'),
13 1
            'name' => __('Hide the name field', 'site-reviews'),
14 1
            'email' => __('Hide the email field', 'site-reviews'),
15 1
            'terms' => __('Hide the terms field', 'site-reviews'),
16
        ];
17
    }
18
19
    /**
20
     * @param array|string $atts
21
     * @param string $type
22
     * @return array
23
     */
24
    public function normalizeAtts($atts, $type = 'shortcode')
25
    {
26
        $atts = parent::normalizeAtts($atts, $type);
27
        if (empty($atts['id'])) {
28
            $atts['id'] = substr(md5(serialize($atts)), 0, 8);
29
        }
30
        return $atts;
31
    }
32
}
33