Add some tests + phpdoc

This commit is contained in:
2024-12-23 22:19:37 +01:00
parent 3996272cec
commit 623b939df1
9 changed files with 71 additions and 5 deletions

View File

@@ -19,6 +19,8 @@ class Fits
public readonly string $imageBlob;
/**
* Construct a Fits object
* @param string $path The full path to the FITS file
* @throws InvalidFits, InvalidPath
* @todo Check path for reading/writing errors
*/
@@ -36,6 +38,7 @@ class Fits
}
$this->headerBlock = $this->extractHeader();
$this->fitsHeader = new FitsHeader($this->headerBlock);
$this->imageBlob = $this->extractImageBlob();
}
@@ -67,6 +70,7 @@ class Fits
*/
private function extractHeader(): string
{
$end = strpos($this->contents, 'END');
// Determine minimum integer number of blocks including 'END' position
$headerEnd = (($end - ($end % 2880)) / 2880 + 1) * 2880;

View File

@@ -45,8 +45,10 @@ class FitsHeader
foreach ($filtered as $record) {
$splitByComment = explode('/', $record);
$comment = isset($splitByComment[1]) ? $splitByComment[1] : null;
[$name, $value] = explode('=', $splitByComment[0]);
$comment = $splitByComment[1] ?? null;
$keyVal = explode('=', $splitByComment[0]);
$name = $keyVal[0];
$value = $keyVal[1] ?? '';
$keywords[] = new Keyword(
name : $name,
@@ -72,7 +74,7 @@ class FitsHeader
return $keywordsString . $blanks;
}
/**
* Retrieve a Keyword object base on key name
* Retrieve a Keyword object based on key name
*/
public function keyword(string $key): ?Keyword
{

View File

@@ -12,7 +12,7 @@ readonly class Keyword
{
public function __construct(
public string $name,
public string $value,
public ?string $value,
public ?string $comment,
) {}