FoundationTemplate::wrapMessages()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
eloc 3
nc 4
nop 2
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 3
rs 10
c 1
b 0
f 1
1
<?php
2
3
namespace Tamtamchik\SimpleFlash\Templates;
4
5
use Tamtamchik\SimpleFlash\BaseTemplate;
6
use Tamtamchik\SimpleFlash\TemplateInterface;
7
8
/**
9
 * Class FoundationTemplate.
10
 * Uses Foundation markdown for flash messages.
11
 */
12
class FoundationTemplate extends BaseTemplate implements TemplateInterface
13
{
14
    protected $prefix = '<p>';
15
    protected $postfix = '</p>';
16
    protected $wrapper = '<div class="callout %s">%s</div>';
17
18
    /**
19
     * Override base function to suite Foundation 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 7
    public function wrapMessages(string $messages, string $type): string
27
    {
28 7
        $type = ($type == 'info') ? 'primary' : $type;
29 7
        $type = ($type == 'error') ? 'alert' : $type;
30
31 7
        return sprintf($this->getWrapper(), $type, $messages);
32
    }
33
}
34