public function __construct($state, $data)
{
//if (true) {
if (!$state || is_string($state)) {
$state = new stdClass();
foreach (['current', 'previous'] as $reference) {
$state->{$reference} = new stdClass();
$state->{$reference}->entityType = false;
foreach ([ENTITY_INVOICE, ENTITY_CLIENT, ENTITY_INVOICE_ITEM] as $entityType) {
$state->{$reference}->{$entityType} = [];
}
}
}
$this->state = $state;
$this->data = $data;
//var_dump($state);
}