Skip to content

Commit

Permalink
some renamings and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Lisa Fischer committed Sep 11, 2024
1 parent ecba2e7 commit 1e49169
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 118 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace MLL\Utils\Microplate;

class CoordinateSystem2x16Well extends CoordinateSystem
class CoordinateSystem2x16 extends CoordinateSystem
{
/** Duplicates @see CoordinateSystem::positionsCount() for static contexts. */
public const POSITIONS_COUNT = 32;
Expand Down
57 changes: 0 additions & 57 deletions src/Microplate/Scalars/AbstractColumnWell.php

This file was deleted.

12 changes: 0 additions & 12 deletions src/Microplate/Scalars/AbstractRowWell.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@

namespace MLL\Utils\Microplate\Scalars;

class Column96Well extends AbstractColumnWell
use MLL\GraphQLScalars\IntRange;

class Column12 extends IntRange
{
public const MAX_INT = 12;
public const MIN_INT = 1;

public function maxInt(): int
protected static function max(): int
{
return self::MAX_INT;
}

public function minInt(): int
protected static function min(): int
{
return self::MIN_INT;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@

namespace MLL\Utils\Microplate\Scalars;

class Column2x16Well extends AbstractColumnWell
use MLL\GraphQLScalars\IntRange;

class Column2 extends IntRange
{
public const MAX_INT = 2;
public const MIN_INT = 1;

public ?string $description = 'Checks if the given column is of the format 2x16-well column';

public function maxInt(): int
protected static function min(): int
{
return self::MAX_INT;
return self::MIN_INT;
}

public function minInt(): int
protected static function max(): int
{
return self::MIN_INT;
return self::MAX_INT;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

namespace MLL\Utils\Microplate\Scalars;

class Row2x16Well extends AbstractRowWell
use MLL\GraphQLScalars\Regex;

class Row16 extends Regex
{
public ?string $description = 'Checks if the given row is of the format 2x16-well row';
public ?string $description = 'Checks if the given row is of the format A-P-well row';

public static function regex(): string
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

namespace MLL\Utils\Microplate\Scalars;

class Row96Well extends AbstractRowWell
use MLL\GraphQLScalars\Regex;

class Row8 extends Regex
{
public ?string $description = 'Checks if the given row is of the format 96-well row';
public ?string $description = 'Checks if the given row is of the format A-H-well row';

public static function regex(): string
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Microplate/CoordinateSystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use MLL\Utils\Microplate\CoordinateSystem;
use MLL\Utils\Microplate\CoordinateSystem12Well;
use MLL\Utils\Microplate\CoordinateSystem2x16Well;
use MLL\Utils\Microplate\CoordinateSystem2x16;
use MLL\Utils\Microplate\CoordinateSystem48Well;
use MLL\Utils\Microplate\CoordinateSystem96Well;
use PHPUnit\Framework\Attributes\DataProvider;
Expand All @@ -31,14 +31,14 @@ public static function firstLast(): iterable
yield [new CoordinateSystem12Well(), 'A1', 'C4'];
yield [new CoordinateSystem48Well(), 'A1', 'F8'];
yield [new CoordinateSystem96Well(), 'A1', 'H12'];
yield [new CoordinateSystem2x16Well(), 'A1', 'B16'];
yield [new CoordinateSystem2x16(), 'A1', 'B16'];
}

public function testPositionsCount(): void
{
self::assertSame(CoordinateSystem12Well::POSITIONS_COUNT, (new CoordinateSystem12Well())->positionsCount());
self::assertSame(CoordinateSystem48Well::POSITIONS_COUNT, (new CoordinateSystem48Well())->positionsCount());
self::assertSame(CoordinateSystem96Well::POSITIONS_COUNT, (new CoordinateSystem96Well())->positionsCount());
self::assertSame(CoordinateSystem2x16Well::POSITIONS_COUNT, (new CoordinateSystem2x16Well())->positionsCount());
self::assertSame(CoordinateSystem2x16::POSITIONS_COUNT, (new CoordinateSystem2x16())->positionsCount());
}
}
14 changes: 7 additions & 7 deletions tests/Microplate/CoordinatesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use MLL\Utils\Microplate\Coordinates;
use MLL\Utils\Microplate\CoordinateSystem;
use MLL\Utils\Microplate\CoordinateSystem12Well;
use MLL\Utils\Microplate\CoordinateSystem2x16Well;
use MLL\Utils\Microplate\CoordinateSystem2x16;
use MLL\Utils\Microplate\CoordinateSystem48Well;
use MLL\Utils\Microplate\CoordinateSystem96Well;
use MLL\Utils\Microplate\Enums\FlowDirection;
Expand Down Expand Up @@ -109,7 +109,7 @@ public static function dataProviderPaddedWells(): array
['paddedCoordinates' => 'H12', 'row' => 'H', 'column' => 12,],
['paddedCoordinates' => 'D10','row' => 'D','column' => 10,],
],],
'2x16Wells' => [ new CoordinateSystem2x16Well(), [
'2x16Wells' => [ new CoordinateSystem2x16(), [
['paddedCoordinates' => 'A1', 'row' => 'A', 'column' => 1,],
['paddedCoordinates' => 'B2','row' => 'B','column' => 2,],
['paddedCoordinates' => 'M1', 'row' => 'M', 'column' => 1,],
Expand All @@ -130,7 +130,7 @@ public static function dataProviderWells(): array
'12Wells' => [ new CoordinateSystem12Well(), self::data12Wells(),],
'48ells' => [ new CoordinateSystem48Well(), self::data48Wells(),],
'96Wells' => [ new CoordinateSystem96Well(), self::data96Wells(),],
'2x16Wells' => [ new CoordinateSystem2x16Well(), self::data2x16Wells(),],
'2x16Wells' => [ new CoordinateSystem2x16(), self::data2x16Wells(),],
];
}

Expand All @@ -151,7 +151,7 @@ public static function invalidRowsOrColumns(): iterable
'12Wells' => [new CoordinateSystem12Well(), [['X', 2], ['B', 0], ['B', 4], ['B', -1], ['B', 1000],['rolf', 2], ['D', 1]]],
'48Wells' => [new CoordinateSystem48Well(), [['X', 2], ['B', 0], ['B', 4], ['B', -1], ['B', 1000],['rolf', 2], ['G', 1]]],
'96Wells' => [new CoordinateSystem96Well(), [['X', 2], ['B', 0], ['B', 13], ['B', -1], ['B', 1000],['rolf', 2]]],
'2x16Wells' => [new CoordinateSystem2x16Well(), [['X', 2], ['B', 0], ['B', 3], ['B', -1], ['B', 1000],['rolf', 2]]],
'2x16Wells' => [new CoordinateSystem2x16(), [['X', 2], ['B', 0], ['B', 3], ['B', -1], ['B', 1000],['rolf', 2]]],
];
}

Expand All @@ -172,7 +172,7 @@ public static function invalidPositions(): iterable
'12Wells' => [new CoordinateSystem12Well(), [0, -1, 13, 10000,]],
'48Wells' => [new CoordinateSystem48Well(), [0, -1, 49, 10000,]],
'96Wells' => [new CoordinateSystem96Well(), [0, -1, 97, 10000,]],
'2x16Wells' => [new CoordinateSystem2x16Well(), [0, -1, 33, 10000,]],
'2x16Wells' => [new CoordinateSystem2x16(), [0, -1, 33, 10000,]],
];
}

Expand All @@ -190,10 +190,10 @@ public function testThrowsOnInvalidCoordinates(CoordinateSystem $coordinateSyste
public static function invalidCoordinates(): array
{
return [
'12Wells' => [new CoordinateSystem2x16Well(), ['A0', 'A01', 'D3', 'C5', 'rolf', 'a1']],
'12Wells' => [new CoordinateSystem2x16(), ['A0', 'A01', 'D3', 'C5', 'rolf', 'a1']],
'48Wells' => [new CoordinateSystem48Well(), ['A0', 'A01', 'G3', 'C9', 'rolf', 'a1']],
'96Wells' => [new CoordinateSystem96Well(), ['A0', 'A001', 'X3', 'rolf', 'a1']],
'2x16Wells' => [new CoordinateSystem2x16Well(), ['A0', 'A01', 'X3', 'rolf', 'a1']],
'2x16Wells' => [new CoordinateSystem2x16(), ['A0', 'A01', 'X3', 'rolf', 'a1']],
];
}

Expand Down
12 changes: 6 additions & 6 deletions tests/Microplate/Scalars/Column2x16WellTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use GraphQL\Error\Error;
use GraphQL\Type\Definition\ScalarType;
use MLL\Utils\Microplate\Scalars\Column2x16Well;
use MLL\Utils\Microplate\Scalars\Column2;
use PHPUnit\Framework\TestCase;

final class Column2x16WellTest extends TestCase
Expand All @@ -23,20 +23,20 @@ public function testSerializeThrowsIfColumn2x16WellIsNotAnInt(): void
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Value not in range: "3".');

(new Column2x16Well())->serialize('3');
(new Column2())->serialize('3');
}

public function testSerializeThrowsIfColumn2x16WellIsInvalid(): void
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Value not in range: 3.');

(new Column2x16Well())->serialize(3);
(new Column2())->serialize(3);
}

