lib/Objects/Basic/ArrayObject.php
The method render uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
Open
} else {
$stringItems[] = (string) $item;
}
- 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
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $this;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
protected $basicType = 'Array';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $this;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
protected $items = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return implode("\n", [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'endobj',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Collection of items.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Initialisation.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$stringItems[] = $item->getReference();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$this->id = $this->document->getActualId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if ($item instanceof \YetiForcePDF\Objects\PdfObject) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$stringItems[] = (string) $item;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$this->getRawId() . ' obj',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @var string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$stringItems = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
parent::init();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
foreach ($this->items as $item) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$this->items[] = $item;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @var string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'[ ' . implode(' ', $stringItems) . ' ]',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Basic object type (integer, string, boolean, dictionary etc..).
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Object name.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
protected $name = 'Array';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @var array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function init()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function addItem($item): self
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* {@inheritdoc}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function render(): string
- Exclude checks