<?php
namespace nulib\schema\_assoc;

use nulib\ref\schema\ref_schema;
use nulib\schema\_scalar\ScalarWrapper;
use nulib\schema\ConsolidatedResult;
use nulib\schema\Wrapper;
use nulib\schema\WrapperContext;

class AssocWrapperContext extends WrapperContext {

  public bool $ensureArray;
  public bool $ensureAssoc;
  public bool $ensureKeys;
  public bool $ensureOrder;

  public function resetParams(?array $params): void {
    parent::resetParams($params);
    $this->ensureArray = $params["ensure_array"] ?? ref_schema::ASSOC_PARAMS_SCHEMA["ensure_array"][1];
    $this->ensureAssoc = $params["ensure_assoc"] ?? ref_schema::ASSOC_PARAMS_SCHEMA["ensure_assoc"][1];
    $this->ensureKeys = $params["ensure_keys"] ?? ref_schema::ASSOC_PARAMS_SCHEMA["ensure_keys"][1];
    $this->ensureOrder = $params["ensure_order"] ?? ref_schema::ASSOC_PARAMS_SCHEMA["ensure_order"][1];
  }

  public ?ScalarWrapper $arrayWrapper = null;

  /** liste des clés valides */
  public array $keys;

  /** @var Wrapper[] */
  public array $keyWrappers;

  /** @var string|int|null clé sélectionnée */
  public $selectedKey = null;

  /** résultat consolidé de l'analyse du tableau et de ses composants */
  public ConsolidatedResult $consolidatedResult;
}
