Skip to content

Commit 31dad21

Browse files
authored
Add coordinate system CoordinateSystem2x16, generalize scalars for rows and columns
1 parent aaa61d5 commit 31dad21

16 files changed

+679
-902
lines changed

CHANGELOG.md

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

1010
## Unreleased
1111

12+
## v5.0.0
13+
14+
### Added
15+
16+
- Add coordinate system `CoordinateSystem2x16`
17+
18+
### Changed
19+
20+
- Breaking Change: Renamed class `Column96Well` to `Column12`
21+
- Breaking Change: Renamed class `Row96Well` to `Row8`
22+
-
1223
## v4.1.0
1324

1425
### Added

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"require-dev": {
2727
"ergebnis/composer-normalize": "^2",
2828
"jangregor/phpstan-prophecy": "^1",
29-
"mll-lab/graphql-php-scalars": "^6",
29+
"mll-lab/graphql-php-scalars": "^6.3",
3030
"mll-lab/php-cs-fixer-config": "^5",
3131
"phpstan/extension-installer": "^1",
3232
"phpstan/phpstan": "^1",
@@ -38,7 +38,7 @@
3838
"thecodingmachine/phpstan-safe-rule": "^1.2"
3939
},
4040
"suggest": {
41-
"mll-lab/graphql-php-scalars": "To use the provided scalar types for GraphQL servers, requires version ^6"
41+
"mll-lab/graphql-php-scalars": "To use the provided scalar types for GraphQL servers, requires version ^6.3"
4242
},
4343
"autoload": {
4444
"psr-4": {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace MLL\Utils\Microplate;
4+
5+
class CoordinateSystem2x16 extends CoordinateSystem
6+
{
7+
/** Duplicates @see CoordinateSystem::positionsCount() for static contexts. */
8+
public const POSITIONS_COUNT = 32;
9+
10+
public function rows(): array
11+
{
12+
return range('A', 'P');
13+
}
14+
15+
public function columns(): array
16+
{
17+
return range(1, 2);
18+
}
19+
}

src/Microplate/Scalars/Column12.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace MLL\Utils\Microplate\Scalars;
4+
5+
use MLL\GraphQLScalars\IntRange;
6+
7+
class Column12 extends IntRange
8+
{
9+
public ?string $description = 'Represents a column in a coordinate system with 12 columns. Allowed values range from 1-12.';
10+
11+
protected static function min(): int
12+
{
13+
return 1;
14+
}
15+
16+
protected static function max(): int
17+
{
18+
return 12;
19+
}
20+
}

src/Microplate/Scalars/Column2.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace MLL\Utils\Microplate\Scalars;
4+
5+
use MLL\GraphQLScalars\IntRange;
6+
7+
class Column2 extends IntRange
8+
{
9+
public ?string $description = 'Represents a column in a coordinate system with 2 columns. Allowed values range from 1-2.';
10+
11+
protected static function min(): int
12+
{
13+
return 1;
14+
}
15+
16+
protected static function max(): int
17+
{
18+
return 2;
19+
}
20+
}

src/Microplate/Scalars/Column96Well.php

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/Microplate/Scalars/Row16.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace MLL\Utils\Microplate\Scalars;
4+
5+
use MLL\GraphQLScalars\Regex;
6+
7+
class Row16 extends Regex
8+
{
9+
public ?string $description = 'Represents a row in a coordinate system with 16 rows. Allowed values range from A-P.';
10+
11+
public static function regex(): string
12+
{
13+
return '/^[A-P]$/';
14+
}
15+
}

src/Microplate/Scalars/Row96Well.php renamed to src/Microplate/Scalars/Row8.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
use MLL\GraphQLScalars\Regex;
66

7-
class Row96Well extends Regex
7+
class Row8 extends Regex
88
{
9-
public ?string $description = 'Checks if the given row is of the format 96-well row';
9+
public ?string $description = 'Represents a row in a coordinate system with 8 rows. Allowed values range from A-H.';
1010

1111
public static function regex(): string
1212
{

tests/Microplate/CoordinateSystemTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use MLL\Utils\Microplate\CoordinateSystem;
66
use MLL\Utils\Microplate\CoordinateSystem12Well;
7+
use MLL\Utils\Microplate\CoordinateSystem2x16;
78
use MLL\Utils\Microplate\CoordinateSystem48Well;
89
use MLL\Utils\Microplate\CoordinateSystem96Well;
910
use PHPUnit\Framework\Attributes\DataProvider;
@@ -30,12 +31,14 @@ public static function firstLast(): iterable
3031
yield [new CoordinateSystem12Well(), 'A1', 'C4'];
3132
yield [new CoordinateSystem48Well(), 'A1', 'F8'];
3233
yield [new CoordinateSystem96Well(), 'A1', 'H12'];
34+
yield [new CoordinateSystem2x16(), 'A1', 'P2'];
3335
}
3436

3537
public function testPositionsCount(): void
3638
{
3739
self::assertSame(CoordinateSystem12Well::POSITIONS_COUNT, (new CoordinateSystem12Well())->positionsCount());
3840
self::assertSame(CoordinateSystem48Well::POSITIONS_COUNT, (new CoordinateSystem48Well())->positionsCount());
3941
self::assertSame(CoordinateSystem96Well::POSITIONS_COUNT, (new CoordinateSystem96Well())->positionsCount());
42+
self::assertSame(CoordinateSystem2x16::POSITIONS_COUNT, (new CoordinateSystem2x16())->positionsCount());
4043
}
4144
}

0 commit comments

Comments
 (0)