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

Meta   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 90
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 90
ccs 21
cts 21
cp 1
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A addProperty() 0 5 1
A getTag() 0 3 1
A add() 0 12 1
A addName() 0 5 1
A addElement() 0 11 1
A addHttp() 0 3 1
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 Meta
18
 */
19
class Meta extends AbstractSeries
20
{
21
    /**
22
     * Add an element to the list
23
     *
24
     * @param array $attributes
25
     *
26
     * @return Meta
27
     */
28 1
    public function add(array $attributes = []): Meta
29
    {
30 1
        $this->store[] = [
31 1
            "renderTag",
32
            [
33 1
                $this->getTag(),
34 1
                $attributes,
35
            ],
36 1
            $this->indent(),
37
        ];
38
39 1
        return $this;
40
    }
41
42
    /**
43
     * @param string $httpEquiv
44
     * @param string $content
45
     *
46
     * @return Meta
47
     * @throws Exception
48
     */
49 1
    public function addHttp(string $httpEquiv, string $content): Meta
50
    {
51 1
        return $this->addElement('http-equiv', $httpEquiv, $content);
52
    }
53
54
    /**
55
     * @param string $name
56
     * @param string $content
57
     *
58
     * @return Meta
59
     * @throws Exception
60
     */
61 1
    public function addName(string $name, string $content): Meta
62
    {
63 1
        $this->addElement('name', $name, $content);
64
65 1
        return $this;
66
    }
67
68
    /**
69
     * @param string $name
70
     * @param string $content
71
     *
72
     * @return Meta
73
     * @throws Exception
74
     */
75 1
    public function addProperty(string $name, string $content): Meta
76
    {
77 1
        $this->addElement('property', $name, $content);
78
79 1
        return $this;
80
    }
81
82
    /**
83
     * @return string
84
     */
85 1
    protected function getTag(): string
86
    {
87 1
        return 'meta';
88
    }
89
90
    /**
91
     * @param string $element
92
     * @param string $value
93
     * @param string $content
94
     *
95
     * @return Meta
96
     * @throws Exception
97
     */
98 1
    private function addElement(
99
        string $element,
100
        string $value,
101
        string $content
102
    ): Meta {
103
        $attributes = [
104 1
            $element  => $value,
105 1
            'content' => $content,
106
        ];
107
108 1
        return $this->add($attributes);
109
    }
110
}
111