Cell   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 71.43%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 31
ccs 5
cts 7
cp 0.7143
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A getGroup() 0 4 1
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