YetiForceCompany/YetiForceCRM

View on GitHub
app/Pdf/Drivers/YetiForcePDF.php

Summary

Maintainability
B
6 hrs
Test Coverage
B
86%

YetiForcePDF has 25 functions (exceeds 20 allowed). Consider refactoring.
Open

class YetiForcePDF extends Base
{
    /** {@inheritdoc} */
    const DRIVER_NAME = 'LBL_YETIFORCE_PDF';

Severity: Minor
Found in app/Pdf/Drivers/YetiForcePDF.php - About 2 hrs to fix

    Function loadWatermark has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function loadWatermark()
        {
            $this->watermark = '';
            if (self::WATERMARK_TYPE_IMAGE === $this->template->get('watermark_type') && '' !== trim($this->template->get('watermark_image'))) {
                if ($this->template->get('watermark_image')) {
    Severity: Minor
    Found in app/Pdf/Drivers/YetiForcePDF.php - About 25 mins to fix

    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

    Class "YetiForcePDF" has 25 methods, which is greater than 20 authorized. Split it into smaller classes.
    Open

    class YetiForcePDF extends Base
    Severity: Major
    Found in app/Pdf/Drivers/YetiForcePDF.php by sonar-php

    A class that grows too much tends to aggregate too many responsibilities and inevitably becomes harder to understand and therefore to maintain. Above a specific threshold, it is strongly advised to refactor the class into smaller ones which focus on well defined topics.

    Missing class import via use statement (line '46', column '21').
    Open

            $this->pdf = (new \YetiForcePDF\Document())->init();
    Severity: Minor
    Found in app/Pdf/Drivers/YetiForcePDF.php by phpmd

    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

    Avoid using static access to class '\App\Fields\File' in method 'output'.
    Open

            $basename = \App\Fields\File::sanitizeUploadFileName($fileName);
    Severity: Minor
    Found in app/Pdf/Drivers/YetiForcePDF.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 '\App\YetiForce\Shop' in method 'wrapFooterContent'.
    Open

            if (!\App\YetiForce\Shop::check('YetiForceDisableBranding')) {
    Severity: Minor
    Found in app/Pdf/Drivers/YetiForcePDF.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\Document' in method 'loadCustomFonts'.
    Open

            \YetiForcePDF\Document::addFonts($customFonts);
    Severity: Minor
    Found in app/Pdf/Drivers/YetiForcePDF.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 '\Vtiger_Loader' in method 'loadCustomFonts'.
    Open

            $resolvedDir = \Vtiger_Loader::resolveNameToPath('~' . $fontsDir, 'css');
    Severity: Minor
    Found in app/Pdf/Drivers/YetiForcePDF.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 '\App\Json' in method 'loadCustomFonts'.
    Open

            $customFonts = \App\Json::read($resolvedDir . 'fonts.json');
    Severity: Minor
    Found in app/Pdf/Drivers/YetiForcePDF.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 '\App\Config' in method '__construct'.
    Open

            $this->setInputCharset(\App\Config::main('default_charset') ?? 'UTF-8');
    Severity: Minor
    Found in app/Pdf/Drivers/YetiForcePDF.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

    Define a constant instead of duplicating this literal "right" 5 times.
    Open

            $this->defaultMargins['right'] = $margin;
    Severity: Critical
    Found in app/Pdf/Drivers/YetiForcePDF.php by sonar-php

    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.

    Define a constant instead of duplicating this literal "watermark_image" 3 times.
    Open

            if (self::WATERMARK_TYPE_IMAGE === $this->template->get('watermark_type') && '' !== trim($this->template->get('watermark_image'))) {
    Severity: Critical
    Found in app/Pdf/Drivers/YetiForcePDF.php by sonar-php

    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.

    Define a constant instead of duplicating this literal "" 4 times.
    Open

            return '<div id="header" data-header style="' . $style . '">' . $content . '</div>';
    Severity: Critical
    Found in app/Pdf/Drivers/YetiForcePDF.php by sonar-php

    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.

    Define a constant instead of duplicating this literal "bottom" 3 times.
    Open

            $this->defaultMargins['bottom'] = $margin;
    Severity: Critical
    Found in app/Pdf/Drivers/YetiForcePDF.php by sonar-php

    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.

    Call to method setDefaultTopMargin from undeclared class \YetiForcePDF\Document
    Open

            $this->pdf->setDefaultTopMargin($margin);
    Severity: Critical
    Found in app/Pdf/Drivers/YetiForcePDF.php by phan

    Call to method getMeta from undeclared class \YetiForcePDF\Document
    Open

            $this->pdf->getMeta()->setCreator($creator);
    Severity: Critical
    Found in app/Pdf/Drivers/YetiForcePDF.php by phan

    Property \App\Pdf\Drivers\YetiForcePDF->pdf has undeclared type \YetiForcePDF\Document
    Open

        protected $pdf;
    Severity: Minor
    Found in app/Pdf/Drivers/YetiForcePDF.php by phan

    Call to method setDefaultLeftMargin from undeclared class \YetiForcePDF\Document
    Open

            $this->pdf->setDefaultLeftMargin((float) $margin);
    Severity: Critical
    Found in app/Pdf/Drivers/YetiForcePDF.php by phan

    Call to method setDefaultBottomMargin from undeclared class \YetiForcePDF\Document
    Open

            $this->pdf->setDefaultBottomMargin((float) $margin);
    Severity: Critical
    Found in app/Pdf/Drivers/YetiForcePDF.php by phan

    Call to method addFonts from undeclared class \YetiForcePDF\Document
    Open

            \YetiForcePDF\Document::addFonts($customFonts);
    Severity: Critical
    Found in app/Pdf/Drivers/YetiForcePDF.php by phan

    Assigning float to property but \App\Pdf\Drivers\YetiForcePDF->footerMargin is int
    Open

            $this->footerMargin = $margin;
    Severity: Minor
    Found in app/Pdf/Drivers/YetiForcePDF.php by phan

    Call to method getMeta from undeclared class \YetiForcePDF\Document
    Open

            $this->pdf->getMeta()->setSubject($subject);
    Severity: Critical
    Found in app/Pdf/Drivers/YetiForcePDF.php by phan

    Call to method loadHtml from undeclared class \YetiForcePDF\Document
    Open

            $this->pdf->loadHtml($this->getHtml(), $this->charset);
    Severity: Critical
    Found in app/Pdf/Drivers/YetiForcePDF.php by phan

    Assigning float to property but \App\Pdf\Drivers\YetiForcePDF->headerMargin is int
    Open

            $this->headerMargin = $margin;
    Severity: Minor
    Found in app/Pdf/Drivers/YetiForcePDF.php by phan

    Call to method setDefaultFormat from undeclared class \YetiForcePDF\Document
    Open

            $this->pdf->setDefaultFormat($format);
    Severity: Critical
    Found in app/Pdf/Drivers/YetiForcePDF.php by phan

    Call to method render from undeclared class \YetiForcePDF\Document
    Open

            $output = $this->pdf->render();
    Severity: Critical
    Found in app/Pdf/Drivers/YetiForcePDF.php by phan

    Call to method __construct from undeclared class \YetiForcePDF\Document
    Open

            $this->pdf = (new \YetiForcePDF\Document())->init();
    Severity: Critical
    Found in app/Pdf/Drivers/YetiForcePDF.php by phan

    Call to method getMeta from undeclared class \YetiForcePDF\Document
    Open

            $this->pdf->getMeta()->setTitle($title);
    Severity: Critical
    Found in app/Pdf/Drivers/YetiForcePDF.php by phan

    Call to method getMeta from undeclared class \YetiForcePDF\Document
    Open

            $this->pdf->getMeta()->setKeywords($keywords);
    Severity: Critical
    Found in app/Pdf/Drivers/YetiForcePDF.php by phan

    Call to method init from undeclared class \YetiForcePDF\Document
    Open

            $this->pdf = (new \YetiForcePDF\Document())->init();
    Severity: Critical
    Found in app/Pdf/Drivers/YetiForcePDF.php by phan

    Call to method setDefaultOrientation from undeclared class \YetiForcePDF\Document
    Open

                $this->pdf->setDefaultOrientation($orientation);
    Severity: Critical
    Found in app/Pdf/Drivers/YetiForcePDF.php by phan

    Call to method getMeta from undeclared class \YetiForcePDF\Document
    Open

            $this->pdf->getMeta()->setAuthor($author);
    Severity: Critical
    Found in app/Pdf/Drivers/YetiForcePDF.php by phan

    Call to method setDefaultRightMargin from undeclared class \YetiForcePDF\Document
    Open

            $this->pdf->setDefaultRightMargin((float) $margin);
    Severity: Critical
    Found in app/Pdf/Drivers/YetiForcePDF.php by phan

    Call to method check from undeclared class \App\YetiForce\Shop
    Open

            if (!\App\YetiForce\Shop::check('YetiForceDisableBranding')) {
    Severity: Critical
    Found in app/Pdf/Drivers/YetiForcePDF.php by phan

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

        public function setMargins(array $margins)
        {
            $this->setTopMargin($margins['top'] ?? $this->defaultMargins['top']);
            $this->setBottomMargin($margins['bottom'] ?? $this->defaultMargins['bottom']);
            $this->setLeftMargin($margins['left'] ?? $this->defaultMargins['left']);
    Severity: Major
    Found in app/Pdf/Drivers/YetiForcePDF.php and 1 other location - About 3 hrs to fix
    app/Pdf/Drivers/Chromium.php on lines 194..203

    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 149.

    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 for alignment; tabs are not allowed
    Open

        /**

    Spaces must be used for alignment; tabs are not allowed
    Open

            return $this;

    Spaces must be used for alignment; tabs are not allowed
    Open

        /** {@inheritdoc} */

    Spaces must be used for alignment; tabs are not allowed
    Open

        public function setBottomMargin(float $margin)

    Spaces must be used for alignment; tabs are not allowed
    Open

         * @param float $margin

    Spaces must be used for alignment; tabs are not allowed
    Open

        protected $pdf;

    Spaces must be used for alignment; tabs are not allowed
    Open

         * Constructor.

    Spaces must be used for alignment; tabs are not allowed
    Open

         */

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->pdf = (new \YetiForcePDF\Document())->init();

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->pdf->setDefaultTopMargin($margin);

    Spaces must be used for alignment; tabs are not allowed
    Open

            return $this;

    Spaces must be used for alignment; tabs are not allowed
    Open

         */

    Spaces must be used for alignment; tabs are not allowed
    Open

        {

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->pdf->setDefaultLeftMargin((float) $margin);

    Spaces must be used for alignment; tabs are not allowed
    Open

        public function setRightMargin(float $margin)

    Spaces must be used for alignment; tabs are not allowed
    Open

        {

    Spaces must be used for alignment; tabs are not allowed
    Open

        }

    Spaces must be used for alignment; tabs are not allowed
    Open

        const DRIVER_NAME = 'LBL_YETIFORCE_PDF';

    Spaces must be used for alignment; tabs are not allowed
    Open

        protected $fontSize = 10;

    Spaces must be used for alignment; tabs are not allowed
    Open

        /** @var \YetiForcePDF\Document PDF generator instance. */

    Spaces must be used for alignment; tabs are not allowed
    Open

        public function __construct()

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->setInputCharset(\App\Config::main('default_charset') ?? 'UTF-8');

    Spaces must be used for alignment; tabs are not allowed
    Open

        }

    Spaces must be used for alignment; tabs are not allowed
    Open

        public function setFooterMargin(float $margin)

    Spaces must be used for alignment; tabs are not allowed
    Open

        public function setTopMargin(float $margin)

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->setTopMargin($margins['top'] ?? $this->defaultMargins['top']);

    Spaces must be used for alignment; tabs are not allowed
    Open

        /** {@inheritdoc} */

    Spaces must be used for alignment; tabs are not allowed
    Open

        {

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->defaultMargins['left'] = $margin;

    Spaces must be used for alignment; tabs are not allowed
    Open

            return $this;

    Spaces must be used for alignment; tabs are not allowed
    Open

            if ($orientation) {

    Spaces must be used for alignment; tabs are not allowed
    Open

            return $this;

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->footer = trim($footerHtml);

    Spaces must be used for alignment; tabs are not allowed
    Open

            return $this;

    Spaces must be used for alignment; tabs are not allowed
    Open

        {

    Spaces must be used for alignment; tabs are not allowed
    Open

            $html .= $this->getBody();

    Spaces must be used for alignment; tabs are not allowed
    Open

         */

    Spaces must be used for alignment; tabs are not allowed
    Open

        public function wrapHeaderContent(string $content): string

    Spaces must be used for alignment; tabs are not allowed
    Open

            // Modification of the following condition will violate the license!

    Spaces must be used for alignment; tabs are not allowed
    Open

                $content .= '<table style="font-size:6px;width:100%; margin: 0;"><tbody><tr><td style="width:50%">Powered by YetiForce</td></tr></tbody></table>';

    Spaces must be used for alignment; tabs are not allowed
    Open

        /**

    Spaces must be used for alignment; tabs are not allowed
    Open

         * Load custom fonts.

    Spaces must be used for alignment; tabs are not allowed
    Open

        /** {@inheritdoc} */

    Spaces must be used for alignment; tabs are not allowed
    Open

        public static function isActive(): bool

    Spaces must be used for alignment; tabs are not allowed
    Open

        }

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->defaultMargins['top'] = $margin;

    Spaces must be used for alignment; tabs are not allowed
    Open

        {

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->defaultMargins['bottom'] = $margin;

    Spaces must be used for alignment; tabs are not allowed
    Open

         * Set left margin.

    Spaces must be used for alignment; tabs are not allowed
    Open

     * @author      Mariusz Krzaczkowski <m.krzaczkowski@yetiforce.com>

    Spaces must be used for alignment; tabs are not allowed
    Open

        /** {@inheritdoc} */

    Spaces must be used for alignment; tabs are not allowed
    Open

        }

    Spaces must be used for alignment; tabs are not allowed
    Open

        /** {@inheritdoc} */

    Spaces must be used for alignment; tabs are not allowed
    Open

        /** {@inheritdoc} */

    Spaces must be used for alignment; tabs are not allowed
    Open

        public function setPageSize(string $format, string $orientation = null)

    Spaces must be used for alignment; tabs are not allowed
    Open

                $this->pdf->setDefaultOrientation($orientation);

    Spaces must be used for alignment; tabs are not allowed
    Open

        {

    Spaces must be used for alignment; tabs are not allowed
    Open

        {

    Spaces must be used for alignment; tabs are not allowed
    Open

        public function setCreator(string $creator)

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->pdf->getMeta()->setSubject($subject);

    Spaces must be used for alignment; tabs are not allowed
    Open

         *

    Spaces must be used for alignment; tabs are not allowed
    Open

            return $this;

    Spaces must be used for alignment; tabs are not allowed
    Open

            return $this;

    Spaces must be used for alignment; tabs are not allowed
    Open

        {

    Spaces must be used for alignment; tabs are not allowed
    Open

            return $this;

    Spaces must be used for alignment; tabs are not allowed
    Open

        }

    Spaces must be used for alignment; tabs are not allowed
    Open

         */

    Spaces must be used for alignment; tabs are not allowed
    Open

         * Gets full html.

    Spaces must be used for alignment; tabs are not allowed
    Open

        /**

    Spaces must be used for alignment; tabs are not allowed
    Open

        public function wrapFooterContent(string $content): string

    Spaces must be used for alignment; tabs are not allowed
    Open

        /**

    Spaces must be used for alignment; tabs are not allowed
    Open

        {

    Spaces must be used for alignment; tabs are not allowed
    Open

            foreach ($customFonts as &$font) {

    Spaces must be used for alignment; tabs are not allowed
    Open

        protected $font = 'DejaVu Sans';

    Spaces must be used for alignment; tabs are not allowed
    Open

        }

    Spaces must be used for alignment; tabs are not allowed
    Open

        /**

    Spaces must be used for alignment; tabs are not allowed
    Open

        public function setLeftMargin(float $margin)

    Spaces must be used for alignment; tabs are not allowed
    Open

        public function setHeaderMargin(float $margin)

    Spaces must be used for alignment; tabs are not allowed
    Open

        /** {@inheritdoc} */

    Spaces must be used for alignment; tabs are not allowed
    Open

        public function setHeader(string $headerHtml)

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->loadCustomFonts();

    Spaces must be used for alignment; tabs are not allowed
    Open

        }

    Spaces must be used for alignment; tabs are not allowed
    Open

        }

    Spaces must be used for alignment; tabs are not allowed
    Open

            $style = "padding-bottom:{$this->footerMargin}px; padding-left:{$this->defaultMargins['left']}px; padding-right:{$this->defaultMargins['right']}px";

    Spaces must be used for alignment; tabs are not allowed
    Open

        {

    Spaces must be used for alignment; tabs are not allowed
    Open

            } elseif (self::WATERMARK_TYPE_TEXT === $this->template->get('watermark_type') && '' !== trim($this->template->get('watermark_text'))) {

    Spaces must be used for alignment; tabs are not allowed
    Open

        {

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->setFooterMargin($margins['footer'] ?? $this->defaultMargins['footer']);

    Spaces must be used for alignment; tabs are not allowed
    Open

            return $this;

    Spaces must be used for alignment; tabs are not allowed
    Open

        {

    Spaces must be used for alignment; tabs are not allowed
    Open

        public function setAuthor(string $author)

    Spaces must be used for alignment; tabs are not allowed
    Open

        {

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->pdf->getMeta()->setKeywords($keywords);

    Spaces must be used for alignment; tabs are not allowed
    Open

            return $this;

    Spaces must be used for alignment; tabs are not allowed
    Open

         *

    Spaces must be used for alignment; tabs are not allowed
    Open

            $html = $this->watermark ? $this->wrapWatermark($this->watermark) : '';

    Spaces must be used for alignment; tabs are not allowed
    Open

         *

    Spaces must be used for alignment; tabs are not allowed
    Open

        }

    Spaces must be used for alignment; tabs are not allowed
    Open

        {

    Spaces must be used for alignment; tabs are not allowed
    Open

            if (empty($fileName)) {

    Spaces must be used for alignment; tabs are not allowed
    Open

                $fileName = ($this->getFileName() ?: time()) . '.pdf';

    Spaces must be used for alignment; tabs are not allowed
    Open

            if ('I' !== $mode && 'D' !== $mode) {

    Spaces must be used for alignment; tabs are not allowed
    Open

            $destination = 'I' === $mode ? 'inline' : 'attachment';

    Spaces must be used for alignment; tabs are not allowed
    Open

            return true;

    Spaces must be used for alignment; tabs are not allowed
    Open

        {

    Spaces must be used for alignment; tabs are not allowed
    Open

        {

    Spaces must be used for alignment; tabs are not allowed
    Open

            }

    Spaces must be used for alignment; tabs are not allowed
    Open

        }

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->pdf->loadHtml($this->getHtml(), $this->charset);

    Spaces must be used for alignment; tabs are not allowed
    Open

            return $this;

    Spaces must be used for alignment; tabs are not allowed
    Open

         * @return string

    Spaces must be used for alignment; tabs are not allowed
    Open

        public function getHtml(): string

    Spaces must be used for alignment; tabs are not allowed
    Open

            $html .= $this->footer ? $this->wrapFooterContent($this->footer) : '';

    Spaces must be used for alignment; tabs are not allowed
    Open

         * @return string

    Spaces must be used for alignment; tabs are not allowed
    Open

         * Wrap watermark.

    Spaces must be used for alignment; tabs are not allowed
    Open

            return $this;

    Spaces must be used for alignment; tabs are not allowed
    Open

            $basename = \App\Fields\File::sanitizeUploadFileName($fileName);

    Spaces must be used for alignment; tabs are not allowed
    Open

        /** @var string Default font. */

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->pdf->setDefaultRightMargin((float) $margin);

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->defaultMargins['right'] = $margin;

    Spaces must be used for alignment; tabs are not allowed
    Open

        {

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->setHeaderMargin($margins['header'] ?? $this->defaultMargins['header']);

    Spaces must be used for alignment; tabs are not allowed
    Open

        public function setTitle(string $title)

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->pdf->getMeta()->setAuthor($author);

    Spaces must be used for alignment; tabs are not allowed
    Open

        }

    Spaces must be used for alignment; tabs are not allowed
    Open

            }

    Spaces must be used for alignment; tabs are not allowed
    Open

            // Modification of the following condition will violate the license!

    Spaces must be used for alignment; tabs are not allowed
    Open

            return '<div id="footer" data-footer style="' . $style . '">' . $content . '</div>';

    Spaces must be used for alignment; tabs are not allowed
    Open

         */

    Spaces must be used for alignment; tabs are not allowed
    Open

            header('accept-charset: utf-8');

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->pdf->setDefaultBottomMargin((float) $margin);

    Spaces must be used for alignment; tabs are not allowed
    Open

            return $this;

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->headerMargin = $margin;

    Spaces must be used for alignment; tabs are not allowed
    Open

        public function setMargins(array $margins)

    Spaces must be used for alignment; tabs are not allowed
    Open

        /** {@inheritdoc} */

    Spaces must be used for alignment; tabs are not allowed
    Open

        /** {@inheritdoc} */

    Spaces must be used for alignment; tabs are not allowed
    Open

        {

    Spaces must be used for alignment; tabs are not allowed
    Open

            $style = "padding-top:{$this->headerMargin}px; padding-left:{$this->defaultMargins['left']}px; padding-right:{$this->defaultMargins['right']}px";

    Spaces must be used for alignment; tabs are not allowed
    Open

         * Wrap footer content.

    Spaces must be used for alignment; tabs are not allowed
    Open

         * @param string $content

    Spaces must be used for alignment; tabs are not allowed
    Open

        }

    Spaces must be used for alignment; tabs are not allowed
    Open

         *

    Spaces must be used for alignment; tabs are not allowed
    Open

        }

    Spaces must be used for alignment; tabs are not allowed
    Open

                $font['file'] = $resolvedDir . $font['file'];

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->setLeftMargin($margins['left'] ?? $this->defaultMargins['left']);

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->setRightMargin($margins['right'] ?? $this->defaultMargins['right']);

    Spaces must be used for alignment; tabs are not allowed
    Open

            return $this;

    Spaces must be used for alignment; tabs are not allowed
    Open

        {

    Spaces must be used for alignment; tabs are not allowed
    Open

        }

    Spaces must be used for alignment; tabs are not allowed
    Open

         * Write html.

    Spaces must be used for alignment; tabs are not allowed
    Open

         * @return $this

    Spaces must be used for alignment; tabs are not allowed
    Open

        {

    Spaces must be used for alignment; tabs are not allowed
    Open

         *

    Spaces must be used for alignment; tabs are not allowed
    Open

         *

    Spaces must be used for alignment; tabs are not allowed
    Open

        {

    Spaces must be used for alignment; tabs are not allowed
    Open

            if (!\App\YetiForce\Shop::check('YetiForceDisableBranding')) {

    Spaces must be used for alignment; tabs are not allowed
    Open

        private function loadCustomFonts()

    Spaces must be used for alignment; tabs are not allowed
    Open

            }

    Spaces must be used for alignment; tabs are not allowed
    Open

                return;

    Spaces must be used for alignment; tabs are not allowed
    Open

        /** {@inheritdoc} */

    Spaces must be used for alignment; tabs are not allowed
    Open

                    $this->watermark = '<img src="' . $this->template->get('watermark_image') . '" style="opacity:0.1;">';

    Spaces must be used for alignment; tabs are not allowed
    Open

                $this->watermark = '<div style="opacity:0.1;display:inline-block;">' . $this->template->parseVariables($this->template->get('watermark_text')) . '</div>';

    Spaces must be used for alignment; tabs are not allowed
    Open

            echo $output;

    Spaces must be used for alignment; tabs are not allowed
    Open

        }

    Spaces must be used for alignment; tabs are not allowed
    Open

        }

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->pdf->getMeta()->setCreator($creator);

    Spaces must be used for alignment; tabs are not allowed
    Open

         */

    Spaces must be used for alignment; tabs are not allowed
    Open

        {

    Spaces must be used for alignment; tabs are not allowed
    Open

            return $this;

    Spaces must be used for alignment; tabs are not allowed
    Open

        }

    Spaces must be used for alignment; tabs are not allowed
    Open

        /** {@inheritdoc} */

    Spaces must be used for alignment; tabs are not allowed
    Open

        /** {@inheritdoc} */

    Spaces must be used for alignment; tabs are not allowed
    Open

        public function setKeywords(array $keywords)

    Spaces must be used for alignment; tabs are not allowed
    Open

        {

    Spaces must be used for alignment; tabs are not allowed
    Open

        /**

    Spaces must be used for alignment; tabs are not allowed
    Open

         */

    Spaces must be used for alignment; tabs are not allowed
    Open

         * @return $this

    Spaces must be used for alignment; tabs are not allowed
    Open

            $customFonts = \App\Json::read($resolvedDir . 'fonts.json');

    Spaces must be used for alignment; tabs are not allowed
    Open

            \YetiForcePDF\Document::addFonts($customFonts);

    Spaces must be used for alignment; tabs are not allowed
    Open

        public function loadWatermark()

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->watermark = '';

    Spaces must be used for alignment; tabs are not allowed
    Open

        public function output($fileName = '', $mode = 'D'): void

    Spaces must be used for alignment; tabs are not allowed
    Open

            }

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->writeHTML();

    Spaces must be used for alignment; tabs are not allowed
    Open

                file_put_contents($fileName, $output);

    Spaces must be used for alignment; tabs are not allowed
    Open

            }

    Spaces must be used for alignment; tabs are not allowed
    Open

        }

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->pdf->getMeta()->setTitle($title);

    Spaces must be used for alignment; tabs are not allowed
    Open

        public function setSubject(string $subject)

    Spaces must be used for alignment; tabs are not allowed
    Open

        }

    Spaces must be used for alignment; tabs are not allowed
    Open

        public function setFooter(string $footerHtml)

    Spaces must be used for alignment; tabs are not allowed
    Open

        public function writeHTML()

    Spaces must be used for alignment; tabs are not allowed
    Open

         */

    Spaces must be used for alignment; tabs are not allowed
    Open

         *

    Spaces must be used for alignment; tabs are not allowed
    Open

         * @param string $content

    Spaces must be used for alignment; tabs are not allowed
    Open

            return '<div id="watermark" data-watermark style="text-align:center">' . $watermarkContent . '</div>';

    Spaces must be used for alignment; tabs are not allowed
    Open

            $resolvedDir = \Vtiger_Loader::resolveNameToPath('~' . $fontsDir, 'css');

    Spaces must be used for alignment; tabs are not allowed
    Open

            if (self::WATERMARK_TYPE_IMAGE === $this->template->get('watermark_type') && '' !== trim($this->template->get('watermark_image'))) {

    Spaces must be used for alignment; tabs are not allowed
    Open

            header('content-type: application/pdf; charset=utf-8');

    Spaces must be used for alignment; tabs are not allowed
    Open

            header("content-disposition: {$destination}; filename=\"{$basename}\"");

    Spaces must be used for alignment; tabs are not allowed
    Open

        }

    Spaces must be used for alignment; tabs are not allowed
    Open

            return $this;

    Spaces must be used for alignment; tabs are not allowed
    Open

        /** {@inheritdoc} */

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->pdf->setDefaultFormat($format);

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->header = trim($headerHtml);

    Spaces must be used for alignment; tabs are not allowed
    Open

        }

    Spaces must be used for alignment; tabs are not allowed
    Open

        /**

    Spaces must be used for alignment; tabs are not allowed
    Open

         * @return string

    Spaces must be used for alignment; tabs are not allowed
    Open

         *

    Spaces must be used for alignment; tabs are not allowed
    Open

         * @return string

    Spaces must be used for alignment; tabs are not allowed
    Open

                if ($this->template->get('watermark_image')) {

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->setBottomMargin($margins['bottom'] ?? $this->defaultMargins['bottom']);

    Spaces must be used for alignment; tabs are not allowed
    Open

        }

    Spaces must be used for alignment; tabs are not allowed
    Open

            return $this;

    Spaces must be used for alignment; tabs are not allowed
    Open

        {

    Spaces must be used for alignment; tabs are not allowed
    Open

        /**

    Spaces must be used for alignment; tabs are not allowed
    Open

            $html .= $this->header ? $this->wrapHeaderContent($this->header) : '';

    Spaces must be used for alignment; tabs are not allowed
    Open

            return $html;

    Spaces must be used for alignment; tabs are not allowed
    Open

         * Wrap header content.

    Spaces must be used for alignment; tabs are not allowed
    Open

            return '<div id="header" data-header style="' . $style . '">' . $content . '</div>';

    Spaces must be used for alignment; tabs are not allowed
    Open

         * @param string $watermarkContent

    Spaces must be used for alignment; tabs are not allowed
    Open

        public function wrapWatermark(string $watermarkContent): string

    Spaces must be used for alignment; tabs are not allowed
    Open

         *

    Spaces must be used for alignment; tabs are not allowed
    Open

                }

    Spaces must be used for alignment; tabs are not allowed
    Open

        /** {@inheritdoc} */

    Spaces must be used for alignment; tabs are not allowed
    Open

            $output = $this->pdf->render();

    Spaces must be used for alignment; tabs are not allowed
    Open

        /** @var int Default font size */

    Spaces must be used for alignment; tabs are not allowed
    Open

        }

    Spaces must be used for alignment; tabs are not allowed
    Open

        /** {@inheritdoc} */

    Spaces must be used for alignment; tabs are not allowed
    Open

         *

    Spaces must be used for alignment; tabs are not allowed
    Open

        }

    Spaces must be used for alignment; tabs are not allowed
    Open

            $this->footerMargin = $margin;

    Spaces must be used for alignment; tabs are not allowed
    Open

        /** {@inheritdoc} */

    Spaces must be used for alignment; tabs are not allowed
    Open

        /** {@inheritdoc} */

    Spaces must be used for alignment; tabs are not allowed
    Open

            return $this;

    Spaces must be used for alignment; tabs are not allowed
    Open

        /** {@inheritdoc} */

    Spaces must be used for alignment; tabs are not allowed
    Open

        {

    Spaces must be used for alignment; tabs are not allowed
    Open

            $fontsDir = 'layouts' . \DIRECTORY_SEPARATOR . 'resources' . \DIRECTORY_SEPARATOR . 'fonts' . \DIRECTORY_SEPARATOR;

    Spaces must be used for alignment; tabs are not allowed
    Open

            }

    Spaces must be used for alignment; tabs are not allowed
    Open

        }

    Line exceeds 120 characters; contains 153 characters
    Open

            $style = "padding-top:{$this->headerMargin}px; padding-left:{$this->defaultMargins['left']}px; padding-right:{$this->defaultMargins['right']}px";

    Line exceeds 120 characters; contains 140 characters
    Open

            if (self::WATERMARK_TYPE_IMAGE === $this->template->get('watermark_type') && '' !== trim($this->template->get('watermark_image'))) {

    Line exceeds 120 characters; contains 144 characters
    Open

            } elseif (self::WATERMARK_TYPE_TEXT === $this->template->get('watermark_type') && '' !== trim($this->template->get('watermark_text'))) {

    Line exceeds 120 characters; contains 166 characters
    Open

                $this->watermark = '<div style="opacity:0.1;display:inline-block;">' . $this->template->parseVariables($this->template->get('watermark_text')) . '</div>';

    Line exceeds 120 characters; contains 158 characters
    Open

                $content .= '<table style="font-size:6px;width:100%; margin: 0;"><tbody><tr><td style="width:50%">Powered by YetiForce</td></tr></tbody></table>';

    Line exceeds 120 characters; contains 123 characters
    Open

            $fontsDir = 'layouts' . \DIRECTORY_SEPARATOR . 'resources' . \DIRECTORY_SEPARATOR . 'fonts' . \DIRECTORY_SEPARATOR;

    Line exceeds 120 characters; contains 156 characters
    Open

            $style = "padding-bottom:{$this->footerMargin}px; padding-left:{$this->defaultMargins['left']}px; padding-right:{$this->defaultMargins['right']}px";

    There are no issues that match your filters.

    Category
    Status