AccordionParser   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get_shortcodes() 0 4 1
A handle_shortcode() 0 11 2
1
<?php
2
3
/**
4
 * Class AccordionParser
5
 *
6
 * Parse the shortcode and return the rendered accordion template
7
 */
8
class AccordionParser
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
9
{
10
    public static function get_shortcodes()
11
    {
12
        return ['code'];
13
    }
14
15
    /**
16
     * @param string $arguments array with the type
17
     * @param array $code string of the code to parse
18
     * @param ShortcodeParser $parser Parser root user.
19
     * @param string $shortcode
20
     * @param array $extra
21
     *
22
     * @return String of parsed code.
23
     */
24
    public static function handle_shortcode($arguments, $code, $parser, $shortcode, $extra = array())
0 ignored issues
show
Unused Code introduced by
The parameter $arguments is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $code is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $parser is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $shortcode is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $extra is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
25
    {
26
        // Only if we're on a Page, so the CMS doesn't crash.
27
        if (Controller::curr() instanceof Page_Controller) {
0 ignored issues
show
Bug introduced by
The class Page_Controller does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
28
            $accordionItems = Controller::curr()->dataRecord;
29
            $template = 'AccordionItems';
30
            $ssViewer = new SSViewer($template);
31
32
            return $ssViewer->process($accordionItems);
33
        }
34
    }
35
}