Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
5 / 5
CRAP
100.00% covered (success)
100.00%
1 / 1
AbstractColoredBlockquote
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
5 / 5
6
100.00% covered (success)
100.00%
1 / 1
 signature
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 resolve
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 expand
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 getClassNameFromSignature
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 get
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace Hyde\Framework\Services\Markdown\Shortcodes;
4
5use Hyde\Framework\Contracts\MarkdownShortcodeContract;
6
7/**
8 * @see \Tests\Feature\ColoredBlockquoteShortcodesTest
9 */
10abstract class AbstractColoredBlockquote implements MarkdownShortcodeContract
11{
12    protected static string $signature = '>color';
13
14    public static function signature(): string
15    {
16        return static::$signature;
17    }
18
19    public static function resolve(string $input): string
20    {
21        return str_starts_with($input, static::signature())
22            ? static::expand($input)
23            : $input;
24    }
25
26    protected static function expand(string $input): string
27    {
28        return sprintf('<blockquote class="%s">%s</blockquote>',
29            static::getClassNameFromSignature(static::signature()),
30            trim(substr($input, strlen(static::signature())), ' ')
31        );
32    }
33
34    protected static function getClassNameFromSignature(string $signature): string
35    {
36        return str_replace('>', '', $signature);
37    }
38
39    public static function get(): array
40    {
41        return [
42            new class extends AbstractColoredBlockquote
43            {
44                protected static string $signature = '>danger';
45            },
46            new class extends AbstractColoredBlockquote
47            {
48                protected static string $signature = '>info';
49            },
50            new class extends AbstractColoredBlockquote
51            {
52                protected static string $signature = '>success';
53            },
54            new class extends AbstractColoredBlockquote
55            {
56                protected static string $signature = '>warning';
57            },
58        ];
59    }
60}