Html5TagTrait::canvas()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
1
<?php /** MicroHtml5TagTrait */
2
3
namespace Micro\Web\Html;
4
5
6
/**
7
 * Html5TagTrait trait file.
8
 *
9
 * @author Oleg Lunegov <[email protected]>
10
 * @link https://github.com/linpax/microphp-framework
11
 * @copyright Copyright (c) 2013 Oleg Lunegov
12
 * @license https://github.com/linpax/microphp-framework/blob/master/LICENSE
13
 * @package Micro
14
 * @subpackage Web\Html
15
 * @version 1.0
16
 * @since 1.0
17
 */
18
trait Html5TagTrait
19
{
20
    use TagTrait;
21
22
23
    /**
24
     * Render charset tag
25
     *
26
     * @access public
27
     *
28
     * @param  string $name charset name
29
     *
30
     * @return string
31
     * @static
32
     */
33
    public static function charset($name)
34
    {
35
        return static::tag('meta', ['charset' => $name]);
36
    }
37
38
    /**
39
     * Render video tag
40
     *
41
     * @access public
42
     *
43
     * @param array $sources format type=>src
44
     * @param array $videos format array(kind, src, srclang, label)
45
     * @param array $attributes attributes tag
46
     * @param string $noCodec text
47
     *
48
     * @return string
49
     * @static
50
     */
51 View Code Duplication
    public static function video(array $sources = [], array $videos = [], array $attributes = [], $noCodec = '')
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
52
    {
53
        $srcs = '';
54
55
        foreach ($sources AS $name => $value) {
56
            $srcs .= static::tag('source', ['type' => $name, 'src' => $value]);
57
        }
58
59
        foreach ($videos AS $video) {
60
            $srcs .= static::tag('track', [
61
                'kind' => $video['kind'],
62
                'src' => $video['src'],
63
                'srclang' => $video['srclang'],
64
                'label' => $video['label']
65
            ]);
66
        }
67
68
        return static::openTag('video', $attributes).$srcs.$noCodec.static::closeTag('video');
69
    }
70
71
    /**
72
     * Render audio tag
73
     *
74
     * @access public
75
     *
76
     * @param array $sources format type=>src
77
     * @param array $tracks format array(kind, src, srclang, label)
78
     * @param array $attributes attributes tag
79
     * @param string $noCodec text
80
     *
81
     * @return string
82
     * @static
83
     */
84 View Code Duplication
    public static function audio(array $sources = [], array $tracks = [], array $attributes = [], $noCodec = '')
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
85
    {
86
        $srcs = '';
87
88
        foreach ($sources AS $name => $value) {
89
            $srcs .= static::tag('audio', ['type' => $name, 'src' => $value]);
90
        }
91
92
        foreach ($tracks AS $track) {
93
            $srcs .= static::tag('track', [
94
                'kind' => $track['kind'],
95
                'src' => $track['src'],
96
                'srclang' => $track['srclang'],
97
                'label' => $track['label']
98
            ]);
99
        }
100
101
        return static::openTag('audio', $attributes).$srcs.$noCodec.static::closeTag('audio');
102
    }
103
104
    /**
105
     * Render canvas tag
106
     *
107
     * @access public
108
     *
109
     * @param array $attributes attributes tag
110
     * @param string $noCodec text
111
     *
112
     * @return string
113
     * @static
114
     */
115
    public static function canvas(array $attributes = [], $noCodec = '')
116
    {
117
        return static::openTag('canvas', $attributes).$noCodec.static::closeTag('canvas');
118
    }
119
}
120