Image   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 0
dl 0
loc 59
ccs 13
cts 13
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A setImageUrl() 0 4 1
A setAlternativeText() 0 4 1
A render() 0 6 1
1
<?php
2
namespace Nkey\Caribu\Mvc\View\Controls;
3
4
use Nkey\Caribu\Mvc\View\Control;
5
use Nkey\Caribu\Mvc\Controller\Request;
6
7
/**
8
 * Image control
9
 *
10
 * @author Maik Greubel <[email protected]>
11
 *         This file is part of Caribu MVC package
12
 */
13
class Image implements Control
14
{
15
    /**
16
     * The url to the image
17
     *
18
     * @var string
19
     */
20
    private $imageUrl;
21
22
    /**
23
     * The alternative text if image can not be found
24
     *
25
     * @var string
26
     */
27
    private $alternateText;
28
29
    /**
30
     * Create a new image control
31
     *
32
     * @param string $imageUrl The url to the image
33
     */
34 1
    public function __construct($imageUrl = '', $alternativeText = '')
35
    {
36 1
        $this->setImageUrl($imageUrl);
37 1
        $this->setAlternativeText($alternativeText);
38 1
    }
39
40
    /**
41
     * Set the image url
42
     *
43
     * @param string $imageUrl The url to set
44
     */
45 1
    public function setImageUrl($imageUrl)
46
    {
47 1
        $this->imageUrl = $imageUrl;
48 1
    }
49
50
    /**
51
     * Set the alternative text
52
     *
53
     * @param string $text The text to set
54
     */
55 1
    public function setAlternativeText($text)
56
    {
57 1
        $this->alternateText = $text;
58 1
    }
59
60
    /**
61
     * (non-PHPdoc)
62
     *
63
     * @see \Nkey\Caribu\Mvc\View\Control::render()
64
     */
65 1
    public function render(Request $request, $parameters = array())
66
    {
67 1
        $rendered = sprintf('<img src="%s" alt="%s"/>', $this->imageUrl, $this->alternateText);
68
69 1
        return $rendered;
70
    }
71
}
72