File Migrator.php
has 433 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
namespace Atk4\Data\Schema;
- Create a ticketCreate a ticket
Migrator
has 26 functions (exceeds 20 allowed). Consider refactoring. Open
class Migrator
{
public const REF_TYPE_NONE = 0;
public const REF_TYPE_LINK = 1;
public const REF_TYPE_PRIMARY = 2;
- Create a ticketCreate a ticket
Function drop
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function drop(bool $dropForeignKeysFirst = false): self
{
$schemaManager = $this->createSchemaManager();
if ($dropForeignKeysFirst) {
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function setModel
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function setModel(Model $model): Model
{
$this->table($model->table);
foreach ($model->getFields() as $field) {
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function isIndexExists
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function isIndexExists(array $fields, bool $requireUnique = false): bool
{
$fields = array_map(fn ($field) => $this->resolvePersistenceField($field), $fields);
$tableName = reset($fields)->getOwner()->table;
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method createForeignKey
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function createForeignKey($relation): void
{
[$localField, $foreignField] = is_array($relation)
? $relation
: $this->resolveRelationDirection($relation);
- Create a ticketCreate a ticket
Method setModel
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function setModel(Model $model): Model
{
$this->table($model->table);
foreach ($model->getFields() as $field) {
- Create a ticketCreate a ticket
Function field
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function field(string $fieldName, array $options = []): self
{
$type = $options['type'] ?? 'string';
unset($options['type']);
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function createIndex
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function createIndex(array $fields, bool $isUnique): void
{
$fields = array_map(fn ($field) => $this->resolvePersistenceField($field), $fields);
$tableName = reset($fields)->getOwner()->table;
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function stripDatabaseFromTableName
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function stripDatabaseFromTableName(string $tableName): string
{
$platform = $this->getDatabasePlatform();
$lastDotPos = strrpos($tableName, '.');
if ($lastDotPos !== false) {
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function resolveRelationDirection
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function resolveRelationDirection(object $relation): array
{
if ($relation instanceof HasOne) {
$localField = $relation->getOwner()->getField($relation->getOurFieldName());
$theirModel = $relation->createTheirModel();
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function __construct
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function __construct(object $source)
{
if ($source instanceof Connection || $source instanceof Persistence\Sql) {
$this->_connection = $source;
} elseif ($source instanceof Model && $source->getPersistence() instanceof Persistence\Sql) { // @phpstan-ignore instanceof.alwaysTrue
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"