YetiForceCompany/YetiForcePDF

View on GitHub
lib/Layout/WatermarkBox.php

Summary

Maintainability
B
5 hrs
Test Coverage

The method measureHeight has a boolean flag argument $afterPageDividing, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function measureHeight(bool $afterPageDividing = false)
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

The method measureWidth has a boolean flag argument $afterPageDividing, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function measureWidth(bool $afterPageDividing = false)
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

The method measurePosition has a boolean flag argument $afterPageDividing, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function measurePosition(bool $afterPageDividing = false)
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

The method measureOffset has a boolean flag argument $afterPageDividing, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function measureOffset(bool $afterPageDividing = false)
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

Avoid using static access to class '\YetiForcePDF\Math' in method 'measureWidth'.
Open

        $width = Math::sub($pageWidth, $horizontalMargins);
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\YetiForcePDF\Math' in method 'measurePosition'.
Open

        $left = Math::sub(Math::div($pageWidth, '2'), Math::div($boxWidth, '2'));
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\YetiForcePDF\Math' in method 'measurePosition'.
Open

        $left = Math::sub(Math::div($pageWidth, '2'), Math::div($boxWidth, '2'));
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\YetiForcePDF\Math' in method 'measureOffset'.
Open

        $left = Math::add($left, $this->getStyle()->getRules('margin-left'));
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\YetiForcePDF\Math' in method 'measurePosition'.
Open

        $top = Math::sub(Math::div($pageHeight, '2'), Math::div($boxHeight, '2'));
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\YetiForcePDF\Math' in method 'measurePosition'.
Open

        $left = Math::sub(Math::div($pageWidth, '2'), Math::div($boxWidth, '2'));
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\YetiForcePDF\Math' in method 'measurePosition'.
Open

        $top = Math::sub(Math::div($pageHeight, '2'), Math::div($boxHeight, '2'));
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\YetiForcePDF\Math' in method 'measureOffset'.
Open

        $top = Math::add($top, $marginTop);
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\YetiForcePDF\Math' in method 'measurePosition'.
Open

        $top = Math::sub(Math::div($pageHeight, '2'), Math::div($boxHeight, '2'));
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    public function measureOffset(bool $afterPageDividing = false)
    {
        if (!$this->isRenderable()) {
            return $this;
        }
Severity: Major
Found in lib/Layout/WatermarkBox.php and 1 other location - About 3 hrs to fix
lib/Layout/HeaderBox.php on lines 62..78

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 144.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    public function measureWidth(bool $afterPageDividing = false)
    {
        if (!$this->isRenderable()) {
            return $this;
        }
Severity: Major
Found in lib/Layout/WatermarkBox.php and 2 other locations - About 1 hr to fix
lib/Layout/FooterBox.php on lines 31..46
lib/Layout/HeaderBox.php on lines 31..46

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 119.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function measureWidth(bool $afterPageDividing = false)
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $pageWidth = $this->document->getCurrentPage()->getOuterDimensions()->getWidth();
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * {@inheritdoc}
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $child->measureWidth($afterPageDividing);
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $horizontalMargins = $this->getStyle()->getHorizontalMarginsWidth();
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        foreach ($this->getChildren() as $child) {
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $width = Math::sub($pageWidth, $horizontalMargins);
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    protected $absolute = true;
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->getDimensions()->setWidth($width);
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * {@inheritdoc}
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if (!$this->isRenderable()) {
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            return $this;
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->getOffset()->setTop($top);
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->getOffset()->setLeft($left);
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->applyStyleWidth();
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            return $this;
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * {@inheritdoc}
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->getCoordinates()->setX($left)->setY($top);
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $left = Math::add($left, $this->getStyle()->getRules('margin-left'));
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $child->measureOffset($afterPageDividing);
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function measurePosition(bool $afterPageDividing = false)
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->divideLines();
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return parent::measureHeight();
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $top = Math::sub(Math::div($pageHeight, '2'), Math::div($boxHeight, '2'));
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $pageWidth = $this->document->getCurrentPage()->getDimensions()->getWidth();
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        foreach ($this->getChildren() as $child) {
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function measureHeight(bool $afterPageDividing = false)
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return $this;
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $boxWidth = $this->getDimensions()->getWidth();
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            return $this;
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return $this;
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $marginTop = $this->getStyle()->getRules('margin-top');
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $pageHeight = $this->document->getCurrentPage()->getDimensions()->getHeight();
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $boxHeight = $this->getDimensions()->getHeight();
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return $this;
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if (!$this->isRenderable()) {
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * {@inheritdoc}
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * {@inheritdoc}
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $top = '0';
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        foreach ($this->getChildren() as $child) {
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if (!$this->isRenderable()) {
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $child->measurePosition($afterPageDividing);
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $left = '0';
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $left = Math::sub(Math::div($pageWidth, '2'), Math::div($boxWidth, '2'));
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if (!$this->isRenderable()) {
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function measureOffset(bool $afterPageDividing = false)
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $top = Math::add($top, $marginTop);
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            return $this;
Severity: Minor
Found in lib/Layout/WatermarkBox.php by phpcodesniffer

There are no issues that match your filters.

Category
Status