modifs.mineures sans commentaires

This commit is contained in:
Jephté Clain 2023-11-25 10:05:01 +04:00
parent ad739c5e44
commit b299fc8139
1 changed files with 0 additions and 41 deletions

View File

@ -1,13 +1,6 @@
<?php
namespace nur\sery\schema;
use nur\sery\schema\input\Input;
use nur\sery\schema\values\AssocValue;
use nur\sery\schema\values\IValue;
use nur\sery\schema\values\ScalarValue;
use nur\sery\schema\values\ListValue;
use nulib\StateException;
class OldSchema {
/**
* @var bool true si toutes les clés du schéma doivent exister, avec leur
@ -26,38 +19,4 @@ class OldSchema {
function ensureSchema(&$value, $key=null, ?array $params=null): void {
}
/** retourner true si la valeur est scalaire */
function getScalar(&$value, $key=null, ?ScalarValue &$scalar=null): bool {
if (!$this->isScalar()) return false;
if ($value instanceof Input) $input = $value;
else $input = new Input($value);
$scalar = new ScalarValue($input, $this->schema, $key);
return true;
}
/** retourner true la valeur est un tableau séquentiel */
function getList(&$value, $key=null, ?ListValue &$list=null): bool {
if (!$this->isSeq()) return false;
if ($value instanceof Input) $input = $value;
else $input = new Input($value);
$list = new ListValue($input, $this->schema, $key);
return true;
}
/** retourner true la valeur est un tableau associatif */
function getAssoc(&$value, $key=null, ?AssocValue &$assoc=null): bool {
if (!$this->isAssoc()) return false;
if ($value instanceof Input) $input = $value;
else $input = new Input($value);
$assoc = new AssocValue($input, $this->schema, $key);
return true;
}
function getValue(&$value, $key=null): IValue {
if ($this->getScalar($value, $key, $scalar)) return $scalar;
elseif ($this->getList($value, $key, $seq)) return $seq;
elseif ($this->getAssoc($value, $key, $assoc)) return $assoc;
else throw StateException::unexpected_state();
}
}