Skip to content

Commit

Permalink
Allow int parts in StringUtil::joinNonEmpty (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
spawnia authored Jan 24, 2025
1 parent f279248 commit 5ddeacd
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ See [GitHub releases](https://github.com/mll-lab/php-utils/releases).

## Unreleased

## v5.11.0

### Added

- Allow `int` parts in `StringUtil::joinNonEmpty`

## v5.10.0

### Added
Expand Down
5 changes: 3 additions & 2 deletions src/FluidXPlate/FluidXScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ public static function parseRawContent(string $rawContent): FluidXPlate
}

if ($id === FluidXScanner::NO_READ) {
throw new ScanFluidXPlateException($barcodes === []
$message = $barcodes === []
? 'Weder Platten-Barcode noch Tube-Barcodes konnten gescannt werden. Bitte überprüfen Sie, dass die Platte korrekt in den FluidX-Scanner eingelegt wurde.'
: 'Platten-Barcode konnte nicht gescannt werden. Bitte überprüfen Sie, dass die Platte mit der korrekten Orientierung in den FluidX-Scanner eingelegt wurde.');
: 'Platten-Barcode konnte nicht gescannt werden. Bitte überprüfen Sie, dass die Platte mit der korrekten Orientierung in den FluidX-Scanner eingelegt wurde.';
throw new ScanFluidXPlateException($message);
}

$plate = new FluidXPlate($id);
Expand Down
4 changes: 1 addition & 3 deletions src/Microplate/Microplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ public function setWell(Coordinates $coordinates, $content): void
private function assertIsWellEmpty(Coordinates $coordinates, $content): void
{
if (! $this->isWellEmpty($coordinates)) {
throw new WellNotEmptyException(
'Well with coordinates "' . $coordinates->toString() . '" is not empty. Use setWell() to overwrite the coordinate. Well content "' . serialize($content) . '" was not added.'
);
throw new WellNotEmptyException('Well with coordinates "' . $coordinates->toString() . '" is not empty. Use setWell() to overwrite the coordinate. Well content "' . serialize($content) . '" was not added.');
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/StringUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class StringUtil
/** https://en.wikipedia.org/wiki/Byte_order_mark#UTF-32 */
public const UTF_32_LITTLE_ENDIAN_BOM = "\xFF\xFE\x00\x00";

/** @param iterable<string|null> $parts */
/** @param iterable<string|int|null> $parts */
public static function joinNonEmpty(string $glue, iterable $parts): string
{
$nonEmptyParts = [];
Expand Down
10 changes: 5 additions & 5 deletions tests/StringUtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class StringUtilTest extends TestCase
/**
* @dataProvider joinNonEmpty
*
* @param iterable<string|null> $parts
* @param iterable<string|int|null> $parts
*/
#[DataProvider('joinNonEmpty')]
public function testJoinNonEmpty(string $expectedJoined, string $glue, iterable $parts): void
Expand All @@ -23,12 +23,12 @@ public function testJoinNonEmpty(string $expectedJoined, string $glue, iterable
);
}

/** @return iterable<array{string, string, iterable<string|null>}> */
/** @return iterable<array{string, string, iterable<string|int|null>}> */
public static function joinNonEmpty(): iterable
{
yield ['a b', ' ', ['a', null, '', 'b']];
yield ['ab', '', ['a', null, '', 'b']];
yield ['a,b', ',', new Collection(['a', null, '', 'b'])];
yield ['a b 0', ' ', ['a', null, 'b', '', 0]];
yield ['ab1', '', ['a', null, '', 'b', 1]];
yield ['a,b,2', ',', new Collection(['a', 'b', 2, null, ''])];
}

/** @dataProvider shortenFirstname */
Expand Down

0 comments on commit 5ddeacd

Please sign in to comment.