budde377/Part

View on GitHub
lib/model/page/PageOrderImpl.php

Summary

Maintainability
D
1 day
Test Coverage

File PageOrderImpl.php has 324 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
namespace ChristianBudde\Part\model\page;

use ChristianBudde\Part\BackendSingletonContainer;
use ChristianBudde\Part\controller\ajax\type_handler\TypeHandler;
Severity: Minor
Found in lib/model/page/PageOrderImpl.php - About 3 hrs to fix

PageOrderImpl has 27 functions (exceeds 20 allowed). Consider refactoring.
Open

class PageOrderImpl implements PageOrder
{

    private $database;
    private $connection;
Severity: Minor
Found in lib/model/page/PageOrderImpl.php - About 3 hrs to fix

Function detectLoop has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function detectLoop($childID, $parentID)
    {

        $prevID = $parentID;
        $loopDetected = false;
Severity: Minor
Found in lib/model/page/PageOrderImpl.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 setPageOrder has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function setPageOrder(Page $page, $place = PageOrder::PAGE_ORDER_LAST, Page $parentPage = null)
    {

        if ($parentPage instanceof Page) {
            if ($this->findPage($parentPage) !== false) {
Severity: Minor
Found in lib/model/page/PageOrderImpl.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

Method createPageInstance has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    private function createPageInstance($id, $title, $template, $alias, $lastMod, $hidden)
Severity: Minor
Found in lib/model/page/PageOrderImpl.php - About 45 mins to fix

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

    public function createPage($id, $title = '', $template = '', $alias = '', $hidden = false)
Severity: Minor
Found in lib/model/page/PageOrderImpl.php - About 35 mins to fix

Function recursiveCalculatePath has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function recursiveCalculatePath(Page $page, Page $parent = null)
    {
        $order = $this->getPageOrder($parent);
        foreach ($order as $p) {
            /** @var $p Page */
Severity: Minor
Found in lib/model/page/PageOrderImpl.php - About 35 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 updatePageOrderId has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function updatePageOrderId($oldId, $newId)
    {
        if (isset($this->pageOrder[$oldId])) {
            $this->pageOrder[$newId] = $this->pageOrder[$oldId];
            unset($this->pageOrder[$oldId]);
Severity: Minor
Found in lib/model/page/PageOrderImpl.php - About 35 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 listPages has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function listPages($listMode = PageOrder::LIST_ALL)
    {
        $retArray = array();
        if ($listMode == PageOrder::LIST_INACTIVE || $listMode == PageOrder::LIST_ALL) {
            foreach ($this->inactivePages as $page) {
Severity: Minor
Found in lib/model/page/PageOrderImpl.php - About 35 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

Avoid too many return statements within this method.
Open

        return $page;
Severity: Major
Found in lib/model/page/PageOrderImpl.php - About 30 mins to fix

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

    private function removeIDFromSubLists($pageID)
    {
        foreach ($this->pageOrder as $parent_id => $orderArray) {
            foreach ($orderArray as $order => $page_id) {
                if ($page_id == $pageID) {
Severity: Minor
Found in lib/model/page/PageOrderImpl.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

There are no issues that match your filters.

Category
Status