Completed
Push — master ( 39734d...9bfb60 )
by Zack
05:51 queued 02:37
created

Core::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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 15 and the first side effect is on line 5.

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
namespace GV;
3
4
/** If this file is called directly, abort. */
5
if ( ! defined( 'GRAVITYVIEW_DIR' ) )
0 ignored issues
show
Coding Style Best Practice introduced by
It is generally a best practice to always use braces with control structures.

Adding braces to control structures avoids accidental mistakes as your code changes:

// Without braces (not recommended)
if (true)
    doSomething();

// Recommended
if (true) {
    doSomething();
}
Loading history...
6
	die();
7
8
/**
9
 * The core GravityView API.
10
 *
11
 * Returned by the wrapper gravityview() global function, exposes
12
 * all the required public functionality and classes, sets up global
13
 * state depending on current request context, etc.
14
 */
15
final class Core {
16
	/**
17
	 * @var \GV\Core The \GV\Core static instance.
18
	 */
19
	private static $__instance = null;
20
21
	/**
22
	 * @var \GV\Plugin The WordPress plugin context.
23
	 *
24
	 * @api
25
	 * @since future
26
	 */
27
	public $plugin;
28
29
	/**
30
	 * @var \GV\Request The current request.
31
	 *
32
	 * @api
33
	 * @since future
34
	 */
35
	public $request;
36
37
	/**
38
	 * @var \GV\CoreSettings core GravityView settings
39
	 */
40
	public $settings;
41
	
42
	/**
43
	 * Get the global instance of \GV\Core.
44
	 *
45
	 * @return \GV\Core The global instance of GravityView Core.
46
	 */
47
	public static function get() {
48
		if ( ! self::$__instance instanceof self )
0 ignored issues
show
Coding Style Best Practice introduced by
It is generally a best practice to always use braces with control structures.

Adding braces to control structures avoids accidental mistakes as your code changes:

// Without braces (not recommended)
if (true)
    doSomething();

// Recommended
if (true) {
    doSomething();
}
Loading history...
49
			self::$__instance = new self;
50
		return self::$__instance;
51
	}
52
53
	/**
54
	 * Bootstrap.
55
	 *
56
	 * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
57
	 */
58
	private function __construct() {
59
		$this->init();
60
	}
61
62
	/**
63
	 * Early initialization.
64
	 *
65
	 * Loads dependencies, sets up the object, adds hooks, etc.
66
	 *
67
	 * @return void
68
	 */
69
	private function init() {
70
		require_once dirname( __FILE__ ) . '/class-gv-plugin.php';
71
		$this->plugin = \GV\Plugin::get();
72
	}
73
74
	private function __clone() { }
75
76
	private function __wakeup() { }
77
}
78