TableWrapperBox   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 109
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 11
eloc 29
c 0
b 0
f 0
dl 0
loc 109
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A appendTableBox() 0 14 1
A appendBlockBox() 0 2 1
A appendInlineBlockBox() 0 2 1
A appendInlineBox() 0 2 1
A measureHeight() 0 18 4
A measureWidth() 0 7 2
A appendTableWrapperBox() 0 2 1
1
<?php
2
3
declare(strict_types=1);
4
/**
5
 * TableWrapperBox class.
6
 *
7
 * @package   YetiForcePDF\Layout
8
 *
9
 * @copyright YetiForce Sp. z o.o
10
 * @license   MIT
11
 * @author    Rafal Pospiech <[email protected]>
12
 */
13
14
namespace YetiForcePDF\Layout;
15
16
use YetiForcePDF\Html\Element;
17
use YetiForcePDF\Math;
18
use YetiForcePDF\Style\Style;
19
20
/**
21
 * Class TableWrapperBox.
22
 */
23
class TableWrapperBox extends BlockBox
24
{
25
	/**
26
	 * We shouldn't append block box here.
27
	 *
28
	 * @param mixed $childDomElement
29
	 * @param mixed $element
30
	 * @param mixed $style
31
	 * @param mixed $parentBlock
32
	 */
33
	public function appendBlockBox($childDomElement, $element, $style, $parentBlock)
34
	{
35
	}
36
37
	/**
38
	 * We shouldn't append table wrapper here.
39
	 *
40
	 * @param mixed $childDomElement
41
	 * @param mixed $element
42
	 * @param mixed $style
43
	 * @param mixed $parentBlock
44
	 */
45
	public function appendTableWrapperBox($childDomElement, $element, $style, $parentBlock)
46
	{
47
	}
48
49
	/**
50
	 * We shouldn't append inline block box here.
51
	 *
52
	 * @param mixed $childDomElement
53
	 * @param mixed $element
54
	 * @param mixed $style
55
	 * @param mixed $parentBlock
56
	 */
57
	public function appendInlineBlockBox($childDomElement, $element, $style, $parentBlock)
58
	{
59
	}
60
61
	/**
62
	 * We shouldn't append inline box here.
63
	 *
64
	 * @param mixed $childDomElement
65
	 * @param mixed $element
66
	 * @param mixed $style
67
	 * @param mixed $parentBlock
68
	 */
69
	public function appendInlineBox($childDomElement, $element, $style, $parentBlock)
70
	{
71
	}
72
73
	/**
74
	 * Append table box element.
75
	 *
76
	 * @param \DOMNode                      $childDomElement
77
	 * @param Element                       $element
78
	 * @param Style                         $style
79
	 * @param \YetiForcePDF\Layout\BlockBox $parentBlock
80
	 *
81
	 * @return $this
82
	 */
83
	public function appendTableBox($childDomElement, $element, $style, $parentBlock)
0 ignored issues
show
Unused Code introduced by
The parameter $style is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

83
	public function appendTableBox($childDomElement, $element, /** @scrutinizer ignore-unused */ $style, $parentBlock)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $parentBlock is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

83
	public function appendTableBox($childDomElement, $element, $style, /** @scrutinizer ignore-unused */ $parentBlock)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $element is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

83
	public function appendTableBox($childDomElement, /** @scrutinizer ignore-unused */ $element, $style, $parentBlock)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $childDomElement is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

83
	public function appendTableBox(/** @scrutinizer ignore-unused */ $childDomElement, $element, $style, $parentBlock)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
84
	{
85
		$cleanStyle = (new \YetiForcePDF\Style\Style())->setDocument($this->document);
86
		$box = (new TableBox())
87
			->setDocument($this->document)
88
			->setParent($this)
89
			//->setElement($element)
90
			->setStyle($cleanStyle)
91
			->init();
92
		$cleanStyle->setRule('display', 'block');
93
		$this->appendChild($box);
94
		$box->getStyle()->init()->setRule('display', 'block');
95
		$box->buildTree($box);
96
		return $box;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $box returns the type YetiForcePDF\Layout\TableBox which is incompatible with the documented return type YetiForcePDF\Layout\TableWrapperBox.
Loading history...
97
	}
98
99
	/**
100
	 * {@inheritdoc}
101
	 */
102
	public function measureWidth(bool $afterPageDividing = false)
103
	{
104
		$this->applyStyleWidth();
105
		foreach ($this->getChildren() as $child) {
106
			$child->measureWidth($afterPageDividing);
0 ignored issues
show
Bug introduced by
The method measureWidth() does not exist on YetiForcePDF\Layout\Box. It seems like you code against a sub-type of said class. However, the method does not exist in YetiForcePDF\Layout\ElementBox. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

106
			$child->/** @scrutinizer ignore-call */ 
107
           measureWidth($afterPageDividing);
Loading history...
107
		}
108
		return $this;
109
	}
110
111
	/**
112
	 * {@inheritdoc}
113
	 */
114
	public function measureHeight(bool $afterPageDividing = false)
115
	{
116
		if ($this->wasCut()) {
117
			return $this;
118
		}
119
		$maxHeight = '0';
120
		foreach ($this->getChildren() as $child) {
121
			$child->measureHeight($afterPageDividing);
0 ignored issues
show
Bug introduced by
The method measureHeight() does not exist on YetiForcePDF\Layout\Box. It seems like you code against a sub-type of said class. However, the method does not exist in YetiForcePDF\Layout\ElementBox. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

121
			$child->/** @scrutinizer ignore-call */ 
122
           measureHeight($afterPageDividing);
Loading history...
122
		}
123
		foreach ($this->getChildren() as $child) {
124
			$child->measureHeight($afterPageDividing);
125
			$maxHeight = Math::max($maxHeight, $child->getDimensions()->getHeight());
0 ignored issues
show
Bug introduced by
It seems like $child->getDimensions()->getHeight() can also be of type null; however, parameter $numbers of YetiForcePDF\Math::max() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

125
			$maxHeight = Math::max($maxHeight, /** @scrutinizer ignore-type */ $child->getDimensions()->getHeight());
Loading history...
126
		}
127
		$style = $this->getStyle();
128
		$maxHeight = Math::add($maxHeight, $style->getVerticalBordersWidth(), $style->getVerticalPaddingsWidth());
129
		$this->getDimensions()->setHeight($maxHeight);
130
		$this->applyStyleWidth();
131
		return $this;
132
	}
133
}
134