Completed
Branch dev (aae49a)
by
unknown
19:32
created

AdminPageFrameworkLoader_Demo::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6
Metric Value
dl 0
loc 18
rs 9.4286
ccs 0
cts 9
cp 0
cc 2
eloc 8
nc 2
nop 0
crap 6
1
<?php
2
/**
3
 * Loads the demo components.
4
 * 
5
 * @package      Admin Page Framework Loader
6
 * @copyright    Copyright (c) 2014, Michael Uno
7
 * @author       Michael Uno
8
 * @authorurl    http://michaeluno.jp
9
 * @since        3.5.0
10
 */
11
12
 /**
13
  * 
14
  * 
15
  * @action     do      admin_page_framework_loader_action_before_loading_demo
16
  * @action     do      admin_page_framework_loader_action_after_loading_demo
17
  */
18
class AdminPageFrameworkLoader_Demo {
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...
19
    
20
    public function __construct() {
21
        
22
        if ( ! $this->_shouldLoadDemo() ) {
23
            return;
24
        }
25
        
26
        // Backward compatibility.
27
        define( 'APFDEMO_FILE', AdminPageFrameworkLoader_Registry::$sFilePath );
28
        define( 'APFDEMO_DIRNAME', AdminPageFrameworkLoader_Registry::$sDirPath );
29
        
30
        do_action( 'admin_page_framework_loader_action_before_loading_demo' );
31
        
32
        // Include example components.
33
        include( AdminPageFrameworkLoader_Registry::$sDirPath . '/example/admin-page-framework-demo-bootstrap.php' );
34
        
35
        do_action( 'admin_page_framework_loader_action_after_loading_demo' );
36
        
37
    }
38
        /**
39
         * @since       3.7.4
40
         * @return      boolean
41
         */
42
        private function _shouldLoadDemo() {
1 ignored issue
show
Coding Style introduced by
Method name "_shouldLoadDemo" should not be prefixed with an underscore to indicate visibility
Loading history...
43
44
            if ( AdminPageFrameworkLoader_Utility::isSilentMode() ) {
45
                return false;
46
            }
47
        
48
            // Check if the demo is enabled.
49
            $_oOption = AdminPageFrameworkLoader_Option::getInstance();
50
            if ( ! $_oOption->get( 'enable_demo' ) ) {
51
                return false;
52
            }           
53
            
54
            return true;
55
            
56
        }
57
 
58
}
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...