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

SiteReviewsSummaryBlock::shortcodeClass()   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\SiteReviewsSummaryShortcode;
6
7
class SiteReviewsSummaryBlock extends Block
8
{
9
    public static function shortcodeClass(): string
10
    {
11
        return SiteReviewsSummaryShortcode::class;
12
    }
13
14
    protected function blockClassAttr(array $attributes): string
15
    {
16
        $attr = [];
17
        if (!empty($attributes['styleAlign'])) {
18
            $attr[] = "items-justified-{$attributes['styleAlign']}";
19
        }
20
        if (!empty($attributes['styleRatingColor']) || !empty($attributes['styleRatingColorCustom'])) {
21
            $attr[] = 'has-custom-color';
22
        }
23
        return implode(' ', $attr);
24
    }
25
26
    protected function blockStyleAttr(array $attributes): string
27
    {
28
        $attr = [];
29
        if (!empty($attributes['styleRatingColor'])) {
30
            $attr[] = "--glsr-bar-bg: var(--wp--preset--color--{$attributes['styleRatingColor']});";
31
            $attr[] = '--glsr-summary-star-bg: var(--glsr-bar-bg);';
32
        } elseif (!empty($attributes['styleRatingColorCustom'])) {
33
            $attr[] = "--glsr-bar-bg: {$attributes['styleRatingColorCustom']};";
34
            $attr[] = '--glsr-summary-star-bg: var(--glsr-bar-bg);';
35
        }
36
        if (!empty($attributes['styleBarSize'])) {
37
            $attr[] = "--glsr-bar-size: {$attributes['styleBarSize']};";
38
        }
39
        if (!empty($attributes['styleBarSpacing'])) {
40
            $attr[] = "--glsr-bar-spacing: {$attributes['styleBarSpacing']};";
41
        }
42
        if (!empty($attributes['styleStarSize'])) {
43
            $attr[] = "--glsr-summary-star: {$attributes['styleStarSize']};";
44
        }
45
        if (!empty($attributes['styleMaxWidth'])) {
46
            $attr[] = "--glsr-max-w: {$attributes['styleMaxWidth']};";
47
        } else {
48
            $attr[] = "--glsr-max-w: none";
49
        }
50
        return implode('', $attr);
51
    }
52
}
53