PicoParsePagesContent   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 18.18 %

Coupling/Cohesion

Components 0
Dependencies 1
Metric Value
wmc 2
lcom 0
cbo 1
dl 4
loc 22
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A onSinglePageLoaded() 4 7 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/**
4
 * Parses the contents of all pages
5
 *
6
 * This plugin exists for backward compatibility and is disabled by default.
7
 * It gets automatically enabled when {@link PicoDeprecated} is enabled. You
8
 * can avoid this by calling {@link PicoParsePagesContent::setEnabled()}.
9
 *
10
 * This plugin heavily impacts Pico's performance, you should avoid to enable
11
 * it whenever possible! If you must parse the contents of a page, do this
12
 * selectively and only for pages you really need to.
13
 *
14
 * @author  Daniel Rudolf
15
 * @link    http://picocms.org
16
 * @license http://opensource.org/licenses/MIT
17
 * @version 1.0
18
 */
19
class PicoParsePagesContent extends AbstractPicoPlugin
20
{
21
    /**
22
     * This plugin is disabled by default
23
     *
24
     * @see AbstractPicoPlugin::$enabled
25
     */
26
    protected $enabled = false;
27
28
    /**
29
     * Parses the contents of all pages
30
     *
31
     * @see DummyPlugin::onSinglePageLoaded()
32
     */
33
    public function onSinglePageLoaded(array &$pageData)
34
    {
35 View Code Duplication
        if (!isset($pageData['content'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
36
            $pageData['content'] = $this->prepareFileContent($pageData['raw_content'], $pageData['meta']);
37
            $pageData['content'] = $this->parseFileContent($pageData['content']);
38
        }
39
    }
40
}
41