Passed
Push — master ( 5cf75b...52ecf5 )
by Nikolaos
04:27 queued 01:52
created

Img::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 12
ccs 0
cts 6
cp 0
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
/**
4
 * This file is part of the Phalcon Framework.
5
 *
6
 * For the full copyright and license information, please view the LICENSE.md
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace Phalcon\Html\Helper;
13
14
use Phalcon\Html\Exception;
15
16
use function array_merge;
17
18
/**
19
 * Class Img
20
 */
21
class Img extends AbstractHelper
22
{
23
    /**
24
     * Produce a <img> tag.
25
     *
26
     * @param string $src
27
     * @param array  $attributes
28
     *
29
     * @return string
30
     * @throws Exception
31
     */
32
    public function __invoke(string $src, array $attributes = [])
33
    {
34
        $overrides = ["src" => $src];
35
36
        /**
37
         * Avoid duplicate "src" and ignore it if it is passed in the attributes
38
         */
39
        unset($attributes["src"]);
40
41
        $overrides = array_merge($overrides, $attributes);
42
43
        return $this->selfClose("img", $overrides);
44
    }
45
}
46