Completed
Push — master ( fa8748...40dd7e )
by Askupa
01:43
created

bootstrap.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 19 and the first side effect is on line 13.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * WordPress UI
4
 *
5
 * A set of HTML UI components for WordPress.
6
 * This is a component within the Amarkal framework.
7
 *
8
 * @package   amarkal-ui
9
 * @author    Askupa Software <[email protected]>
10
 * @link      https://github.com/askupasoftware/amarkal-ui
11
 * @copyright 2017 Askupa Software
12
 */
13
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
14
15
/**
16
 * Prevent loading the library more than once
17
 */
18
if( defined( 'AMARKAL_UI' ) ) return;
19
define( 'AMARKAL_UI', true );
20
21
/**
22
 * Load required classes if not using composer
23
 */
24
if( !class_exists('Composer\\Autoload\\ClassLoader') )
25
{
26
    require_once 'Renderer.php';
27
    require_once 'AbstractController.php';
28
    require_once 'AbstractComponent.php';
29
}
30
31
if(!function_exists('amarkal_ui_render'))
32
{
33
    /**
34
     * Render a UI component.
35
     * 
36
     * @param string $type The component's type - one of the core component types,
37
     * or a registered custom component.
38
     * @param array $props The component's properties
39
     * @return string The rendered HTML
40
     */
41
    function amarkal_ui_render( $type, array $props = array() )
42
    {
43
        $renderer = Amarkal\UI\Renderer::get_instance();
44
        return $renderer->render_component( $type, $props );
45
    }
46
}
47
48
if(!function_exists('amarkal_ui_register_component'))
49
{
50
    /**
51
     * Register a custom UI component. The registered component's class should
52
     * inherit from Amarkal\UI\AbstractComponent.
53
     * 
54
     * @param string $type The component's type. If the custom type is similar 
55
     * to one of the core component's type, it will override the core component.
56
     * @param string $class_name The component's class name.
57
     */
58
    function amarkal_ui_register_component( $type, $class_name )
59
    {
60
        $renderer = Amarkal\UI\Renderer::get_instance();
61
        $renderer->register_component( $type, $class_name );
62
    }
63
}