Skip to content

Commit fe90662

Browse files
authored
Offer unified coordinate system classes, deprecate naming by count
1 parent bb90d32 commit fe90662

34 files changed

+304
-266
lines changed

CHANGELOG.md

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

1010
## Unreleased
1111

12+
## v5.2.0
13+
14+
### Added
15+
16+
- Add coordinate systems `CoordinateSystem4x3`, `CoordinateSystem8x6` and `CoordinateSystem12x8`
17+
18+
### Changed
19+
20+
- Deprecate coordinate systems `CoordinateSystem12Well`, `CoordinateSytem48Well` and `CoordinateSystem96Well`
21+
1222
## v5.1.0
1323

1424
### Added

src/FluidXPlate/FluidXPlate.php

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

55
use Illuminate\Support\Collection;
66
use MLL\Utils\Microplate\Coordinates;
7-
use MLL\Utils\Microplate\CoordinateSystem96Well;
7+
use MLL\Utils\Microplate\CoordinateSystem12x8;
88
use MLL\Utils\Microplate\Enums\FlowDirection;
99
use MLL\Utils\Microplate\Microplate;
1010

@@ -15,7 +15,7 @@ class FluidXPlate
1515

1616
public string $rackID;
1717

18-
/** @var Microplate<string, CoordinateSystem96Well> */
18+
/** @var Microplate<string, CoordinateSystem12x8> */
1919
private Microplate $microplate;
2020

2121
public function __construct(string $rackID)
@@ -27,12 +27,12 @@ public function __construct(string $rackID)
2727
$this->microplate = new Microplate(self::coordinateSystem());
2828
}
2929

30-
public static function coordinateSystem(): CoordinateSystem96Well
30+
public static function coordinateSystem(): CoordinateSystem12x8
3131
{
32-
return new CoordinateSystem96Well();
32+
return new CoordinateSystem12x8();
3333
}
3434

35-
/** @param Coordinates<CoordinateSystem96Well> $coordinates */
35+
/** @param Coordinates<CoordinateSystem12x8> $coordinates */
3636
public function addWell(Coordinates $coordinates, string $barcode): void
3737
{
3838
if (\Safe\preg_match(self::FLUIDX_BARCODE_REGEX, $barcode) === 0) {
@@ -42,7 +42,7 @@ public function addWell(Coordinates $coordinates, string $barcode): void
4242
$this->microplate->addWell($coordinates, $barcode);
4343
}
4444

45-
/** @return Coordinates<CoordinateSystem96Well> */
45+
/** @return Coordinates<CoordinateSystem12x8> */
4646
public function addToNextFreeWell(string $content, FlowDirection $flowDirection): Coordinates
4747
{
4848
return $this->microplate->addToNextFreeWell($content, $flowDirection);

src/FluidXPlate/FluidXScanner.php

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

55
use Illuminate\Support\Str;
66
use MLL\Utils\Microplate\Coordinates;
7-
use MLL\Utils\Microplate\CoordinateSystem96Well;
87
use MLL\Utils\StringUtil;
98

109
/** Communicates with a FluidX scanner device and fetches results from it. */
@@ -87,8 +86,9 @@ public static function parseRawContent(string $rawContent): FluidXPlate
8786
}
8887

8988
$plate = new FluidXPlate($id);
89+
$coordinateSystem = FluidXPlate::coordinateSystem();
9090
foreach ($barcodes as $coordinates => $barcode) {
91-
$plate->addWell(Coordinates::fromString($coordinates, new CoordinateSystem96Well()), $barcode);
91+
$plate->addWell(Coordinates::fromString($coordinates, $coordinateSystem), $barcode);
9292
}
9393

9494
return $plate;

src/Microplate/CoordinateSystem.php

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

55
use Illuminate\Support\Arr;
66

7+
/**
8+
* Children should be called `CoordinateSystemXxY`, where X is the number of columns and Y is the number of rows.
9+
* Naming them by the number of positions is insufficient, e.g. it does not allow distinguishing between 3x4 and 4x3.
10+
*/
711
abstract class CoordinateSystem
812
{
913
/** @return list<string> */

src/Microplate/CoordinateSystem12Well.php

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,5 @@
22

33
namespace MLL\Utils\Microplate;
44

5-
class CoordinateSystem12Well extends CoordinateSystem
6-
{
7-
/** Duplicates @see CoordinateSystem::positionsCount() for static contexts. */
8-
public const POSITIONS_COUNT = 12;
9-
10-
public function rows(): array
11-
{
12-
return range('A', 'C');
13-
}
14-
15-
public function columns(): array
16-
{
17-
return range(1, 4);
18-
}
19-
}
5+
/** @deprecated use CoordinateSystem4x3 */
6+
class CoordinateSystem12Well extends CoordinateSystem4x3 {}
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 CoordinateSystem12x8 extends CoordinateSystem
6+
{
7+
/** Duplicates @see CoordinateSystem::positionsCount() for static contexts. */
8+
public const POSITIONS_COUNT = 96;
9+
10+
public function rows(): array
11+
{
12+
return range('A', 'H');
13+
}
14+
15+
public function columns(): array
16+
{
17+
return range(1, 12);
18+
}
19+
}

src/Microplate/CoordinateSystem48Well.php

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,5 @@
22

33
namespace MLL\Utils\Microplate;
44

5-
class CoordinateSystem48Well extends CoordinateSystem
6-
{
7-
/** Duplicates @see CoordinateSystem::positionsCount() for static contexts. */
8-
public const POSITIONS_COUNT = 48;
9-
10-
public function rows(): array
11-
{
12-
return range('A', 'F');
13-
}
14-
15-
public function columns(): array
16-
{
17-
return range(1, 8);
18-
}
19-
}
5+
/** @deprecated use CoordinateSystem8x6 */
6+
class CoordinateSystem48Well extends CoordinateSystem8x6 {}
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 CoordinateSystem4x3 extends CoordinateSystem
6+
{
7+
/** Duplicates @see CoordinateSystem::positionsCount() for static contexts. */
8+
public const POSITIONS_COUNT = 12;
9+
10+
public function rows(): array
11+
{
12+
return range('A', 'C');
13+
}
14+
15+
public function columns(): array
16+
{
17+
return range(1, 4);
18+
}
19+
}
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 CoordinateSystem8x6 extends CoordinateSystem
6+
{
7+
/** Duplicates @see CoordinateSystem::positionsCount() for static contexts. */
8+
public const POSITIONS_COUNT = 48;
9+
10+
public function rows(): array
11+
{
12+
return range('A', 'F');
13+
}
14+
15+
public function columns(): array
16+
{
17+
return range(1, 8);
18+
}
19+
}

src/Microplate/CoordinateSystem96Well.php

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,5 @@
22

33
namespace MLL\Utils\Microplate;
44

5-
class CoordinateSystem96Well extends CoordinateSystem
6-
{
7-
/** Duplicates @see CoordinateSystem::positionsCount() for static contexts. */
8-
public const POSITIONS_COUNT = 96;
9-
10-
public function rows(): array
11-
{
12-
return range('A', 'H');
13-
}
14-
15-
public function columns(): array
16-
{
17-
return range(1, 12);
18-
}
19-
}
5+
/** @deprecated use CoordinateSystem12x8 */
6+
class CoordinateSystem96Well extends CoordinateSystem12x8 {}

0 commit comments

Comments
 (0)