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

SiteReviewsBlock   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 9
eloc 16
c 0
b 0
f 0
dl 0
loc 31
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A shortcodeClass() 0 3 1
A blockStyleAttr() 0 15 5
A blockClassAttr() 0 7 3
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\Gutenberg\Blocks;
4
5
use GeminiLabs\SiteReviews\Shortcodes\SiteReviewsShortcode;
6
7
class SiteReviewsBlock extends Block
8
{
9
    public static function shortcodeClass(): string
10
    {
11
        return SiteReviewsShortcode::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-review-star-bg: var(--wp--preset--color--{$attributes['styleRatingColor']});";
28
        } elseif (!empty($attributes['styleRatingColorCustom'])) {
29
            $attr[] = "--glsr-review-star-bg: {$attributes['styleRatingColorCustom']};";
30
        }
31
        if (!empty($attributes['styleStarSize'])) {
32
            $attr[] = "--glsr-review-star: {$attributes['styleStarSize']};";
33
        }
34
        if (!empty($attributes['styleReviewSpacing']['top'])) {
35
            $attr[] = "--glsr-review-row-gap: {$attributes['styleReviewSpacing']['top']};";
36
        }
37
        return implode('', $attr);
38
    }
39
}
40