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

SiteReviewsBlock::blockClassAttr()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 7
rs 10
cc 3
nc 2
nop 1
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\Gutenberg\Blocks;
4
5
use GeminiLabs\SiteReviews\Contracts\ShortcodeContract;
6
use GeminiLabs\SiteReviews\Shortcodes\SiteReviewsShortcode;
7
8
class SiteReviewsBlock extends Block
9
{
10
    public function shortcode(): ShortcodeContract
11
    {
12
        return glsr(SiteReviewsShortcode::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-review-star-bg: var(--wp--preset--color--{$attributes['styleRatingColor']});";
29
        } elseif (!empty($attributes['styleRatingColorCustom'])) {
30
            $attr[] = "--glsr-review-star-bg: {$attributes['styleRatingColorCustom']};";
31
        }
32
        if (!empty($attributes['styleStarSize'])) {
33
            $attr[] = "--glsr-review-star: {$attributes['styleStarSize']};";
34
        }
35
        return implode('', $attr);
36
    }
37
}
38