Test Failed
Push — develop ( 8a2d95...1ddb5f )
by Paul
11:12
created

SiteReviewsFormBlock   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 8
eloc 14
c 0
b 0
f 0
dl 0
loc 28
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A shortcode() 0 3 1
A blockClassAttr() 0 7 3
A blockStyleAttr() 0 12 4
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\Gutenberg\Blocks;
4
5
use GeminiLabs\SiteReviews\Contracts\ShortcodeContract;
6
use GeminiLabs\SiteReviews\Shortcodes\SiteReviewsFormShortcode;
7
8
class SiteReviewsFormBlock extends Block
9
{
10
    public function shortcode(): ShortcodeContract
11
    {
12
        return glsr(SiteReviewsFormShortcode::class);
13
    }
14
15
    protected function blockClassAttr(array $attributes): string
16
    {
17
        $attr = [];
18
        if (!empty($attributes['styleRatingColor']) || !empty($attributes['styleRatingColorCustom'])) {
19
            $attr[] = 'has-custom-rating-color';
20
        }
21
        return implode(' ', $attr);
22
    }
23
24
    protected function blockStyleAttr(array $attributes): string
25
    {
26
        $attr = [];
27
        if (!empty($attributes['styleRatingColor'])) {
28
            $attr[] = "--glsr-form-star-bg: var(--wp--preset--color--{$attributes['styleRatingColor']});";
29
        } elseif (!empty($attributes['styleRatingColorCustom'])) {
30
            $attr[] = "--glsr-form-star-bg: {$attributes['styleRatingColorCustom']};";
31
        }
32
        if (!empty($attributes['styleStarSize'])) {
33
            $attr[] = "--glsr-form-star: {$attributes['styleStarSize']};";
34
        }
35
        return implode('', $attr);
36
    }
37
}
38