Function parseParams
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
public function parseParams(array $params)
{
foreach ($params as $param => $value) {
switch ($param) {
case 'margin-top':
- 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
Base
has 29 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class Base
{
/** @var string Driver name */
const DRIVER_NAME = self::DRIVER_NAME;
Method parseParams
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function parseParams(array $params)
{
foreach ($params as $param => $value) {
switch ($param) {
case 'margin-top':
The method parseParams() has a Cyclomatic Complexity of 19. The configured cyclomatic complexity threshold is 10. Open
public function parseParams(array $params)
{
foreach ($params as $param => $value) {
switch ($param) {
case 'margin-top':
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
Class "Base" has 29 methods, which is greater than 20 authorized. Split it into smaller classes. Open
abstract class 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.
Refactor this function to reduce its Cognitive Complexity from 27 to the 15 allowed. Open
public function parseParams(array $params)
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
The method parseParams uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->setBottomMargin($this->defaultMargins['bottom']);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method parseParams uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->setFooterMargin($this->defaultMargins['footer']);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method parseParams uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->setTopMargin($this->defaultMargins['top']);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method parseParams uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->setHeaderMargin($this->defaultMargins['header']);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method parseParams uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->setLeftMargin($this->defaultMargins['left']);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\App\Fields\File' in method 'setFileName'. Open
$this->fileName = \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
The method parseParams uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->setRightMargin($this->defaultMargins['right']);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Define a constant instead of duplicating this literal "bottom" 3 times. Open
'bottom' => 40,
- 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 "footer" 3 times. Open
'footer' => 10,
- 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 "right" 3 times. Open
'right' => 30,
- 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 "header" 3 times. Open
'header' => 10,
- 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.
Doc-block of $orientation
in setPageSize
is phpdoc param type string
which is not a permitted replacement of the nullable param type ?string
declared in the signature ('?T' should be documented as 'T|null' or '?T') Open
* @param string $orientation
- Exclude checks
Saw an @param annotation for headerHtml,
but the param list of function loadWatermark() : static
is empty Open
* @param string $headerHtml
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var object PDF generator instance. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Watermark text type */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Watermark image type */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'bottom' => 40,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'footer' => 10,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string HTML body. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $fileName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param float $margin
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const WATERMARK_TYPE_TEXT = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'left' => 30,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'header' => 10,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
abstract public static function isActive(): bool;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $margins ['top'=>40,'bottom'=>40,'left'=>30,'right'=>30,'header'=>10,'footer'=>10]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const WATERMARK_TYPE_IMAGE = 1;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var \Vtiger_PDF_Model PDF model instance. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string HTML header. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $header;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string HTML footer. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string File name. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $fontSize;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set left margin.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Charset. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $footerMargin = 10;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $defaultMargins = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $charset;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $body;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $watermark;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $headerMargin = 10;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set document margins.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set bottom margin.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param float $margin
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var array Default margins in mm. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'right' => 30,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $pdf;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $template;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $font;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set top margin.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param float $margin
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $footer;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var int Footer margin . */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Driver name */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
abstract public function setHeaderMargin(float $margin);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
abstract public function setPageSize(string $format, string $orientation = null);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'right' => $this->template->get('margin_right'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'bottom' => $this->template->get('margin_bottom'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'left' => $this->template->get('margin_left'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
abstract public function setHeader(string $headerHtml);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
abstract public function setFooter(string $footerHtml);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $mode Output mode, default: `D`, `I` = show in browser , `D` = download , `F` = save to file
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'footer' => $this->template->get('footer_height'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setFooter($this->template->parseVariables($this->template->getFooter() ?? ''));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const DRIVER_NAME = self::DRIVER_NAME;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var int Header margin. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $headerHtml
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
abstract public function output($filePath = '', $mode = 'D'): void;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setFileName($this->template->parseVariables($this->template->get('filename')) ?? '');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set input charset.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function parseParams(array $params)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (is_numeric($value)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'top' => 40,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Check if the driver is active.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
abstract public function setBottomMargin(float $margin);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
abstract public function setFooterMargin(float $margin);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set header content.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'top' => $this->template->get('margin_top'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->parseParams($this->template->getParameters());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set PDF template model.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->template = $template;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get PDF template model.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->body;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->fileName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Parse and set options.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'margin-bottom':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setRightMargin($this->defaultMargins['right']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'creator':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var mixed Default font size. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
abstract public function setLeftMargin(float $margin);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $title
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setPageSize($this->template->getFormat(), $this->template->getOrientation());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'header' => $this->template->get('header_height'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->loadWatermark();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setBody($this->template->parseVariables($this->template->getBody() ?? ''));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get HTML body content.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
switch ($param) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'header_height':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'footer_height':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setFooterMargin($value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'subject':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setKeywords(explode(',', $value));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
abstract public function setCreator(string $creator);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $charset
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set HTML body content for exporting to PDF.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getBody(): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setHeaderMargin($this->defaultMargins['header']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'author':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
default:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string HTML watermark. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
abstract public function setTopMargin(float $margin);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param float $margin
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
abstract public function setSubject(string $subject);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Load template data to PDF instance.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setHeader($this->template->parseVariables($this->template->getHeader() ?? ''));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \Vtiger_PDF_Model $template
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get input charset.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($params as $param => $value) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (is_numeric($value)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (is_numeric($value)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $format
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $orientation
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
abstract public function setAuthor(string $author);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set footer content.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $footerHtml
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->charset = $charset;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get pdf filename.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $fileName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->fontSize = $size;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (is_numeric($value)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'margin-right':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set right margin.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
abstract public function setRightMargin(float $margin);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $headerHtml
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getTemplate(): \Vtiger_PDF_Model
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getFileName()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setBottomMargin($this->defaultMargins['bottom']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setSubject($value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set header margin.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param float $margin
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set footer margin.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $creator
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setTemplate(\Vtiger_PDF_Model $template)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $family
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setAuthor($value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Default font. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
abstract public function setMargins(array $margins);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param float $margin
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set Title of the document.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set Title of the document.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Output content to PDF.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (1 !== $this->template->get('margin_chkbox')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $html
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setBody(string $html)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $size
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set Title of the document.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set Title of the document.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setMargins([
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->body = $html;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $filePath Path name for saving pdf file
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getInputCharset(): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set pdf filename.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set font.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setLeftMargin($this->defaultMargins['left']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setFooterMargin($this->defaultMargins['footer']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setCreator($value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
abstract public function setKeywords(array $keywords);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setBottomMargin($value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set Title of the document.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $author
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string[] $keywords
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Load watermark.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function loadTemplateData(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return \Vtiger_PDF_Model
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set page size and orientation.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
abstract public function setTitle(string $title);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $subject
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
abstract public function loadWatermark();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setInputCharset(string $charset)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setFileName(string $fileName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->fileName = \App\Fields\File::sanitizeUploadFileName($fileName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $params
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setTopMargin($value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'margin-left':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setLeftMargin($value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setRightMargin($value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setHeaderMargin($value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->template;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setFont(string $family, $size)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setTopMargin($this->defaultMargins['top']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (is_numeric($value)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->charset;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->font = $family;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'margin-top':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (is_numeric($value)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'title':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setTitle($value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'keywords':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks