Skip to content

Commit

Permalink
Add doc blocks to specify array contents
Browse files Browse the repository at this point in the history
  • Loading branch information
sprain committed Jun 23, 2024
1 parent 0e99f88 commit 8449b48
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/QrBill.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ public function addAlternativeScheme(AlternativeScheme $alternativeScheme): self
}

/**
* @param string|null $fileFormat
* @param array<string, string> $unsupportedCharacterReplacements
* @return QrCode
* @throws InvalidQrBillDataException
*/
public function getQrCode(?string $fileFormat = null, array $unsupportedCharacterReplacements = []): QrCode
Expand Down
18 changes: 18 additions & 0 deletions src/QrCode/QrCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ final class QrCode
/** @var array<string, bool> $writerOptions */
private array $writerOptions = [SvgWriter::WRITER_OPTION_FORCE_XLINK_HREF => true];

/**
* @param string $data
* @param string|null $fileFormat
* @param array<string, string> $unsupportedCharacterReplacements
* @return self
* @throws UnsupportedFileExtensionException
*/
public static function create(string $data, string $fileFormat = null, array $unsupportedCharacterReplacements = []): self
{
if (null === $fileFormat) {
Expand All @@ -45,6 +52,12 @@ public static function create(string $data, string $fileFormat = null, array $un
return new self($data, $fileFormat, $unsupportedCharacterReplacements);
}

/**
* @param string $data
* @param string $fileFormat
* @param array<string, string> $unsupportedCharacterReplacements
* @throws UnsupportedFileExtensionException
*/
private function __construct(string $data, string $fileFormat, array $unsupportedCharacterReplacements)
{
$data = $this->replaceUnsupportedCharacters($data, $unsupportedCharacterReplacements);
Expand Down Expand Up @@ -132,6 +145,11 @@ public function avoidCompactSvgs(): void
}
}

/**
* @param string $data
* @param array<string, string> $unsupportedCharacterReplacements
* @return string
*/
private function replaceUnsupportedCharacters(string $data, array $unsupportedCharacterReplacements): string
{
foreach ($unsupportedCharacterReplacements as $character => $replacement) {
Expand Down

0 comments on commit 8449b48

Please sign in to comment.