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

SiteReviewsFormBlock::blockStyleAttr()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 12
rs 10
cc 4
nc 6
nop 1
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