YetiForcePDF
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
class YetiForcePDF extends Base
{
/** {@inheritdoc} */
const DRIVER_NAME = 'LBL_YETIFORCE_PDF';
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')) {
- 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
Class "YetiForcePDF" has 25 methods, which is greater than 20 authorized. Split it into smaller classes. Open
class YetiForcePDF extends Base
- Read upRead up
- Exclude checks
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();
- 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
Avoid using static access to class '\App\Fields\File' in method 'output'. Open
$basename = \App\Fields\File::sanitizeUploadFileName($fileName);
- Read upRead up
- Exclude checks
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')) {
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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');
- Read upRead up
- Exclude checks
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');
- Read upRead up
- Exclude checks
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');
- Read upRead up
- Exclude checks
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;
- 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.
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'))) {
- 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.
Define a constant instead of duplicating this literal "" 4 times. Open
return '<div id="header" data-header style="' . $style . '">' . $content . '</div>';
- 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.
Define a constant instead of duplicating this literal "bottom" 3 times. Open
$this->defaultMargins['bottom'] = $margin;
- 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.
Call to method setDefaultTopMargin
from undeclared class \YetiForcePDF\Document
Open
$this->pdf->setDefaultTopMargin($margin);
- Exclude checks
Call to method getMeta
from undeclared class \YetiForcePDF\Document
Open
$this->pdf->getMeta()->setCreator($creator);
- Exclude checks
Property \App\Pdf\Drivers\YetiForcePDF->pdf
has undeclared type \YetiForcePDF\Document
Open
protected $pdf;
- Exclude checks
Call to method setDefaultLeftMargin
from undeclared class \YetiForcePDF\Document
Open
$this->pdf->setDefaultLeftMargin((float) $margin);
- Exclude checks
Call to method setDefaultBottomMargin
from undeclared class \YetiForcePDF\Document
Open
$this->pdf->setDefaultBottomMargin((float) $margin);
- Exclude checks
Call to method addFonts
from undeclared class \YetiForcePDF\Document
Open
\YetiForcePDF\Document::addFonts($customFonts);
- Exclude checks
Assigning float
to property but \App\Pdf\Drivers\YetiForcePDF->footerMargin
is int
Open
$this->footerMargin = $margin;
- Exclude checks
Call to method getMeta
from undeclared class \YetiForcePDF\Document
Open
$this->pdf->getMeta()->setSubject($subject);
- Exclude checks
Call to method loadHtml
from undeclared class \YetiForcePDF\Document
Open
$this->pdf->loadHtml($this->getHtml(), $this->charset);
- Exclude checks
Assigning float
to property but \App\Pdf\Drivers\YetiForcePDF->headerMargin
is int
Open
$this->headerMargin = $margin;
- Exclude checks
Call to method setDefaultFormat
from undeclared class \YetiForcePDF\Document
Open
$this->pdf->setDefaultFormat($format);
- Exclude checks
Call to method render
from undeclared class \YetiForcePDF\Document
Open
$output = $this->pdf->render();
- Exclude checks
Call to method __construct
from undeclared class \YetiForcePDF\Document
Open
$this->pdf = (new \YetiForcePDF\Document())->init();
- Exclude checks
Call to method getMeta
from undeclared class \YetiForcePDF\Document
Open
$this->pdf->getMeta()->setTitle($title);
- Exclude checks
Call to method getMeta
from undeclared class \YetiForcePDF\Document
Open
$this->pdf->getMeta()->setKeywords($keywords);
- Exclude checks
Call to method init
from undeclared class \YetiForcePDF\Document
Open
$this->pdf = (new \YetiForcePDF\Document())->init();
- Exclude checks
Call to method setDefaultOrientation
from undeclared class \YetiForcePDF\Document
Open
$this->pdf->setDefaultOrientation($orientation);
- Exclude checks
Call to method getMeta
from undeclared class \YetiForcePDF\Document
Open
$this->pdf->getMeta()->setAuthor($author);
- Exclude checks
Call to method setDefaultRightMargin
from undeclared class \YetiForcePDF\Document
Open
$this->pdf->setDefaultRightMargin((float) $margin);
- Exclude checks
Call to method check
from undeclared class \App\YetiForce\Shop
Open
if (!\App\YetiForce\Shop::check('YetiForceDisableBranding')) {
- Exclude checks
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']);
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function setBottomMargin(float $margin)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param float $margin
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
protected $pdf;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Constructor.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->pdf = (new \YetiForcePDF\Document())->init();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->pdf->setDefaultTopMargin($margin);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->pdf->setDefaultLeftMargin((float) $margin);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function setRightMargin(float $margin)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
const DRIVER_NAME = 'LBL_YETIFORCE_PDF';
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
protected $fontSize = 10;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/** @var \YetiForcePDF\Document PDF generator instance. */
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function __construct()
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->setInputCharset(\App\Config::main('default_charset') ?? 'UTF-8');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function setFooterMargin(float $margin)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function setTopMargin(float $margin)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->setTopMargin($margins['top'] ?? $this->defaultMargins['top']);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->defaultMargins['left'] = $margin;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($orientation) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->footer = trim($footerHtml);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$html .= $this->getBody();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function wrapHeaderContent(string $content): string
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
// Modification of the following condition will violate the license!
- Exclude checks
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>';
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Load custom fonts.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public static function isActive(): bool
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->defaultMargins['top'] = $margin;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->defaultMargins['bottom'] = $margin;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Set left margin.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @author Mariusz Krzaczkowski <m.krzaczkowski@yetiforce.com>
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function setPageSize(string $format, string $orientation = null)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->pdf->setDefaultOrientation($orientation);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function setCreator(string $creator)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->pdf->getMeta()->setSubject($subject);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Gets full html.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function wrapFooterContent(string $content): string
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
foreach ($customFonts as &$font) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
protected $font = 'DejaVu Sans';
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function setLeftMargin(float $margin)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function setHeaderMargin(float $margin)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function setHeader(string $headerHtml)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->loadCustomFonts();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
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";
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
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'))) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->setFooterMargin($margins['footer'] ?? $this->defaultMargins['footer']);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function setAuthor(string $author)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->pdf->getMeta()->setKeywords($keywords);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$html = $this->watermark ? $this->wrapWatermark($this->watermark) : '';
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (empty($fileName)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$fileName = ($this->getFileName() ?: time()) . '.pdf';
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ('I' !== $mode && 'D' !== $mode) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$destination = 'I' === $mode ? 'inline' : 'attachment';
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->pdf->loadHtml($this->getHtml(), $this->charset);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function getHtml(): string
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$html .= $this->footer ? $this->wrapFooterContent($this->footer) : '';
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Wrap watermark.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$basename = \App\Fields\File::sanitizeUploadFileName($fileName);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/** @var string Default font. */
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->pdf->setDefaultRightMargin((float) $margin);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->defaultMargins['right'] = $margin;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->setHeaderMargin($margins['header'] ?? $this->defaultMargins['header']);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function setTitle(string $title)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->pdf->getMeta()->setAuthor($author);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
// Modification of the following condition will violate the license!
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return '<div id="footer" data-footer style="' . $style . '">' . $content . '</div>';
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
header('accept-charset: utf-8');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->pdf->setDefaultBottomMargin((float) $margin);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->headerMargin = $margin;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function setMargins(array $margins)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
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";
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Wrap footer content.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param string $content
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$font['file'] = $resolvedDir . $font['file'];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->setLeftMargin($margins['left'] ?? $this->defaultMargins['left']);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->setRightMargin($margins['right'] ?? $this->defaultMargins['right']);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Write html.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (!\App\YetiForce\Shop::check('YetiForceDisableBranding')) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
private function loadCustomFonts()
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->watermark = '<img src="' . $this->template->get('watermark_image') . '" style="opacity:0.1;">';
- Exclude checks
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>';
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
echo $output;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->pdf->getMeta()->setCreator($creator);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function setKeywords(array $keywords)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$customFonts = \App\Json::read($resolvedDir . 'fonts.json');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
\YetiForcePDF\Document::addFonts($customFonts);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function loadWatermark()
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->watermark = '';
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function output($fileName = '', $mode = 'D'): void
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->writeHTML();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
file_put_contents($fileName, $output);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->pdf->getMeta()->setTitle($title);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function setSubject(string $subject)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function setFooter(string $footerHtml)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function writeHTML()
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param string $content
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return '<div id="watermark" data-watermark style="text-align:center">' . $watermarkContent . '</div>';
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$resolvedDir = \Vtiger_Loader::resolveNameToPath('~' . $fontsDir, 'css');
- Exclude checks
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'))) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
header('content-type: application/pdf; charset=utf-8');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
header("content-disposition: {$destination}; filename=\"{$basename}\"");
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->pdf->setDefaultFormat($format);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->header = trim($headerHtml);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($this->template->get('watermark_image')) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->setBottomMargin($margins['bottom'] ?? $this->defaultMargins['bottom']);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$html .= $this->header ? $this->wrapHeaderContent($this->header) : '';
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $html;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Wrap header content.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return '<div id="header" data-header style="' . $style . '">' . $content . '</div>';
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param string $watermarkContent
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function wrapWatermark(string $watermarkContent): string
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$output = $this->pdf->render();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/** @var int Default font size */
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->footerMargin = $margin;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$fontsDir = 'layouts' . \DIRECTORY_SEPARATOR . 'resources' . \DIRECTORY_SEPARATOR . 'fonts' . \DIRECTORY_SEPARATOR;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
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";
- Exclude checks
Line exceeds 120 characters; contains 140 characters Open
if (self::WATERMARK_TYPE_IMAGE === $this->template->get('watermark_type') && '' !== trim($this->template->get('watermark_image'))) {
- Exclude checks
Line exceeds 120 characters; contains 144 characters Open
} elseif (self::WATERMARK_TYPE_TEXT === $this->template->get('watermark_type') && '' !== trim($this->template->get('watermark_text'))) {
- Exclude checks
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>';
- Exclude checks
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>';
- Exclude checks
Line exceeds 120 characters; contains 123 characters Open
$fontsDir = 'layouts' . \DIRECTORY_SEPARATOR . 'resources' . \DIRECTORY_SEPARATOR . 'fonts' . \DIRECTORY_SEPARATOR;
- Exclude checks
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";
- Exclude checks