Completed
Branch dev (a3767f)
by Michael
40:38
created

AdminPageFrameworkLoader_AdminPage_Help_Example   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 47
rs 10
ccs 0
cts 32
cp 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B replyToLoadTab() 0 30 4
A getReadMeContents() 0 7 1
1
<?php
2
/**
3
 * Admin Page Framework Loader
4
 * 
5
 * Demonstrates the usage of Admin Page Framework.
6
 * 
7
 * http://en.michaeluno.jp/admin-page-framework/
8
 * Copyright (c) 2013-2015 Michael Uno; Licensed GPLv2
9
 * 
10
 */
11
12
/**
13
 * Adds a tab of the set page to the loader plugin.
14
 * 
15
 * @since       3.5.0    
16
 */
17
class AdminPageFrameworkLoader_AdminPage_Help_Example extends AdminPageFrameworkLoader_AdminPage_Tab_ReadMeBase {
2 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...
Coding Style introduced by
As per PSR2, the opening brace for this class should be on a new line.
Loading history...
18
        
19
    /**
20
     * Triggered when the tab is loaded.
21
     */
22
    public function replyToLoadTab( $oAdminPage ) {
23
            
24
        $_aItems     = $this->getContentsByHeader( $this->getReadmeContents(), 3 );
25
        $_iLastIndex = count( $_aItems ) - 1;
26
        foreach( $_aItems as $_iIndex => $_aContent ) {
27
28
            $_oParser   = new AdminPageFramework_WPReadmeParser;
29
            $_oParser->setText( $_aContent[ 1 ] );
30
            $_sContent  = $_oParser->get();
31
            $oAdminPage->addSettingSections(    
32
                $this->sPageSlug, // the target page slug  
33
                array(
34
                    'section_id'        => 'examples_' . $_iIndex,             
35
                    'title'             => $_aContent[ 0 ],
36
                    'collapsible'       => array(
37
                        'toggle_all_button' => $_iLastIndex === $_iIndex 
38
                            ? array( 'bottom-right' )
39
                            : ( 0 === $_iIndex
40
                                ? array( 'top-right' )
41
                                : false
42
                            ),
43
                    ),
44
                    'content'           => $_sContent,
45
                            
46
                )
47
            );              
48
            
49
        }        
50
51
    }
52
        /**
53
         * @return      string
54
         */
55
        private function getReadMeContents()  {       
56
            return $this->_getReadmeContents( 
57
                AdminPageFrameworkLoader_Registry::$sDirPath . '/asset/text/examples.txt',
58
                '',
59
                array( 'Examples' )
60
            );     
61
        }       
62
    
63
}
1 ignored issue
show
Coding Style introduced by
According to PSR2, the closing brace of classes should be placed on the next line directly after the body.

Below you find some examples:

// Incorrect placement according to PSR2
class MyClass
{
    public function foo()
    {

    }
    // This blank line is not allowed.

}

// Correct
class MyClass
{
    public function foo()
    {

    } // No blank lines after this line.
}
Loading history...