PHP value holder objects for parse-hydrodaten and parse-swissmetnet
This simple library provides immutable typed value holder objects (DTO) with the readonly fields timestamp, location, parameter and value.
Also provides a iterable row object containing an array of values and some simple statistic methods, along with a CSV parser.
Installation: composer require cstuder/parse-valueholder
$data = new \cstuder\ParseValueholder\Value(
$timestamp,
$locationString,
$parameterString,
$value
);
echo $data->timestamp;
echo $data->location;
echo $data->parameter;
echo $data->value;
$row = new \cstuder\ParseValueholder\Row([
$value1,
$value2
]);
$row->append($value3);
foreach($row as $value) {
var_dump($value);
}
A simple CSV parser to parse CSV files without header, in the format timestamp, location, parameter, value
, i.e.:
1675281000,BER,tt,5.7
Delimiters, enclosure and escape characters are configurable.
All values are cast to float.
Parses either from a file or from a string:
$row = \cstuder\ParseValueholder\Utils\CsvParser::parseFile($filename);
$row2 = \cstuder\ParseValueholder\Utils\CsvParser::parseString("1675281000,BER,tt,5.7\n1675281600,BER,tt,5.8");
Run composer test
to execute the PHPUnit test suite.
- Add changes to the changelog.
- Create a new tag
vX.X.X
. - Push.
MIT.
Christian Studer [email protected], Bureau für digitale Existenz.