<?php
namespace nur\sery\wip\schema\types;

use nur\sery\wip\schema\Result;
use nur\sery\wip\schema\Schema;

class tpkey extends _tsimple {
  static function ensure_pkey(&$pkey): void {
    if (!is_string($pkey) && !is_int($pkey) && !is_array($pkey)) $pkey = strval($pkey);
    if (is_array($pkey)) {
      foreach ($pkey as &$key) {
        tkey::ensure_key($key);
      };
      unset($key);
    }
  }

  static function ensure_npkey(&$pkey): void {
    if ($pkey !== null) self::ensure_pkey($pkey);
  }

  function isValid($value, ?bool &$normalized=null): bool {
    $normalized = is_string($value) || is_int($value) || is_array($value);
    return is_scalar($value) || is_array($value);
  }

  function verifix(&$value, Result &$result, Schema $schema): bool {
  }

  function format($value, $format=null): string {
  }
}
