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

TableCaption::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
rs 9.4285
cc 1
eloc 5
nc 1
nop 2
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