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

Html5Video   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 91.3 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 21
loc 23
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A _parse() 9 10 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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