Skip to content

Commit 5ddeacd

Browse files
authored
Allow int parts in StringUtil::joinNonEmpty (#47)
1 parent f279248 commit 5ddeacd

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ See [GitHub releases](https://github.com/mll-lab/php-utils/releases).
99

1010
## Unreleased
1111

12+
## v5.11.0
13+
14+
### Added
15+
16+
- Allow `int` parts in `StringUtil::joinNonEmpty`
17+
1218
## v5.10.0
1319

1420
### Added

src/FluidXPlate/FluidXScanner.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,10 @@ public static function parseRawContent(string $rawContent): FluidXPlate
8080
}
8181

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

8889
$plate = new FluidXPlate($id);

src/Microplate/Microplate.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ public function setWell(Coordinates $coordinates, $content): void
7272
private function assertIsWellEmpty(Coordinates $coordinates, $content): void
7373
{
7474
if (! $this->isWellEmpty($coordinates)) {
75-
throw new WellNotEmptyException(
76-
'Well with coordinates "' . $coordinates->toString() . '" is not empty. Use setWell() to overwrite the coordinate. Well content "' . serialize($content) . '" was not added.'
77-
);
75+
throw new WellNotEmptyException('Well with coordinates "' . $coordinates->toString() . '" is not empty. Use setWell() to overwrite the coordinate. Well content "' . serialize($content) . '" was not added.');
7876
}
7977
}
8078

src/StringUtil.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class StringUtil
2121
/** https://en.wikipedia.org/wiki/Byte_order_mark#UTF-32 */
2222
public const UTF_32_LITTLE_ENDIAN_BOM = "\xFF\xFE\x00\x00";
2323

24-
/** @param iterable<string|null> $parts */
24+
/** @param iterable<string|int|null> $parts */
2525
public static function joinNonEmpty(string $glue, iterable $parts): string
2626
{
2727
$nonEmptyParts = [];

tests/StringUtilTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ final class StringUtilTest extends TestCase
1212
/**
1313
* @dataProvider joinNonEmpty
1414
*
15-
* @param iterable<string|null> $parts
15+
* @param iterable<string|int|null> $parts
1616
*/
1717
#[DataProvider('joinNonEmpty')]
1818
public function testJoinNonEmpty(string $expectedJoined, string $glue, iterable $parts): void
@@ -23,12 +23,12 @@ public function testJoinNonEmpty(string $expectedJoined, string $glue, iterable
2323
);
2424
}
2525

26-
/** @return iterable<array{string, string, iterable<string|null>}> */
26+
/** @return iterable<array{string, string, iterable<string|int|null>}> */
2727
public static function joinNonEmpty(): iterable
2828
{
29-
yield ['a b', ' ', ['a', null, '', 'b']];
30-
yield ['ab', '', ['a', null, '', 'b']];
31-
yield ['a,b', ',', new Collection(['a', null, '', 'b'])];
29+
yield ['a b 0', ' ', ['a', null, 'b', '', 0]];
30+
yield ['ab1', '', ['a', null, '', 'b', 1]];
31+
yield ['a,b,2', ',', new Collection(['a', 'b', 2, null, ''])];
3232
}
3333

3434
/** @dataProvider shortenFirstname */

0 commit comments

Comments
 (0)