koselig/library

View on GitHub
src/Models/Post.php

Summary

Maintainability
B
5 hrs
Test Coverage

Function getACF has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public function getACF($key = null, $format = true)
    {
        if (!function_exists('acf_format_value')) {
            throw new UnsatisfiedDependencyException('Advanced Custom Fields must be installed to use field');
        }
Severity: Minor
Found in src/Models/Post.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

Post has 21 functions (exceeds 20 allowed). Consider refactoring.
Open

class Post extends Model
{
    use Rememberable;

    public $timestamps = false;
Severity: Minor
Found in src/Models/Post.php - About 2 hrs to fix

    Method getACF has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getACF($key = null, $format = true)
        {
            if (!function_exists('acf_format_value')) {
                throw new UnsatisfiedDependencyException('Advanced Custom Fields must be installed to use field');
            }
    Severity: Minor
    Found in src/Models/Post.php - About 1 hr to fix

      The method getACF() has an NPath complexity of 392. The configured NPath complexity threshold is 200.
      Open

          public function getACF($key = null, $format = true)
          {
              if (!function_exists('acf_format_value')) {
                  throw new UnsatisfiedDependencyException('Advanced Custom Fields must be installed to use field');
              }
      Severity: Minor
      Found in src/Models/Post.php by phpmd

      NPathComplexity

      Since: 0.1

      The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

      Example

      class Foo {
          function bar() {
              // lots of complicated code
          }
      }

      Source https://phpmd.org/rules/codesize.html#npathcomplexity

      The class Post has a coupling between objects value of 16. Consider to reduce the number of dependencies under 13.
      Open

      class Post extends Model
      {
          use Rememberable;
      
          public $timestamps = false;
      Severity: Minor
      Found in src/Models/Post.php by phpmd

      CouplingBetweenObjects

      Since: 1.1.0

      A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

      Example

      class Foo {
          /**
           * @var \foo\bar\X
           */
          private $x = null;
      
          /**
           * @var \foo\bar\Y
           */
          private $y = null;
      
          /**
           * @var \foo\bar\Z
           */
          private $z = null;
      
          public function setFoo(\Foo $foo) {}
          public function setBar(\Bar $bar) {}
          public function setBaz(\Baz $baz) {}
      
          /**
           * @return \SplObjectStorage
           * @throws \OutOfRangeException
           * @throws \InvalidArgumentException
           * @throws \ErrorException
           */
          public function process(\Iterator $it) {}
      
          // ...
      }

      Source https://phpmd.org/rules/design.html#couplingbetweenobjects

      There are no issues that match your filters.

      Category
      Status