Cell::getWidthByContent()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 7
nc 3
nop 1
dl 0
loc 12
ccs 8
cts 8
cp 1
crap 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace VPA\Console\Glyphs;
4
5
class Cell extends GlyphBlock
6
{
7 9
    public function getWidthByContent(int $endOfPreviousSibling = 0): int
8
    {
9 9
        $this->offsetX = $this->__get('paddingLeft') + $this->__get('borderLeft');
10 9
        if ($this->renderedWidth) {
11 8
            return $this->width;
12
        }
13
14 9
        foreach ($this->children as $child) {
15 9
            $this->width = $child->getWidthByContent(0);
16
        }
17 9
        parent::appendWidth($this->width);
18 9
        return $this->width;
19
    }
20
21 10
    public function getHeightByContent(int $endOfPreviousSibling = 0): int
22
    {
23 10
        $deltaTop = $this->__get('paddingTop') + $this->__get('borderTop');
24 10
        $this->offsetY = $deltaTop;
25 10
        if ($this->renderedHeight) {
26 8
            return $this->height;
27
        }
28 10
        foreach ($this->children as $child) {
29 10
            $this->height = $child->getHeightByContent(0);
30
        }
31 10
        parent::appendHeight($this->height);
32 10
        return $this->height;
33
    }
34
}
35