Passed
Push — develop ( 7fa65f...4875bb )
by Paul
13:31
created

SiteReviewBlock::blockStyleAttr()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 12
rs 10
cc 4
nc 6
nop 1
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\Gutenberg\Blocks;
4
5
use GeminiLabs\SiteReviews\Shortcodes\SiteReviewShortcode;
6
7
class SiteReviewBlock extends Block
8
{
9
    public function render(array $attributes): string
10
    {
11
        if ('edit' === filter_input(INPUT_GET, 'context')) {
12
            if (empty(wp_count_posts(glsr()->post_type)->publish)) {
13
                return $this->buildEmptyBlock(
14
                    _x('No reviews found.', 'admin-text', 'site-reviews')
15
                );
16
            }
17
        }
18
        return parent::render($attributes);
19
    }
20
21
    public static function shortcodeClass(): string
22
    {
23
        return SiteReviewShortcode::class;
24
    }
25
26
    protected function blockClasses(array $attributes): array
27
    {
28
        $classes = [];
29
        if (!empty($attributes['styleAlign'])) {
30
            $classes[] = "items-justified-{$attributes['styleAlign']}";
31
        }
32
        return $classes;
33
    }
34
}
35