Function fixTables
has a Cognitive Complexity of 93 (exceeds 5 allowed). Consider refactoring. Open
public function fixTables()
{
$tables = $this->getBoxesByType('TableWrapperBox');
foreach ($tables as $tableWrapperBox) {
$tableBox = $tableWrapperBox->getFirstChild();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function buildTree
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
public function buildTree($parentBlock = null)
{
if ($this->getElement()) {
$domElement = $this->getElement()->getDOMElement();
} else {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method fixTables
has 90 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function fixTables()
{
$tables = $this->getBoxesByType('TableWrapperBox');
foreach ($tables as $tableWrapperBox) {
$tableBox = $tableWrapperBox->getFirstChild();
The class ElementBox has an overall complexity of 59 which is very high. The configured complexity threshold is 50. Open
class ElementBox extends Box
{
/**
* @var Element
*/
- Exclude checks
Method buildTree
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function buildTree($parentBlock = null)
{
if ($this->getElement()) {
$domElement = $this->getElement()->getDOMElement();
} else {
Function getBoxesByTagName
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function getBoxesByTagName(string $tagName)
{
$boxes = [];
$allChildren = [];
$this->getAllChildren($allChildren);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
The method fixTables() has an NPath complexity of 1017. The configured NPath complexity threshold is 200. Open
public function fixTables()
{
$tables = $this->getBoxesByType('TableWrapperBox');
foreach ($tables as $tableWrapperBox) {
$tableBox = $tableWrapperBox->getFirstChild();
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method buildTree() has an NPath complexity of 292. The configured NPath complexity threshold is 200. Open
public function buildTree($parentBlock = null)
{
if ($this->getElement()) {
$domElement = $this->getElement()->getDOMElement();
} else {
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method buildTree() has a Cyclomatic Complexity of 26. The configured cyclomatic complexity threshold is 10. Open
public function buildTree($parentBlock = null)
{
if ($this->getElement()) {
$domElement = $this->getElement()->getDOMElement();
} else {
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method fixTables() has a Cyclomatic Complexity of 21. The configured cyclomatic complexity threshold is 10. Open
public function fixTables()
{
$tables = $this->getBoxesByType('TableWrapperBox');
foreach ($tables as $tableWrapperBox) {
$tableBox = $tableWrapperBox->getFirstChild();
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
Refactor this function to reduce its Cognitive Complexity from 93 to the 15 allowed. Open
public function fixTables()
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Refactor this function to reduce its Cognitive Complexity from 37 to the 15 allowed. Open
public function buildTree($parentBlock = null)
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Missing class import via use statement (line '221', column '19'). Open
$style = (new \YetiForcePDF\Style\Style())
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method fixTables uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$nextRow->appendChild($insertColumn);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method buildTree uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->appendBlockBox($childDomElement, $element, $style, $parentBlock);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method fixTables uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
if (isset($rowSpans[$columnIndex]) && $rowSpans[$columnIndex] > 1) {
if ($rowSpansUp[$columnIndex] < $rowSpans[$columnIndex]) {
++$rowSpansUp[$columnIndex];
$column->setRowSpanUp($rowSpansUp[$columnIndex]);
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method fixTables uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$rowSpansUp[$columnIndex] = 0;
$rowSpans[$columnIndex] = 1;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method fixTables uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$columnsCount = 0;
foreach ($rowGroups as $rowGroup) {
if (!$rowGroup->hasChildren()) {
$row = $rowGroup->createRowBox();
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method buildTree uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
// tablebox doesn't have element so we can get it from table wrapper (parent box)
$domElement = $this->getParent()->getElement()->getDOMElement();
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Define a constant instead of duplicating this literal "style" 4 times. Open
if ($childDomElement->hasAttribute('style')) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Merge this if statement with the enclosing one. Open
if (isset($child->getElement()->getDOMElement()->tagName)) {
- Read upRead up
- Exclude checks
Merging collapsible if
statements increases the code's readability.
Noncompliant Code Example
if (condition1) { if (condition2) { ... } }
Compliant Solution
if (condition1 && condition2) { ... }
Rename "$element" which has the same name as the field declared at line 26. Open
$element = (new Element())
- Read upRead up
- Exclude checks
Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.
Noncompliant Code Example
class Foo { public $myField; public function doSomething() { $myField = 0; ... } }
See
- CERT, DCL51-J. - Do not shadow or obscure identifiers in subscopes
Add a "case default" clause to this "switch" statement. Open
switch ($display) {
- Read upRead up
- Exclude checks
The requirement for a final case default
clause is defensive programming. The clause should either take appropriate action, or contain
a suitable comment as to why no action is taken. Even when the switch
covers all current values of an enum
, a default case
should still be used because there is no guarantee that the enum
won't be extended.
Noncompliant Code Example
switch ($param) { //missing default clause case 0: do_something(); break; case 1: do_something_else(); break; } switch ($param) { default: // default clause should be the last one error(); break; case 0: do_something(); break; case 1: do_something_else(); break; }
Compliant Solution
switch ($param) { case 0: do_something(); break; case 1: do_something_else(); break; default: error(); break; }
See
- MISRA C:2004, 15.0 - The MISRA C switch syntax shall be used.
- MISRA C:2004, 15.3 - The final clause of a switch statement shall be the default clause
- MISRA C++:2008, 6-4-3 - A switch statement shall be a well-formed switch statement.
- MISRA C++:2008, 6-4-6 - The final clause of a switch statement shall be the default-clause
- MISRA C:2012, 16.1 - All switch statements shall be well-formed
- MISRA C:2012, 16.4 - Every switch statement shall have a default label
- MISRA C:2012, 16.5 - A default label shall appear as either the first or the last switch label of a switch statement
- MITRE, CWE-478 - Missing Default Case in Switch Statement
- CERT, MSC01-C. - Strive for logical completeness
- CERT, MSC01-CPP. - Strive for logical completeness
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set element.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get element.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var Element
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param Element $element
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->element;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $element;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$element->setBox($this);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $tagName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$boxes[] = $child;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// fix row spans
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($column->getRowSpan() > 1) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Span all rows.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$boxes = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->getAllChildren($allChildren);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rowGroup = $tableBox->createRowGroupBox();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$columns = $row->getChildren();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$columnsCount = max($columnsCount, \count($columns));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$insertCell = $insertColumn->createCellBox();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tableBox->spanRows();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function buildTree($parentBlock = null)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->getElement()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($rowGroups as $rowGroup) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($rowGroups)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($column->getRowSpan() > 1) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$nextRow = $rowGroup->getChildren()[$rowIndex + $i];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tablesBoxes = $this->getBoxesByType('TableBox');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($elementTagName && strtolower($elementTagName) === strtolower($tagName)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tables = $this->getBoxesByType('TableWrapperBox');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rowChildren = $nextRow->getChildren();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$column = $row->createColumnBox();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
++$rowSpansUp[$columnIndex];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$column->setRowSpanUp($rowSpansUp[$columnIndex]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$domElement = $this->getElement()->getDOMElement();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// tablebox doesn't have element so we can get it from table wrapper (parent box)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setElement(Element $element)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
unset($wrapRowGroup);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$column = $row->createColumnBox();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row = $rowGroup->createRowBox();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$nextRow->appendChild($insertColumn);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$insertColumn->getStyle()->setBox($insertColumn);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($rowGroup->getChildren() as $row) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row->setRowSpanUp(max($row->getRowSpanUp(), 0));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row->setRowSpan(max($row->getRowSpan(), $column->getRowSpan()));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rowSpansUp[$columnIndex] = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$domElement = $this->getParent()->getElement()->getDOMElement();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($allChildren as $child) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($rowGroup instanceof TableRowBox) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset($wrapRowGroup)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$wrapRowGroup->appendChild($tableBox->removeChild($rowGroup));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$insertColumn = $nextRow->removeChild($nextRow->createColumnBox());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$columns = $row->getChildren();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rowSpansUp = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($rowSpansUp[$columnIndex] < $rowSpans[$columnIndex]) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row->setRowSpanUp(max($row->getRowSpanUp(), $rowSpansUp[$columnIndex]));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return Element
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getElement()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param $parentBlock
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($child->getElement()->getDOMElement()->tagName)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$column->createCellBox();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($rowGroups as $rowGroup) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rowSpans = $column->getRowSpan();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rowSpans[$columnIndex] = $column->getRowSpan();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Fix tables - iterate through cells and insert missing one.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$rowGroup->hasChildren()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rowSpans[$columnIndex] = 1;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($tables as $tableWrapperBox) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rowGroups = $tableBox->getChildren();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$column->createCellBox();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$nextRow->insertBefore($insertColumn, $before);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$column->createCellBox();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function spanAllRows()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$elementTagName = $child->getElement()->getDOMElement()->tagName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$column = $row->createColumnBox();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rowSpans = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($rowSpans[$columnIndex]) && $rowSpans[$columnIndex] > 1) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->element = $element;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $boxes;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function fixTables()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rowGroups = $tableBox->getChildren();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row = $rowGroup->createRowBox();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$columnsCount = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
for ($i = 1; $i < $rowSpans; ++$i) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$before = $rowChildren[$columnIndex];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$insertColumn->setStyle(clone $column->getStyle());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$missing = $columnsCount - \count($columns);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
for ($i = 0; $i < $missing; ++$i) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$column->setRowSpanUp(0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Build tree.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$allChildren = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tableBox->insertBefore($wrapRowGroup, $rowGroup);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$insertCell->setStyle(clone $column->getFirstChild()->getStyle());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($row->getChildren() as $columnIndex => $column) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($tablesBoxes as $tableBox) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get boxes by tag name.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getBoxesByTagName(string $tagName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($columns as $columnIndex => $column) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$insertCell->getStyle()->setBox($insertCell);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rowSpansUp[$columnIndex] = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row->setRowSpan(max($row->getRowSpan(), $column->getRowSpan()));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($child instanceof self && $child->getElement() && $child->getElement()->getDOMElement()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tableBox = $tableWrapperBox->getFirstChild();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$wrapRowGroup = $tableBox->removeChild($tableBox->createRowGroupBox());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($rowGroup->getChildren() as $rowIndex => $row) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($rowChildren[$columnIndex])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
continue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($childDomElement->hasAttribute('data-header')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// wrap rows with row groups
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($rowGroup->getChildren() as $row) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->appendTableRowGroupBox($childDomElement, $element, $style, $parentBlock, $display);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$inline = $this->appendInlineBox($childDomElement, $element, $style, $parentBlock);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// for now only basic style is used - from current element only (with defaults)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->appendHeaderBox($childDomElement, $element, $style, $parentBlock);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tableWrapper = $this->appendTableWrapperBox($childDomElement, $element, $style, $parentBlock);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setElement($element);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ($childDomElement->hasAttribute('data-footer')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ($childDomElement->hasAttribute('data-barcode')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'table':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->appendTableCellBox($childDomElement, $element, $style, $parentBlock);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$style->setContent($childDomElement->getAttribute('style'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$display = $style->getRules('display');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ($childDomElement->hasAttribute('data-font')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('style' === $childDomElement->nodeName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$element->attachClasses();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'table-row':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setDocument($this->document)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$style->parseCss($childDomElement->nodeValue);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->appendBlockBox($childDomElement, $element, $style, $parentBlock);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($domElement->hasChildNodes()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ('style' === $childDomElement->nodeName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->appendTableRowBox($childDomElement, $element, $style, $parentBlock);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->appendFontBox($childDomElement, $element, $style, $parentBlock);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'table-row-group':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'inline':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($domElement->childNodes as $childDomElement) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setDocument($this->document)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->appendFooterBox($childDomElement, $element, $style, $parentBlock);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->appendBarcodeBox($childDomElement, $element, $style, $parentBlock);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'table-header-group':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'table-cell':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->init();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'block':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ($childDomElement->hasAttribute('data-watermark')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->appendWatermarkBox($childDomElement, $element, $style, $parentBlock);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'table-footer-group':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($inline) && $childDomElement instanceof \DOMText) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'none':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$element = (new Element())
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setDOMElement($childDomElement)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$style = $style->parseInline();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
switch ($display) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($childDomElement instanceof \DOMComment) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->appendStyleBox($childDomElement, $element, $style, $parentBlock);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$style = (new \YetiForcePDF\Style\Style())
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($childDomElement->hasAttribute('style')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tableWrapper->appendTableBox($childDomElement, $element, $style, $parentBlock);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'inline-block':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($childDomElement instanceof \DOMElement) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->appendInlineBlockBox($childDomElement, $element, $style, $parentBlock);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$inline->setAnonymous(true)->appendText($childDomElement, null, null, $parentBlock);
- Exclude checks
Line indented incorrectly; expected 20 spaces, found 24 Open
case 'none':
- Exclude checks
Line indented incorrectly; expected 24 spaces, found 28 Open
if ('style' === $childDomElement->nodeName) {
- Exclude checks
Line indented incorrectly; expected 24 spaces, found 28 Open
}
- Exclude checks