Skip to content

Commit

Permalink
[TASK] Remove code smell
Browse files Browse the repository at this point in the history
"Local variables should not have the same name as class fields"
from SonarAnalyzer.
  • Loading branch information
brotkrueml committed Mar 29, 2020
1 parent c003a0b commit f51831f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Classes/JsonLd/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class Renderer implements RendererInterface
private const CONTEXT = 'http://schema.org';

private $types = [];
private $result;
private $typeResult;

public function addType(TypeInterface ...$type): void
{
Expand Down Expand Up @@ -61,25 +61,25 @@ public function render(): string

private function prepare(TypeInterface $type): array
{
$this->result = [];
$this->typeResult = [];

$this->addTypeToResult($type);
$this->addIdToResult($type);
$this->addPropertiesToResult($type);

return $this->result;
return $this->typeResult;
}

private function addTypeToResult(TypeInterface $type): void
{
$this->result['@type'] = $type->getType();
$this->typeResult['@type'] = $type->getType();
}

private function addIdToResult(TypeInterface $type): void
{
$id = $type->getId();
if ($id) {
$this->result['@id'] = $id;
$this->typeResult['@id'] = $id;
}
}

Expand All @@ -93,14 +93,14 @@ private function addPropertiesToResult(TypeInterface $type): void
}

if (\is_array($propertyValue)) {
$this->result[$propertyName] = [];
$this->typeResult[$propertyName] = [];
foreach ($propertyValue as $singlePropertyValue) {
$this->result[$propertyName][] = $this->getPropertyValueForResult($singlePropertyValue);
$this->typeResult[$propertyName][] = $this->getPropertyValueForResult($singlePropertyValue);
}
continue;
}

$this->result[$propertyName] = $this->getPropertyValueForResult($propertyValue);
$this->typeResult[$propertyName] = $this->getPropertyValueForResult($propertyValue);
}
}

Expand Down

0 comments on commit f51831f

Please sign in to comment.