Kylob/Database

View on GitHub

Showing 13 of 13 total issues

Function __construct has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct($dsn, $username = null, $password = null, array $options = array(), array $exec = array())
    {
        if ($dsn instanceof \PDO) {
            $this->connection = $dsn;
            $this->driver('PDO');
Severity: Minor
Found in src/Driver.php - About 2 hrs 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

Method __construct has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function __construct($dsn, $username = null, $password = null, array $options = array(), array $exec = array())
    {
        if ($dsn instanceof \PDO) {
            $this->connection = $dsn;
            $this->driver('PDO');
Severity: Minor
Found in src/Driver.php - About 1 hr to fix

    Function errors has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function errors()
        {
            $errors = self::logs();
            foreach ($errors as $id => $db) {
                foreach ($db['queries'] as $num => $log) {
    Severity: Minor
    Found in src/Driver.php - About 1 hr 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 logs has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function logs($id = null)
        {
            $logs = array();
            $ids = (is_null($id)) ? array_keys(static::$logs) : array($id);
            foreach ($ids as $key) {
    Severity: Minor
    Found in src/Driver.php - About 1 hr 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 execute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function execute($stmt, $values = null)
        {
            if (isset($this->prepared[$stmt])) {
                if (!is_array($values)) {
                    $values = ($this->prepared[$stmt]['params'] == 1) ? array($values) : array();
    Severity: Minor
    Found in src/Component.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 upsert has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function upsert($table, $id, array $data)
        {
            if (isset($this->prepared[$table]['ref']) && $this->execute($table, $id)) {
                $data[] = $id;
                if ($row = $this->fetch($table)) {
    Severity: Minor
    Found in src/Component.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

    Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function __construct($dsn, $username = null, $password = null, array $options = array(), array $exec = array())
    Severity: Minor
    Found in src/Driver.php - About 35 mins to fix

      Avoid too many return statements within this method.
      Open

                      return \PDO::FETCH_NUM;
      Severity: Major
      Found in src/Driver.php - About 30 mins to fix

        Function close has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function close($stmt)
            {
                if (isset($this->prepared[$stmt])) {
                    if (isset($this->prepared[$stmt]['ref'])) {
                        foreach ($this->prepared[$stmt]['ref'] as $value) {
        Severity: Minor
        Found in src/Component.php - About 25 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 dbStyle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function dbStyle($fetch)
            {
                switch ($fetch) {
                    case 'obj':
                        return \PDO::FETCH_OBJ;
        Severity: Minor
        Found in src/Driver.php - About 25 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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function update($table, $id, array $data, $and = '')
            {
                if (isset($this->prepared[$table])) {
                    $data[] = $id;
        
        
        Severity: Minor
        Found in src/Component.php - About 25 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 connection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function connection()
            {
                if (is_null($this->connection) && !is_null($this->construct)) {
                    list($dsn, $username, $password, $options, $exec) = $this->construct;
                    try {
        Severity: Minor
        Found in src/Driver.php - About 25 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 insert has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function insert($table, array $data, $and = '')
            {
                if (isset($this->prepared[$table])) {
                    return $this->execute($table, $data);
                }
        Severity: Minor
        Found in src/Component.php - About 25 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

        Severity
        Category
        Status
        Source
        Language