apparat/object

View on GitHub
src/Object/Application/Model/Object/Manager.php

Summary

Maintainability
A
1 hr
Test Coverage

Function loadObjectResource has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function loadObjectResource(
        RepositoryLocatorInterface &$currentLocator,
        $visibility = SelectorInterface::ALL
    ) {
        // Validate the object visibility
Severity: Minor
Found in src/Object/Application/Model/Object/Manager.php - About 55 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 createObject has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

        RepositoryInterface $repository,
        Type $type,
        $payload = '',
        array $propertyData = [],
        \DateTimeInterface $creationDate = null
Severity: Minor
Found in src/Object/Application/Model/Object/Manager.php - About 35 mins to fix

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

    class Manager implements ManagerInterface
    {
        /**
         * Create and return a new object
         *

    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

    Missing class import via use statement (line '82', column '33').
    Open

                $creationDate = new \DateTimeImmutable('now');

    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

    There are no issues that match your filters.

    Category
    Status