This is a major redesign of the code that handles these four actions: in-place edit(AJAX), edit of multiple rows, copying of rows, and insertion of new rows. The goal is to make the code easier to read and more understandable.
I introduced a new DTO for better readability.
Some of the methods were made private to the model
The controller has access to two methods for getting the value for INSERT and for UPDATE
Unfortunately, I have introduced method envy on EditField, but I do not want to move the functionality away from InsertEdit.php
Unit tests have not improved in readability but I added helpful comments explaining what we are testing. There's probably a way to improve it too.
I will probably merge all commits once I decide it's ready for review.
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
57 lines
1.4 KiB
PHP
57 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpMyAdmin;
|
|
|
|
/**
|
|
* @psalm-immutable
|
|
*/
|
|
final class EditField
|
|
{
|
|
/** @var string $columnName */
|
|
public $columnName;
|
|
/** @var string $value */
|
|
public $value;
|
|
/** @var string $type */
|
|
public $type;
|
|
/** @var bool $autoIncrement */
|
|
public $autoIncrement;
|
|
/** @var bool $isNull */
|
|
public $isNull;
|
|
/** @var bool $wasPreviouslyNull */
|
|
public $wasPreviouslyNull;
|
|
/** @var string $function */
|
|
public $function;
|
|
/** @var string|null $salt */
|
|
public $salt;
|
|
/** @var string|null $previousValue */
|
|
public $previousValue;
|
|
/** @var bool $isUploaded */
|
|
public $isUploaded;
|
|
|
|
public function __construct(
|
|
string $columnName,
|
|
string $value,
|
|
string $type,
|
|
bool $autoIncrement,
|
|
bool $isNull,
|
|
bool $wasPreviouslyNull,
|
|
string $function,
|
|
?string $salt,
|
|
?string $previousValue,
|
|
bool $isUploaded
|
|
) {
|
|
$this->columnName = $columnName;
|
|
$this->value = $value;
|
|
$this->type = $type;
|
|
$this->autoIncrement = $autoIncrement;
|
|
$this->isNull = $isNull;
|
|
$this->wasPreviouslyNull = $wasPreviouslyNull;
|
|
$this->function = $function;
|
|
$this->salt = $salt;
|
|
$this->previousValue = $previousValue;
|
|
$this->isUploaded = $isUploaded;
|
|
}
|
|
}
|