Cell::getGroup()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Foo\Grid\Cell;
6
7
use Foo\Grid\Component\Component;
8
use Foo\Grid\Component\IComponent;
9
10
class Cell extends Component implements ICell
11
{
12
    const HEAD = 'th';
13
    const BODY = 'td';
14
15
    /** @var string */
16
    protected $group = '';
17
18
    /**
19
     * @param string|IComponent $content
20
     * @param string            $group
21
     * @param array             $attributes
22
     * @param string            $tag
23
     */
24 8
    public function __construct(string $content, string $group, array $attributes = [], string $tag = self::BODY)
25
    {
26 8
        $this->group = $group;
27
28 8
        parent::__construct($content, $tag, $attributes);
0 ignored issues
show
Bug introduced by
It seems like $content defined by parameter $content on line 24 can also be of type object<Foo\Grid\Component\IComponent>; however, Foo\Grid\Component\Component::__construct() does only seem to accept string, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
29
30 8
        $this->appendToAttribute(Component::ATTRIBUTE_CLASS, $tag . '-' . $group);
31 8
    }
32
33
    /**
34
     * @return string
35
     */
36
    public function getGroup(): string
37
    {
38
        return $this->group;
39
    }
40
}
41