src/DataLayer/Database/Connection.php
Function __construct
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
protected function __construct($details, array $options = [], LoggerInterface $logger = null)
{
$this->schemaGenerator = new SchemaGenerator($this);
$this->dataAccess = new DataAccess($this);
$this->logger = $logger;
- 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 '149', column '23'). Open
Open
throw new \Exception('Cannot unserialise a Connection that does not contain a server address');
- 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
Suspicious attempt to unset class \Automatorm\DataLayer\Database\Connection's
property connection
declared at /code/src/DataLayer/Database/Connection.php:52
(This can be done, but is more commonly done for dynamic properties and Phan does not expect this) Open
Open
unset($this->connection);
- Exclude checks
Return type of getLogger()
is undeclared type \Psr\Log\LoggerInterface
Open
Open
public function getLogger()
- Exclude checks
Suspicious attempt to unset class \Automatorm\DataLayer\Database\Connection's
property connection
declared at /code/src/DataLayer/Database/Connection.php:52
(This can be done, but is more commonly done for dynamic properties and Phan does not expect this) Open
Open
unset($this->connection);
- Exclude checks
Parameter $logger
has undeclared type ?\Psr\Log\LoggerInterface
Open
Open
public static function registerPDO(PDO $pdo, LoggerInterface $logger = null)
- Exclude checks
Reference to undeclared property \Automatorm\DataLayer\Database\Connection->logger
(Did you mean $logger) Open
Open
$this->logger = $logger;
- Exclude checks
Parameter $logger
has undeclared type ?\Psr\Log\LoggerInterface
Open
Open
public static function register(array $db, LoggerInterface $logger = null, array $options = [])
- Exclude checks
Parameter $logger
has undeclared type ?\Psr\Log\LoggerInterface
Open
Open
protected function __construct($details, array $options = [], LoggerInterface $logger = null)
- Exclude checks
The property $unix_socket is not named in camelCase. Open
Open
class Connection implements ConnectionInterface
{
use LoggerAwareTrait;
public function getLogger()
{
- 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
Whitespace found at end of line Open
Open
$this->dataAccess = new DataAccess($this);
- Exclude checks