brokencube/automatorm

View on GitHub
src/Orm/Schema.php

Summary

Maintainability
A
1 hr
Test Coverage

Function generate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public static function generate(Connection $connection, $namespace = 'models', $cache = null) : Schema
    {
        // Get schema from cache
        if (is_null($cache)) {
            list($model, $schema) = $connection->getSchemaGenerator()->generate();
Severity: Minor
Found in src/Orm/Schema.php - About 45 mins to fix

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 guessContext has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function guessContext($classOrTable)
    {
        // Return 'cached' result
        if (isset(static::$contextCache[$classOrTable])) {
            return static::$contextCache[$classOrTable];
Severity: Minor
Found in src/Orm/Schema.php - About 35 mins to fix

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

Missing class import via use statement (line '63', column '27').
Open

                throw new \InvalidArgumentException('Supplied $cache does not implement PSR6/16 interface');
Severity: Minor
Found in src/Orm/Schema.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '51', column '34').
Open

            $item->expiresAt(new \DateTime('now + 3600 seconds'));
Severity: Minor
Found in src/Orm/Schema.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Checking instanceof against undeclared class \Psr\SimpleCache\CacheInterface
Open

        if ($cache instanceof Psr16) {
Severity: Critical
Found in src/Orm/Schema.php by phan

Checking instanceof against undeclared class \Psr\Cache\CacheItemPoolInterface
Open

        if ($cache instanceof Psr6) {
Severity: Critical
Found in src/Orm/Schema.php by phan

Checking instanceof against undeclared class \Psr\Cache\CacheItemPoolInterface
Open

            if (!$cache instanceof Psr16 && !$cache instanceof Psr6) {
Severity: Critical
Found in src/Orm/Schema.php by phan

Checking instanceof against undeclared class \Psr\SimpleCache\CacheInterface
Open

        if ($cache instanceof Psr16) {
Severity: Critical
Found in src/Orm/Schema.php by phan

Checking instanceof against undeclared class \Psr\SimpleCache\CacheInterface
Open

            if (!$cache instanceof Psr16 && !$cache instanceof Psr6) {
Severity: Critical
Found in src/Orm/Schema.php by phan

Checking instanceof against undeclared class \Psr\Cache\CacheItemPoolInterface
Open

        if ($cache instanceof Psr6) {
Severity: Critical
Found in src/Orm/Schema.php by phan

The property $_serviceContainer is not named in camelCase.
Open

class Schema
{
    const CURRENT_VERSION = 9;

    // Singleton
Severity: Minor
Found in src/Orm/Schema.php by phpmd

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

Property name "$_serviceContainer" should not be prefixed with an underscore to indicate visibility
Open

    protected $_serviceContainer = [];
Severity: Minor
Found in src/Orm/Schema.php by phpcodesniffer

Line exceeds 120 characters; contains 122 characters
Open

        // Normalise the (namespace stripped) class or table name so we don't have to worry about under_score or CamelCase
Severity: Minor
Found in src/Orm/Schema.php by phpcodesniffer

There are no issues that match your filters.

Category
Status