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

SiteReviewsFormBlock::blockStyleAttr()   A

Complexity

Conditions 6
Paths 24

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 12
c 2
b 0
f 1
dl 0
loc 18
rs 9.2222
cc 6
nc 24
nop 1
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