nur-sery/nur_src/b/coll/TArrayMd.php

28 lines
733 B
PHP
Raw Normal View History

2023-12-03 22:10:18 +04:00
<?php
namespace nur\b\coll;
use nur\data\types\md_utils;
use nur\data\types\Metadata;
/**
* Trait TArrayMd: à utiliser avec {@link TAutoconstsStatic}
*/
trait TArrayMd {
protected static function _ensure_md(?Metadata &$md, ?array $schema, ?string $cache_key=null): ?Metadata {
if ($schema === null) return null;
return md_utils::ensure_md($md, $schema);
}
protected static function _ensure_md_func(?Metadata &$md, ?callable $get_md, ?string $cache_key=null): ?Metadata {
if ($get_md === null) return null;
return md_utils::ensure_md_func($md, $get_md);
}
/** @var Metadata */
private static $md;
protected function md(): ?Metadata {
return self::_ensure_md(self::$md, static::SCHEMA);
}
}