20250818 v1.0.2-b1

This commit is contained in:
2025-08-18 17:58:38 +03:00
parent 6940e9107d
commit 670d226309
4 changed files with 893 additions and 42 deletions

View File

@@ -53,7 +53,11 @@
*/
private static function FindAttribute (array $attrs, string $className): ?object
{
return array_find($attrs, fn ($attr) => $attr->getName() === $className);
// Получаю атрибут
$attr = array_find($attrs, fn ($attr) => $attr->getName() === $className);
// Возвращаю
return $attr?->newInstance();
}
/**
@@ -108,8 +112,10 @@
// - если поле игнорируется
$isIgnore = $ignoreAttr !== null
&& $ignoreAttr->IgnoredOperations->IsExist(fn (DBOperation $oper)
=> $oper == $operation);
&& $ignoreAttr->IgnoredOperations->IsExist(
fn (DBOperation $oper)
=> $oper == $operation
);
/**
* Получаю значение имени поля
@@ -119,7 +125,7 @@
$fieldNameAttr = self::FindAttribute($attributes, FieldName::class);
// Если есть атрибут имени поля, то беру его имя, иначе беру имя свойства
$fieldName = $fieldNameAttr !== null ? $fieldNameAttr->FieldName : "";
$fieldName = $fieldNameAttr !== null ? $fieldNameAttr->FieldName : $key;
/**
* Преобразование типа.
@@ -230,13 +236,17 @@
$isAutoIncrement = $aiAttr !== null;
// - создаю заголовок
$columnHeader = new DataBaseColumn($fieldName, $dataType, $isNotNull, $isUnique, $isPrimary,
$foreignWith, $checkFunc, $default, $isAutoIncrement);
$columnHeader = new DataBaseColumn(
$fieldName, $dataType, $isNotNull, $isUnique, $isPrimary,
$foreignWith, $checkFunc, $default, $isAutoIncrement
);
// - создаю объект свойства
$item = new DBItemProperty($key, $value, $columnHeader, $isIgnore, $converterToDB,
$converterFromDB, $compareFunc);
$item = new DBItemProperty(
$key, $value, $columnHeader, $isIgnore, $converterToDB,
$converterFromDB, $compareFunc
);
// - добавляю в массив
$result[] = $item;
@@ -276,7 +286,7 @@
*
* @return array|false Подготовленный массив параметров или false в случае ошибки
*/
private function PrepareParamsArray (IDBItem $source, DBOperation $operation): array|false
private function PrepareParamsArray (IDBItem $source, DBOperation $operation): array | false
{
$result = [];
@@ -408,36 +418,38 @@
*/
private function PrepareColumn (array $columns): array
{
return array_map(function ($item)
{
// Результирующая строка
$result = "";
// Если длинна строки > 0
if (strlen($item) > 0) {
// - первый символ
$firstLetter = substr($item, 0, 1);
return array_map(
function ($item)
{
// Результирующая строка
$result = "";
// - последний символ
$lastLetter = substr($item, -1);
// Если длинна строки > 0
if (strlen($item) > 0) {
// - первый символ
$firstLetter = substr($item, 0, 1);
// - последний символ
$lastLetter = substr($item, -1);
// - если первый символ не $this->DBSignOpen
if ($firstLetter !== $this->DBSignOpen)
// -- то добавляем
$result .= $this->DBSignOpen;
// - добавляем строку
$result .= $item;
// - если последний символ не $this->DBSignClose
if ($lastLetter !== $this->DBSignClose)
// -- то добавляем
$result .= $this->DBSignClose;
}
// - если первый символ не $this->DBSignOpen
if ($firstLetter !== $this->DBSignOpen)
// -- то добавляем
$result .= $this->DBSignOpen;
// - добавляем строку
$result .= $item;
// - если последний символ не $this->DBSignClose
if ($lastLetter !== $this->DBSignClose)
// -- то добавляем
$result .= $this->DBSignClose;
}
// Возвращаем результат
return $result;
}, $columns);
// Возвращаем результат
return $result;
}, $columns
);
}
/**