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();
- Read upRead up
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];
- Read upRead up
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');
- Read upRead up
- Exclude checks
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'));
- Read upRead up
- Exclude checks
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) {
- Exclude checks
Checking instanceof against undeclared class \Psr\Cache\CacheItemPoolInterface
Open
if ($cache instanceof Psr6) {
- Exclude checks
Checking instanceof against undeclared class \Psr\Cache\CacheItemPoolInterface
Open
if (!$cache instanceof Psr16 && !$cache instanceof Psr6) {
- Exclude checks
Checking instanceof against undeclared class \Psr\SimpleCache\CacheInterface
Open
if ($cache instanceof Psr16) {
- Exclude checks
Checking instanceof against undeclared class \Psr\SimpleCache\CacheInterface
Open
if (!$cache instanceof Psr16 && !$cache instanceof Psr6) {
- Exclude checks
Checking instanceof against undeclared class \Psr\Cache\CacheItemPoolInterface
Open
if ($cache instanceof Psr6) {
- Exclude checks
The property $_serviceContainer is not named in camelCase. Open
class Schema
{
const CURRENT_VERSION = 9;
// Singleton
- Read upRead up
- Exclude checks
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 = [];
- Exclude checks
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
- Exclude checks