Test Failed
Push — develop ( 006c9f...4b441a )
by Paul
13:29
created

SiteReviewsFormBlock::shortcode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\Gutenberg\Blocks;
4
5
use GeminiLabs\SiteReviews\Shortcodes\SiteReviewsFormShortcode;
6
7
class SiteReviewsFormBlock extends Block
8
{
9
    public static function shortcodeClass(): string
10
    {
11
        return SiteReviewsFormShortcode::class;
12
    }
13
14
    protected function blockClassAttr(array $attributes): string
15
    {
16
        $attr = [];
17
        if (!empty($attributes['styleRatingColor']) || !empty($attributes['styleRatingColorCustom'])) {
18
            $attr[] = 'has-custom-color';
19
        }
20
        return implode(' ', $attr);
21
    }
22
23
    protected function blockStyleAttr(array $attributes): string
24
    {
25
        $attr = [];
26
        if (!empty($attributes['styleRatingColor'])) {
27
            $attr[] = "--glsr-form-star-bg: var(--wp--preset--color--{$attributes['styleRatingColor']});";
28
        } elseif (!empty($attributes['styleRatingColorCustom'])) {
29
            $attr[] = "--glsr-form-star-bg: {$attributes['styleRatingColorCustom']};";
30
        }
31
        if (!empty($attributes['styleStarSize'])) {
32
            $attr[] = "--glsr-form-star: {$attributes['styleStarSize']};";
33
        }
34
        if (!empty($attributes['styleFieldSpacing']['left'])) {
35
            $attr[] = "--glsr-form-col-gap: {$attributes['styleFieldSpacing']['left']};";
36
        }
37
        if (!empty($attributes['styleFieldSpacing']['top'])) {
38
            $attr[] = "--glsr-form-row-gap: {$attributes['styleFieldSpacing']['top']};";
39
        }
40
        return implode('', $attr);
41
    }
42
}
43