Completed
Push — master ( 5b5792...2b84bd )
by Schlaefer
03:33 queued 11s
created

Html5Media::_video()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 19
rs 9.6333
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A Html5Video::_parse() 9 10 3
1
<?php
2
3
namespace Plugin\BbcodeParser\src\Lib\jBBCode\Definitions;
4
5
use Plugin\BbcodeParser\src\Lib\Helper\UrlParserTrait;
6
use Plugin\BbcodeParser\src\Lib\jBBCode\Definitions\CodeDefinition;
7
8
//@codingStandardsIgnoreStart
9 View Code Duplication
class Html5Audio extends CodeDefinition
0 ignored issues
show
Duplication introduced by
This class 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...
10
//@codingStandardsIgnoreEnd
11
{
12
    use UrlParserTrait;
13
14
    protected $_sTagName = 'audio';
15
16
    protected $_sParseContent = false;
17
18
    /**
19
     * {@inheritDoc}
20
     */
21
    protected function _parse($content, $attributes, \JBBCode\ElementNode $node)
22
    {
23
        if (!empty($attributes['src']) && $attributes['src'] === 'upload') {
24
            $content = $this->_linkToUploadedFile($content);
25
        }
26
27
        // Better: preload='metadata'. But Safari 12 doesn't support it.
28
        return "<audio src='$content' controls='controls' preload='auto' x-webkit-airplay='allow'></audio>";
29
    }
30
}
31
32
//@codingStandardsIgnoreStart
33
class Html5AudioWithAttributes extends Html5Audio
34
//@codingStandardsIgnoreEnd
35
{
36
    protected $_sUseOptions = true;
37
}
38
39
//@codingStandardsIgnoreStart
40 View Code Duplication
class Html5Video extends CodeDefinition
0 ignored issues
show
Duplication introduced by
This class 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...
41
//@codingStandardsIgnoreEnd
42
{
43
    use UrlParserTrait;
44
45
    protected $_sTagName = 'video';
46
47
    protected $_sParseContent = false;
48
49
    /**
50
     * {@inheritDoc}
51
     */
52
    protected function _parse($content, $attributes, \JBBCode\ElementNode $node)
53
    {
54
        if (!empty($attributes['src']) && $attributes['src'] === 'upload') {
55
            $content = $this->_linkToUploadedFile($content);
56
        }
57
58
        // Better: preload='metadata'. But Safari 12 doesn't support it and
59
        // only shows a blank preview.
60
        return "<video src='$content' controls='controls' preload='auto' x-webkit-airplay='allow'></video>";
61
    }
62
}
63
64
//@codingStandardsIgnoreStart
65
class Html5VideoWithAttributes extends Html5Video
66
//@codingStandardsIgnoreEnd
67
{
68
    protected $_sUseOptions = true;
69
}
70