File Migration.php
has 417 lines of code (exceeds 250 allowed). Consider refactoring.
<?php
declare(strict_types=1);
namespace atk4\schema;
Function setDb
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
public function setDb($db_data, $import_data = true)
{
$this->tables = array_keys($db_data);
Migration
has 32 functions (exceeds 20 allowed). Consider refactoring.
abstract class Migration extends Expression
{
public const REF_TYPE_NONE = 0;
public const REF_TYPE_LINK = 1;
public const REF_TYPE_PRIMARY = 2;
Function run
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
public function run(): string
{
$changes = $added = $altered = $dropped = 0;
Function getDb
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
public function getDb($tables = null, bool $no_id = false)
{
$tables = $tables ?: $this->tables;
if (is_string($tables)) {
Method run
has 44 lines of code (exceeds 25 allowed). Consider refactoring.
public function run(): string
{
$changes = $added = $altered = $dropped = 0;
Method setDb
has 44 lines of code (exceeds 25 allowed). Consider refactoring.
public function setDb($db_data, $import_data = true)
{
$this->tables = array_keys($db_data);
Function setModel
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
public function setModel(Model $m): Model
{
$this->table($m->table);
foreach ($m->getFields() as $field) {
Method __construct
has 36 lines of code (exceeds 25 allowed). Consider refactoring.
public function __construct($source, $params = [])
{
$this->templates['create'] = <<<'EOT'
Function _render_statements
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
public function _render_statements(): string
{
$result = [];
if (isset($this->args['dropField'])) {
Function _render_statements
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
public function _render_statements(): string
{
$result = [];
if (isset($this->args['dropField'])) {
Function createModel
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
public function createModel($persistence, $table = null): Model
{
$this['table'] = $table ?? $this['table'];
$m = new Model([$persistence, 'table' => $this['table']]);
Function getSqlFieldType
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
public function getSqlFieldType(?string $type, array $options = []): ?string
{
if ($type !== null) {
$type = strtolower($type);
}