Html::asLink()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Benrowe\Formatter\Providers;
4
5
use Benrowe\Formatter\AbstractFormatterProvider;
6
7
/**
8
 * Provides formatters that produce specific html based output
9
 *
10
 * @package Benrowe\Formatter
11
 */
12
class Html extends AbstractFormatterProvider
13
{
14
    /**
15
     * Format the value as a html link
16
     *
17
     * @param  string $value link
18
     * @return string
19
     */
20 2
    public function asLink($value)
21
    {
22 2
        if ($value === null) {
23 1
            return $this->nullValue;
24
        }
25 1
        return '<a href="'.$value.'">'.$value.'</a>';
26
    }
27
28
    /**
29
     * Format the value as a html image
30
     *
31
     * @param  string $value image url
32
     * @return string
33
     */
34 2
    public function asImage($value)
35
    {
36 2
        if ($value === null) {
37 1
            return $this->nullValue;
38
        }
39
40 1
        return '<img src="'.$value.'">';
41
    }
42
}
43