MaterializeTemplate   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 9
dl 0
loc 22
ccs 6
cts 6
cp 1
rs 10
c 1
b 0
f 1
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A wrapMessages() 0 8 5
1
<?php
2
3
namespace Tamtamchik\SimpleFlash\Templates;
4
5
use Tamtamchik\SimpleFlash\BaseTemplate;
6
use Tamtamchik\SimpleFlash\TemplateInterface;
7
8
/**
9
 * Class MaterializeTemplate.
10
 * Uses default Materialize markdown for flash messages.
11
 */
12
class MaterializeTemplate extends BaseTemplate implements TemplateInterface
13
{
14
    protected $prefix = '<div>';
15
    protected $postfix = '</div>';
16
    protected $wrapper = '<div class="card-panel %s lighten-4 %s-text text-darken-4">%s</div>';
17
18
    /**
19
     * Override base function to suite Bootstrap 3 alert naming.
20
     *
21
     * @param string $messages - message text
22
     * @param string $type - message type: success, info, warning, error
23
     *
24
     * @return string
25
     */
26 3
    public function wrapMessages(string $messages, string $type): string
27
    {
28 3
        $type = ($type == 'success') ? 'green' : $type;
29 3
        $type = ($type == 'info') ? 'blue' : $type;
30 3
        $type = ($type == 'warning') ? 'yellow' : $type;
31 3
        $type = ($type == 'error') ? 'red' : $type;
32
33 3
        return sprintf($this->getWrapper(), $type, $type, $messages);
34
    }
35
}
36