Better PHP Docstring
This commit is contained in:
parent
f344ffb727
commit
6e27fc27fb
@ -5,9 +5,7 @@ namespace germanairlinesva_recording;
|
|||||||
class Recording
|
class Recording
|
||||||
{
|
{
|
||||||
private const ident = "VGAR";
|
private const ident = "VGAR";
|
||||||
|
|
||||||
private const header_unpack = "Z5ident/Cversion";
|
private const header_unpack = "Z5ident/Cversion";
|
||||||
|
|
||||||
private const segment_unpack = "Vtime/Saltitude/Sgroundspeed/elatitude/elongitude";
|
private const segment_unpack = "Vtime/Saltitude/Sgroundspeed/elatitude/elongitude";
|
||||||
|
|
||||||
private string $file_name;
|
private string $file_name;
|
||||||
@ -20,9 +18,9 @@ class Recording
|
|||||||
/**
|
/**
|
||||||
* Generates a geoJSON representation
|
* Generates a geoJSON representation
|
||||||
*
|
*
|
||||||
* @return geoJSON representation of path
|
* @return string geoJSON representation of path
|
||||||
*/
|
*/
|
||||||
public function geoJSON()
|
public function geoJSON(): string
|
||||||
{
|
{
|
||||||
$geoJSON = [
|
$geoJSON = [
|
||||||
"type" => "FeatureCollection",
|
"type" => "FeatureCollection",
|
||||||
@ -52,14 +50,14 @@ class Recording
|
|||||||
/**
|
/**
|
||||||
* Reads recording
|
* Reads recording
|
||||||
*
|
*
|
||||||
* Array of objects with
|
* @return array Fields:
|
||||||
* @return time Segment time (number)
|
* int Segment time (number) as time,
|
||||||
* @return altitude Altitude
|
* int Altitude as altitude,
|
||||||
* @return groundspeed Ground speed
|
* int Ground speed as groundspeed,
|
||||||
* @return latitude Latitude
|
* double Latitude as latitude,
|
||||||
* @return longitude Longitude
|
* double Longitude as longitude
|
||||||
*/
|
*/
|
||||||
public function read()
|
public function read(): array
|
||||||
{
|
{
|
||||||
$file = fopen($this->file_name, "rb");
|
$file = fopen($this->file_name, "rb");
|
||||||
flock($file, LOCK_SH);
|
flock($file, LOCK_SH);
|
||||||
@ -85,18 +83,18 @@ class Recording
|
|||||||
*
|
*
|
||||||
* @param resource $file File handle
|
* @param resource $file File handle
|
||||||
*
|
*
|
||||||
* If not EOF
|
* @return array if not EOF with fields:
|
||||||
* @return time Segment time (number)
|
* int Segment time (number) as time,
|
||||||
* @return altitude Altitude
|
* int Altitude as altitude,
|
||||||
* @return groundspeed Ground speed
|
* int Ground speed as groundspeed,
|
||||||
* @return latitude Latitude
|
* double Latitude as latitude,
|
||||||
* @return longitude Longitude
|
* double Longitude as longitude
|
||||||
* Else
|
*
|
||||||
* @return false
|
* @return false if EOF
|
||||||
*
|
*
|
||||||
* @throws InvalidArgumentException If file is not a resource
|
* @throws InvalidArgumentException If file is not a resource
|
||||||
*/
|
*/
|
||||||
private function read_segment_1($file)
|
private function read_segment_1($file): array | false
|
||||||
{
|
{
|
||||||
if (false === is_resource($file)) {
|
if (false === is_resource($file)) {
|
||||||
throw new \InvalidArgumentException(sprintf('Argument must be a valid resource type. %s given.', gettype($file)));
|
throw new \InvalidArgumentException(sprintf('Argument must be a valid resource type. %s given.', gettype($file)));
|
||||||
@ -111,14 +109,14 @@ class Recording
|
|||||||
/**
|
/**
|
||||||
* Reads the file header
|
* Reads the file header
|
||||||
*
|
*
|
||||||
* @param resource file File handle
|
* @param resource $file File handle
|
||||||
*
|
*
|
||||||
* @return version File version
|
* @return string File version
|
||||||
*
|
*
|
||||||
* @throws InvalidArgumentException If file is not a resource
|
* @throws InvalidArgumentException If file is not a resource
|
||||||
* @throws UnexpectedValueException If ident mismatches
|
* @throws UnexpectedValueException If ident mismatches
|
||||||
*/
|
*/
|
||||||
private function read_header($file)
|
private function read_header($file): string
|
||||||
{
|
{
|
||||||
if (false === is_resource($file)) {
|
if (false === is_resource($file)) {
|
||||||
throw new \InvalidArgumentException(sprintf('Argument must be a valid resource type. %s given.', gettype($file)));
|
throw new \InvalidArgumentException(sprintf('Argument must be a valid resource type. %s given.', gettype($file)));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user