Passed
Push — master ( 2afdeb...b846a2 )
by Nikolaos
06:23 queued 03:51
created

Base   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 27
ccs 7
cts 7
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 16 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
/**
17
 * Class Base
18
 */
19
class Base extends AbstractHelper
20
{
21
    /**
22
     * Produce a `<base/>` tag.
23
     *
24
     * @param string $href
25
     * @param array  $attributes
26
     *
27
     * @return string
28
     * @throws Exception
29
     */
30 1
    public function __invoke(string $href, array $attributes = [])
31
    {
32 1
        if (!empty($href)) {
33 1
            $overrides = ["href" => $href];
34
        } else {
35 1
            $overrides = [];
36
        }
37
38
        /**
39
         * Avoid duplicate "href" and ignore it if it is passed in the attributes
40
         */
41 1
        unset($attributes["href"]);
42
43 1
        $overrides = array_merge($overrides, $attributes);
44
45 1
        return $this->renderElement("base", $overrides);
46
    }
47
}
48