generated from spawnia/php-package-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
525 additions
and
344 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace MLL\Utils\Tecan\Rack; | ||
|
||
class AlublockA extends BaseRack | ||
{ | ||
public function type(): string | ||
{ | ||
return 'Eppis 24x0.5 ml Cooled'; | ||
} | ||
|
||
public function name(): string | ||
{ | ||
return 'A'; | ||
} | ||
|
||
public function positionCount(): int | ||
{ | ||
return 24; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace MLL\Utils\Tecan\Rack; | ||
|
||
use Illuminate\Support\Collection; | ||
|
||
abstract class BaseRack implements Rack | ||
{ | ||
public const EMPTY_POSITION = null; | ||
|
||
/** @var Collection<int, mixed> */ | ||
public Collection $positions; | ||
|
||
public function __construct() | ||
{ | ||
$this->positions = Collection::times($this->positionCount(), fn () => self::EMPTY_POSITION) | ||
->mapWithKeys(fn ($content, int $position): array => [$position + 1 => $content]); | ||
} | ||
|
||
public function id(): ?string | ||
{ | ||
return null; | ||
} | ||
|
||
public function toString(): string | ||
{ | ||
return implode(';', [ | ||
$this->name(), | ||
$this->id(), | ||
$this->type(), | ||
]); | ||
} | ||
|
||
/** @param mixed $content Anything goes, null is considered empty */ | ||
public function assignFirstEmptyPosition($content): int | ||
{ | ||
return $this->assignPosition($content, $this->findFirstEmptyPosition()); | ||
} | ||
|
||
/** @param mixed $content Anything goes, null is considered empty */ | ||
public function assignLastEmptyPosition($content): int | ||
{ | ||
return $this->assignPosition($content, $this->findLastEmptyPosition()); | ||
} | ||
|
||
public function findFirstEmptyPosition(): int | ||
{ | ||
$firstEmpty = $this->positions | ||
->filter(fn ($content): bool => $content === self::EMPTY_POSITION) | ||
->keys() | ||
->first(); | ||
|
||
if ($firstEmpty === null) { | ||
throw new NoEmptyPositionOnRack(); | ||
} | ||
|
||
return $firstEmpty; | ||
} | ||
|
||
public function findLastEmptyPosition(): int | ||
{ | ||
$lastEmpty = $this->positions | ||
->filter(fn ($content): bool => $content === self::EMPTY_POSITION) | ||
->keys() | ||
->last(); | ||
|
||
if ($lastEmpty === null) { | ||
throw new NoEmptyPositionOnRack(); | ||
} | ||
|
||
return $lastEmpty; | ||
} | ||
|
||
/** @param mixed $content Anything goes, null is considered empty */ | ||
public function assignPosition($content, int $position): int | ||
{ | ||
if (! $this->positions->has($position)) { | ||
throw new InvalidPositionOnRack($position, $this); | ||
} | ||
|
||
$this->positions[$position] = $content; | ||
|
||
return $position; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace MLL\Utils\Tecan\Rack; | ||
|
||
class DestLC extends BaseRack | ||
{ | ||
public function type(): string | ||
{ | ||
return '96 Well MP LightCycler480'; | ||
} | ||
|
||
public function name(): string | ||
{ | ||
return 'DestLC'; | ||
} | ||
|
||
public function positionCount(): int | ||
{ | ||
return 96; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace MLL\Utils\Tecan\Rack; | ||
|
||
class DestPCR extends BaseRack | ||
{ | ||
public function type(): string | ||
{ | ||
return '96 Well PCR ABI semi-skirted'; | ||
} | ||
|
||
public function name(): string | ||
{ | ||
return 'DestPCR'; | ||
} | ||
|
||
public function positionCount(): int | ||
{ | ||
return 96; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace MLL\Utils\Tecan\Rack; | ||
|
||
class DestTaqMan extends BaseRack | ||
{ | ||
public function type(): string | ||
{ | ||
return '96 Well PCR TaqMan'; | ||
} | ||
|
||
public function name(): string | ||
{ | ||
return 'DestTaqMan'; | ||
} | ||
|
||
public function positionCount(): int | ||
{ | ||
return 96; | ||
} | ||
} |
Oops, something went wrong.