public function testSerializePassesWhenColumn2x16WellIsValid(): void
{
$serializedResult = (new Column2x16Well())->serialize(2);
$serializedResult = (new Column2())->serialize(2);

self::assertSame(2, $serializedResult);
}
Expand All @@ -46,14 +46,14 @@ public function testParseValueThrowsIfColumn2x16WellIsInvalid(): void
$this->expectException(Error::class);
$this->expectExceptionMessage('Value not in range: 3.');

(new Column2x16Well())->parseValue(3);
(new Column2())->parseValue(3);
}

public function testParseValuePassesIfColumn2x16WellIsValid(): void
{
self::assertSame(
2,
(new Column2x16Well())->parseValue(2)
(new Column2())->parseValue(2)
);
}
}
12 changes: 6 additions & 6 deletions tests/Microplate/Scalars/Column96WellTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use GraphQL\Error\Error;
use GraphQL\Type\Definition\ScalarType;
use MLL\Utils\Microplate\Scalars\Column96Well;
use MLL\Utils\Microplate\Scalars\Column12;
use PHPUnit\Framework\TestCase;

final class Column96WellTest extends TestCase
Expand All @@ -23,20 +23,20 @@ public function testSerializeThrowsIfColumn96WellIsNotAnInt(): void
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Value not in range: "12".');

(new Column96Well())->serialize('12');
(new Column12())->serialize('12');
}

public function testSerializeThrowsIfColumn96WellIsInvalid(): void
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Value not in range: 13.');

(new Column96Well())->serialize(13);
(new Column12())->serialize(13);
}

public function testSerializePassesWhenColumn96WellIsValid(): void
{
$serializedResult = (new Column96Well())->serialize(12);
$serializedResult = (new Column12())->serialize(12);

self::assertSame(12, $serializedResult);
}
Expand All @@ -46,14 +46,14 @@ public function testParseValueThrowsIfColumn96WellIsInvalid(): void
$this->expectException(Error::class);
$this->expectExceptionMessage('Value not in range: 13.');

(new Column96Well())->parseValue(13);
(new Column12())->parseValue(13);
}

public function testParseValuePassesIfColumn96WellIsValid(): void
{
self::assertSame(
12,
(new Column96Well())->parseValue(12)
(new Column12())->parseValue(12)
);
}
}
Loading

0 comments on commit 1e49169

Please sign in to comment.