This commit is contained in:
@@ -8,7 +8,10 @@ use InvalidArgumentException;
|
||||
|
||||
final class Nachrichtenvertrag
|
||||
{
|
||||
public const VERSION = '3.0';
|
||||
public const VERSION = '4.0';
|
||||
|
||||
public const BETRIEBSART_PV = 'PV';
|
||||
public const BETRIEBSART_PEAK = 'Peak';
|
||||
|
||||
public const LEISTUNGSQUELLE_NICHT_VORHANDEN = 0;
|
||||
public const LEISTUNGSQUELLE_BERECHNET = 1;
|
||||
@@ -19,11 +22,12 @@ final class Nachrichtenvertrag
|
||||
*/
|
||||
public static function pruefeManagerdaten(array $daten): void
|
||||
{
|
||||
self::pruefeSchluessel($daten, ['Kopf', 'Sollleistung_W'], 'Managerdaten');
|
||||
self::pruefeSchluessel($daten, ['Kopf', 'Betriebsart', 'Sollleistung_W'], 'Managerdaten');
|
||||
self::pruefeKopf($daten['Kopf']);
|
||||
self::pruefeBetriebsart($daten['Betriebsart']);
|
||||
|
||||
if (!is_int($daten['Sollleistung_W'])) {
|
||||
throw new InvalidArgumentException('Sollleistung_W muss eine Ganzzahl sein.');
|
||||
if ($daten['Sollleistung_W'] !== null && !is_int($daten['Sollleistung_W'])) {
|
||||
throw new InvalidArgumentException('Sollleistung_W muss eine Ganzzahl oder null sein.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +40,7 @@ final class Nachrichtenvertrag
|
||||
$daten,
|
||||
[
|
||||
'Kopf',
|
||||
'Betriebsart',
|
||||
'PrioritaetPV',
|
||||
'PrioritaetPeak',
|
||||
'Leistungswerte_W',
|
||||
@@ -49,6 +54,7 @@ final class Nachrichtenvertrag
|
||||
);
|
||||
|
||||
self::pruefeKopf($daten['Kopf']);
|
||||
self::pruefeBetriebsart($daten['Betriebsart']);
|
||||
self::pruefePrioritaet($daten['PrioritaetPV'], 'PrioritaetPV');
|
||||
self::pruefePrioritaet($daten['PrioritaetPeak'], 'PrioritaetPeak');
|
||||
self::pruefeLeistungswerte($daten['Leistungswerte_W']);
|
||||
@@ -93,6 +99,18 @@ final class Nachrichtenvertrag
|
||||
}
|
||||
}
|
||||
|
||||
/** @param mixed $betriebsart */
|
||||
private static function pruefeBetriebsart($betriebsart): void
|
||||
{
|
||||
if (!is_string($betriebsart) || !in_array(
|
||||
$betriebsart,
|
||||
[self::BETRIEBSART_PV, self::BETRIEBSART_PEAK],
|
||||
true
|
||||
)) {
|
||||
throw new InvalidArgumentException('Betriebsart muss PV oder Peak sein.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $prioritaet
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user