Skip to content

Commit

Permalink
Remove unneeded class property
Browse files Browse the repository at this point in the history
  • Loading branch information
endroid committed Feb 12, 2018
1 parent f9a2b9c commit 927dd3a
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions src/Writer/AbstractWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,8 @@

abstract class AbstractWriter implements WriterInterface
{
private $data = [];

protected function getData(QrCodeInterface $qrCode): array
{
if (0 !== count($this->data)) {
return $this->data;
}

$name = strtoupper(substr($qrCode->getErrorCorrectionLevel(), 0, 1));
$errorCorrectionLevel = constant('BaconQrCode\Common\ErrorCorrectionLevel::'.$name);

Expand All @@ -33,23 +27,23 @@ protected function getData(QrCodeInterface $qrCode): array
$row = $row->toArray();
}

$this->data['matrix'] = $matrix;
$this->data['block_count'] = count($matrix[0]);
$this->data['block_size'] = $qrCode->getSize() / $this->data['block_count'];
$data['matrix'] = $matrix;
$data['block_count'] = count($matrix[0]);
$data['block_size'] = $qrCode->getSize() / $data['block_count'];
if ($qrCode->getRoundBlockSize()) {
$this->data['block_size'] = intval(floor($this->data['block_size']));
$data['block_size'] = intval(floor($data['block_size']));
}
$this->data['inner_width'] = $this->data['block_size'] * $this->data['block_count'];
$this->data['inner_height'] = $this->data['block_size'] * $this->data['block_count'];
$this->data['outer_width'] = $qrCode->getSize() + 2 * $qrCode->getMargin();
$this->data['outer_height'] = $qrCode->getSize() + 2 * $qrCode->getMargin();
$this->data['margin_left'] = ($this->data['outer_width'] - $this->data['inner_width']) / 2;
$data['inner_width'] = $data['block_size'] * $data['block_count'];
$data['inner_height'] = $data['block_size'] * $data['block_count'];
$data['outer_width'] = $qrCode->getSize() + 2 * $qrCode->getMargin();
$data['outer_height'] = $qrCode->getSize() + 2 * $qrCode->getMargin();
$data['margin_left'] = ($data['outer_width'] - $data['inner_width']) / 2;
if ($qrCode->getRoundBlockSize()) {
$this->data['margin_left'] = intval(floor($this->data['margin_left']));
$data['margin_left'] = intval(floor($data['margin_left']));
}
$this->data['margin_right'] = $this->data['outer_width'] - $this->data['inner_width'] - $this->data['margin_left'];
$data['margin_right'] = $data['outer_width'] - $data['inner_width'] - $data['margin_left'];

return $this->data;
return $data;
}

public function writeDataUri(QrCodeInterface $qrCode): string
Expand Down

0 comments on commit 927dd3a

Please sign in to comment.