Completed
Push — master ( 6b1205...73a107 )
by Vitaliy
03:00
created

TableCaption   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 1
cbo 3
dl 0
loc 40
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A attachToCompound() 0 4 1
A getText() 0 4 1
A setText() 0 4 1
1
<?php
2
3
namespace ViewComponents\Grids\Component;
4
5
use ViewComponents\Grids\Grid;
6
use ViewComponents\ViewComponents\Base\Compound\PartInterface;
7
use ViewComponents\ViewComponents\Base\Compound\PartTrait;
8
use ViewComponents\ViewComponents\Component\Compound;
9
use ViewComponents\ViewComponents\Component\DataView;
10
use ViewComponents\ViewComponents\Component\Html\Tag;
11
12
class TableCaption extends Tag implements PartInterface
13
{
14
    use PartTrait {
15
        PartTrait::attachToCompound as private attachToCompoundInternal;
16
    }
17
18
    const ID = 'caption';
19
20
    /** @var DataView  */
21
    private $text;
22
23
    public function __construct($text, $attributes = [])
24
    {
25
        parent::__construct('caption', $attributes);
26
        $this->setDestinationParentId(Grid::TABLE_ID);
27
        $this->setId(static::ID);
28
        $this->addChild($this->text = new DataView($text));
29
    }
30
31
    public function attachToCompound(Compound $root, $prepend = true)
32
    {
33
        $this->attachToCompoundInternal($root, $prepend);
0 ignored issues
show
Unused Code introduced by
The call to TableCaption::attachToCompoundInternal() has too many arguments starting with $prepend.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
34
    }
35
36
    /**
37
     * @return string
38
     */
39
    public function getText()
40
    {
41
        return $this->text;
42
    }
43
44
    /**
45
     * @param string $text
46
     */
47
    public function setText($text)
48
    {
49
        $this->text->setData($text);
50
    }
51
}
52