@@ -3,19 +3,19 @@ |
||
3 | 3 | // autoload.php @generated by Strauss |
4 | 4 | |
5 | 5 | if (file_exists(__DIR__.'/autoload-classmap.php')) { |
6 | - $class_map = include __DIR__.'/autoload-classmap.php'; |
|
7 | - if (is_array($class_map)) { |
|
8 | - spl_autoload_register( |
|
9 | - function ($classname) use ($class_map) { |
|
10 | - if (isset($class_map[$classname]) && file_exists($class_map[$classname])) { |
|
11 | - require_once $class_map[$classname]; |
|
12 | - } |
|
13 | - } |
|
14 | - ); |
|
15 | - } |
|
16 | - unset($class_map); |
|
6 | + $class_map = include __DIR__.'/autoload-classmap.php'; |
|
7 | + if (is_array($class_map)) { |
|
8 | + spl_autoload_register( |
|
9 | + function ($classname) use ($class_map) { |
|
10 | + if (isset($class_map[$classname]) && file_exists($class_map[$classname])) { |
|
11 | + require_once $class_map[$classname]; |
|
12 | + } |
|
13 | + } |
|
14 | + ); |
|
15 | + } |
|
16 | + unset($class_map); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | if (file_exists(__DIR__.'/autoload-files.php')) { |
20 | - require_once __DIR__.'/autoload-files.php'; |
|
20 | + require_once __DIR__.'/autoload-files.php'; |
|
21 | 21 | } |
@@ -2,20 +2,20 @@ |
||
2 | 2 | |
3 | 3 | // autoload.php @generated by Strauss |
4 | 4 | |
5 | -if (file_exists(__DIR__.'/autoload-classmap.php')) { |
|
6 | - $class_map = include __DIR__.'/autoload-classmap.php'; |
|
7 | - if (is_array($class_map)) { |
|
5 | +if ( file_exists( __DIR__ . '/autoload-classmap.php' ) ) { |
|
6 | + $class_map = include __DIR__ . '/autoload-classmap.php'; |
|
7 | + if ( is_array( $class_map ) ) { |
|
8 | 8 | spl_autoload_register( |
9 | - function ($classname) use ($class_map) { |
|
10 | - if (isset($class_map[$classname]) && file_exists($class_map[$classname])) { |
|
11 | - require_once $class_map[$classname]; |
|
9 | + function( $classname ) use ( $class_map ) { |
|
10 | + if ( isset( $class_map[ $classname ] ) && file_exists( $class_map[ $classname ] ) ) { |
|
11 | + require_once $class_map[ $classname ]; |
|
12 | 12 | } |
13 | 13 | } |
14 | 14 | ); |
15 | 15 | } |
16 | - unset($class_map); |
|
16 | + unset( $class_map ); |
|
17 | 17 | } |
18 | 18 | |
19 | -if (file_exists(__DIR__.'/autoload-files.php')) { |
|
20 | - require_once __DIR__.'/autoload-files.php'; |
|
19 | +if ( file_exists( __DIR__ . '/autoload-files.php' ) ) { |
|
20 | + require_once __DIR__ . '/autoload-files.php'; |
|
21 | 21 | } |
@@ -14,12 +14,12 @@ |
||
14 | 14 | */ |
15 | 15 | class LogLevel |
16 | 16 | { |
17 | - const EMERGENCY = 'emergency'; |
|
18 | - const ALERT = 'alert'; |
|
19 | - const CRITICAL = 'critical'; |
|
20 | - const ERROR = 'error'; |
|
21 | - const WARNING = 'warning'; |
|
22 | - const NOTICE = 'notice'; |
|
23 | - const INFO = 'info'; |
|
24 | - const DEBUG = 'debug'; |
|
17 | + const EMERGENCY = 'emergency'; |
|
18 | + const ALERT = 'alert'; |
|
19 | + const CRITICAL = 'critical'; |
|
20 | + const ERROR = 'error'; |
|
21 | + const WARNING = 'warning'; |
|
22 | + const NOTICE = 'notice'; |
|
23 | + const INFO = 'info'; |
|
24 | + const DEBUG = 'debug'; |
|
25 | 25 | } |
@@ -12,8 +12,7 @@ |
||
12 | 12 | /** |
13 | 13 | * Describes log levels. |
14 | 14 | */ |
15 | -class LogLevel |
|
16 | -{ |
|
15 | +class LogLevel { |
|
17 | 16 | const EMERGENCY = 'emergency'; |
18 | 17 | const ALERT = 'alert'; |
19 | 18 | const CRITICAL = 'critical'; |
@@ -18,118 +18,118 @@ |
||
18 | 18 | */ |
19 | 19 | abstract class AbstractLogger implements LoggerInterface |
20 | 20 | { |
21 | - /** |
|
22 | - * System is unusable. |
|
23 | - * |
|
24 | - * @param string $message |
|
25 | - * @param mixed[] $context |
|
26 | - * |
|
27 | - * @return void |
|
28 | - */ |
|
29 | - public function emergency($message, array $context = []) |
|
30 | - { |
|
31 | - $this->log(LogLevel::EMERGENCY, $message, $context); |
|
32 | - } |
|
21 | + /** |
|
22 | + * System is unusable. |
|
23 | + * |
|
24 | + * @param string $message |
|
25 | + * @param mixed[] $context |
|
26 | + * |
|
27 | + * @return void |
|
28 | + */ |
|
29 | + public function emergency($message, array $context = []) |
|
30 | + { |
|
31 | + $this->log(LogLevel::EMERGENCY, $message, $context); |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * Action must be taken immediately. |
|
36 | - * |
|
37 | - * Example: Entire website down, database unavailable, etc. This should |
|
38 | - * trigger the SMS alerts and wake you up. |
|
39 | - * |
|
40 | - * @param string $message |
|
41 | - * @param mixed[] $context |
|
42 | - * |
|
43 | - * @return void |
|
44 | - */ |
|
45 | - public function alert($message, array $context = []) |
|
46 | - { |
|
47 | - $this->log(LogLevel::ALERT, $message, $context); |
|
48 | - } |
|
34 | + /** |
|
35 | + * Action must be taken immediately. |
|
36 | + * |
|
37 | + * Example: Entire website down, database unavailable, etc. This should |
|
38 | + * trigger the SMS alerts and wake you up. |
|
39 | + * |
|
40 | + * @param string $message |
|
41 | + * @param mixed[] $context |
|
42 | + * |
|
43 | + * @return void |
|
44 | + */ |
|
45 | + public function alert($message, array $context = []) |
|
46 | + { |
|
47 | + $this->log(LogLevel::ALERT, $message, $context); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * Critical conditions. |
|
52 | - * |
|
53 | - * Example: Application component unavailable, unexpected exception. |
|
54 | - * |
|
55 | - * @param string $message |
|
56 | - * @param mixed[] $context |
|
57 | - * |
|
58 | - * @return void |
|
59 | - */ |
|
60 | - public function critical($message, array $context = []) |
|
61 | - { |
|
62 | - $this->log(LogLevel::CRITICAL, $message, $context); |
|
63 | - } |
|
50 | + /** |
|
51 | + * Critical conditions. |
|
52 | + * |
|
53 | + * Example: Application component unavailable, unexpected exception. |
|
54 | + * |
|
55 | + * @param string $message |
|
56 | + * @param mixed[] $context |
|
57 | + * |
|
58 | + * @return void |
|
59 | + */ |
|
60 | + public function critical($message, array $context = []) |
|
61 | + { |
|
62 | + $this->log(LogLevel::CRITICAL, $message, $context); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * Runtime errors that do not require immediate action but should typically |
|
67 | - * be logged and monitored. |
|
68 | - * |
|
69 | - * @param string $message |
|
70 | - * @param mixed[] $context |
|
71 | - * |
|
72 | - * @return void |
|
73 | - */ |
|
74 | - public function error($message, array $context = []) |
|
75 | - { |
|
76 | - $this->log(LogLevel::ERROR, $message, $context); |
|
77 | - } |
|
65 | + /** |
|
66 | + * Runtime errors that do not require immediate action but should typically |
|
67 | + * be logged and monitored. |
|
68 | + * |
|
69 | + * @param string $message |
|
70 | + * @param mixed[] $context |
|
71 | + * |
|
72 | + * @return void |
|
73 | + */ |
|
74 | + public function error($message, array $context = []) |
|
75 | + { |
|
76 | + $this->log(LogLevel::ERROR, $message, $context); |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * Exceptional occurrences that are not errors. |
|
81 | - * |
|
82 | - * Example: Use of deprecated APIs, poor use of an API, undesirable things |
|
83 | - * that are not necessarily wrong. |
|
84 | - * |
|
85 | - * @param string $message |
|
86 | - * @param mixed[] $context |
|
87 | - * |
|
88 | - * @return void |
|
89 | - */ |
|
90 | - public function warning($message, array $context = []) |
|
91 | - { |
|
92 | - $this->log(LogLevel::WARNING, $message, $context); |
|
93 | - } |
|
79 | + /** |
|
80 | + * Exceptional occurrences that are not errors. |
|
81 | + * |
|
82 | + * Example: Use of deprecated APIs, poor use of an API, undesirable things |
|
83 | + * that are not necessarily wrong. |
|
84 | + * |
|
85 | + * @param string $message |
|
86 | + * @param mixed[] $context |
|
87 | + * |
|
88 | + * @return void |
|
89 | + */ |
|
90 | + public function warning($message, array $context = []) |
|
91 | + { |
|
92 | + $this->log(LogLevel::WARNING, $message, $context); |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * Normal but significant events. |
|
97 | - * |
|
98 | - * @param string $message |
|
99 | - * @param mixed[] $context |
|
100 | - * |
|
101 | - * @return void |
|
102 | - */ |
|
103 | - public function notice($message, array $context = []) |
|
104 | - { |
|
105 | - $this->log(LogLevel::NOTICE, $message, $context); |
|
106 | - } |
|
95 | + /** |
|
96 | + * Normal but significant events. |
|
97 | + * |
|
98 | + * @param string $message |
|
99 | + * @param mixed[] $context |
|
100 | + * |
|
101 | + * @return void |
|
102 | + */ |
|
103 | + public function notice($message, array $context = []) |
|
104 | + { |
|
105 | + $this->log(LogLevel::NOTICE, $message, $context); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * Interesting events. |
|
110 | - * |
|
111 | - * Example: User logs in, SQL logs. |
|
112 | - * |
|
113 | - * @param string $message |
|
114 | - * @param mixed[] $context |
|
115 | - * |
|
116 | - * @return void |
|
117 | - */ |
|
118 | - public function info($message, array $context = []) |
|
119 | - { |
|
120 | - $this->log(LogLevel::INFO, $message, $context); |
|
121 | - } |
|
108 | + /** |
|
109 | + * Interesting events. |
|
110 | + * |
|
111 | + * Example: User logs in, SQL logs. |
|
112 | + * |
|
113 | + * @param string $message |
|
114 | + * @param mixed[] $context |
|
115 | + * |
|
116 | + * @return void |
|
117 | + */ |
|
118 | + public function info($message, array $context = []) |
|
119 | + { |
|
120 | + $this->log(LogLevel::INFO, $message, $context); |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * Detailed debug information. |
|
125 | - * |
|
126 | - * @param string $message |
|
127 | - * @param mixed[] $context |
|
128 | - * |
|
129 | - * @return void |
|
130 | - */ |
|
131 | - public function debug($message, array $context = []) |
|
132 | - { |
|
133 | - $this->log(LogLevel::DEBUG, $message, $context); |
|
134 | - } |
|
123 | + /** |
|
124 | + * Detailed debug information. |
|
125 | + * |
|
126 | + * @param string $message |
|
127 | + * @param mixed[] $context |
|
128 | + * |
|
129 | + * @return void |
|
130 | + */ |
|
131 | + public function debug($message, array $context = []) |
|
132 | + { |
|
133 | + $this->log(LogLevel::DEBUG, $message, $context); |
|
134 | + } |
|
135 | 135 | } |
@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return void |
28 | 28 | */ |
29 | - public function emergency($message, array $context = []) |
|
29 | + public function emergency( $message, array $context = [ ] ) |
|
30 | 30 | { |
31 | - $this->log(LogLevel::EMERGENCY, $message, $context); |
|
31 | + $this->log( LogLevel::EMERGENCY, $message, $context ); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @return void |
44 | 44 | */ |
45 | - public function alert($message, array $context = []) |
|
45 | + public function alert( $message, array $context = [ ] ) |
|
46 | 46 | { |
47 | - $this->log(LogLevel::ALERT, $message, $context); |
|
47 | + $this->log( LogLevel::ALERT, $message, $context ); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return void |
59 | 59 | */ |
60 | - public function critical($message, array $context = []) |
|
60 | + public function critical( $message, array $context = [ ] ) |
|
61 | 61 | { |
62 | - $this->log(LogLevel::CRITICAL, $message, $context); |
|
62 | + $this->log( LogLevel::CRITICAL, $message, $context ); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @return void |
73 | 73 | */ |
74 | - public function error($message, array $context = []) |
|
74 | + public function error( $message, array $context = [ ] ) |
|
75 | 75 | { |
76 | - $this->log(LogLevel::ERROR, $message, $context); |
|
76 | + $this->log( LogLevel::ERROR, $message, $context ); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return void |
89 | 89 | */ |
90 | - public function warning($message, array $context = []) |
|
90 | + public function warning( $message, array $context = [ ] ) |
|
91 | 91 | { |
92 | - $this->log(LogLevel::WARNING, $message, $context); |
|
92 | + $this->log( LogLevel::WARNING, $message, $context ); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -100,9 +100,9 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @return void |
102 | 102 | */ |
103 | - public function notice($message, array $context = []) |
|
103 | + public function notice( $message, array $context = [ ] ) |
|
104 | 104 | { |
105 | - $this->log(LogLevel::NOTICE, $message, $context); |
|
105 | + $this->log( LogLevel::NOTICE, $message, $context ); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | * |
116 | 116 | * @return void |
117 | 117 | */ |
118 | - public function info($message, array $context = []) |
|
118 | + public function info( $message, array $context = [ ] ) |
|
119 | 119 | { |
120 | - $this->log(LogLevel::INFO, $message, $context); |
|
120 | + $this->log( LogLevel::INFO, $message, $context ); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return void |
130 | 130 | */ |
131 | - public function debug($message, array $context = []) |
|
131 | + public function debug( $message, array $context = [ ] ) |
|
132 | 132 | { |
133 | - $this->log(LogLevel::DEBUG, $message, $context); |
|
133 | + $this->log( LogLevel::DEBUG, $message, $context ); |
|
134 | 134 | } |
135 | 135 | } |
@@ -16,8 +16,7 @@ discard block |
||
16 | 16 | * reduce boilerplate code that a simple Logger that does the same thing with |
17 | 17 | * messages regardless of the error level has to implement. |
18 | 18 | */ |
19 | -abstract class AbstractLogger implements LoggerInterface |
|
20 | -{ |
|
19 | +abstract class AbstractLogger implements LoggerInterface { |
|
21 | 20 | /** |
22 | 21 | * System is unusable. |
23 | 22 | * |
@@ -26,8 +25,7 @@ discard block |
||
26 | 25 | * |
27 | 26 | * @return void |
28 | 27 | */ |
29 | - public function emergency($message, array $context = []) |
|
30 | - { |
|
28 | + public function emergency($message, array $context = []) { |
|
31 | 29 | $this->log(LogLevel::EMERGENCY, $message, $context); |
32 | 30 | } |
33 | 31 | |
@@ -42,8 +40,7 @@ discard block |
||
42 | 40 | * |
43 | 41 | * @return void |
44 | 42 | */ |
45 | - public function alert($message, array $context = []) |
|
46 | - { |
|
43 | + public function alert($message, array $context = []) { |
|
47 | 44 | $this->log(LogLevel::ALERT, $message, $context); |
48 | 45 | } |
49 | 46 | |
@@ -57,8 +54,7 @@ discard block |
||
57 | 54 | * |
58 | 55 | * @return void |
59 | 56 | */ |
60 | - public function critical($message, array $context = []) |
|
61 | - { |
|
57 | + public function critical($message, array $context = []) { |
|
62 | 58 | $this->log(LogLevel::CRITICAL, $message, $context); |
63 | 59 | } |
64 | 60 | |
@@ -71,8 +67,7 @@ discard block |
||
71 | 67 | * |
72 | 68 | * @return void |
73 | 69 | */ |
74 | - public function error($message, array $context = []) |
|
75 | - { |
|
70 | + public function error($message, array $context = []) { |
|
76 | 71 | $this->log(LogLevel::ERROR, $message, $context); |
77 | 72 | } |
78 | 73 | |
@@ -87,8 +82,7 @@ discard block |
||
87 | 82 | * |
88 | 83 | * @return void |
89 | 84 | */ |
90 | - public function warning($message, array $context = []) |
|
91 | - { |
|
85 | + public function warning($message, array $context = []) { |
|
92 | 86 | $this->log(LogLevel::WARNING, $message, $context); |
93 | 87 | } |
94 | 88 | |
@@ -100,8 +94,7 @@ discard block |
||
100 | 94 | * |
101 | 95 | * @return void |
102 | 96 | */ |
103 | - public function notice($message, array $context = []) |
|
104 | - { |
|
97 | + public function notice($message, array $context = []) { |
|
105 | 98 | $this->log(LogLevel::NOTICE, $message, $context); |
106 | 99 | } |
107 | 100 | |
@@ -115,8 +108,7 @@ discard block |
||
115 | 108 | * |
116 | 109 | * @return void |
117 | 110 | */ |
118 | - public function info($message, array $context = []) |
|
119 | - { |
|
111 | + public function info($message, array $context = []) { |
|
120 | 112 | $this->log(LogLevel::INFO, $message, $context); |
121 | 113 | } |
122 | 114 | |
@@ -128,8 +120,7 @@ discard block |
||
128 | 120 | * |
129 | 121 | * @return void |
130 | 122 | */ |
131 | - public function debug($message, array $context = []) |
|
132 | - { |
|
123 | + public function debug($message, array $context = []) { |
|
133 | 124 | $this->log(LogLevel::DEBUG, $message, $context); |
134 | 125 | } |
135 | 126 | } |
@@ -21,125 +21,125 @@ |
||
21 | 21 | */ |
22 | 22 | abstract class LoggerInterfaceTest extends TestCase |
23 | 23 | { |
24 | - /** |
|
25 | - * @return LoggerInterface |
|
26 | - */ |
|
27 | - abstract public function getLogger(); |
|
28 | - |
|
29 | - /** |
|
30 | - * This must return the log messages in order. |
|
31 | - * |
|
32 | - * The simple formatting of the messages is: "<LOG LEVEL> <MESSAGE>". |
|
33 | - * |
|
34 | - * Example ->error('Foo') would yield "error Foo". |
|
35 | - * |
|
36 | - * @return string[] |
|
37 | - */ |
|
38 | - abstract public function getLogs(); |
|
39 | - |
|
40 | - public function testImplements() |
|
41 | - { |
|
42 | - $this->assertInstanceOf('GravityView\Psr\Log\LoggerInterface', $this->getLogger()); |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * @dataProvider provideLevelsAndMessages |
|
47 | - */ |
|
48 | - public function testLogsAtAllLevels($level, $message) |
|
49 | - { |
|
50 | - $logger = $this->getLogger(); |
|
51 | - $logger->{$level}($message, ['user' => 'Bob']); |
|
52 | - $logger->log($level, $message, ['user' => 'Bob']); |
|
53 | - |
|
54 | - $expected = [ |
|
55 | - $level.' message of level '.$level.' with context: Bob', |
|
56 | - $level.' message of level '.$level.' with context: Bob', |
|
57 | - ]; |
|
58 | - $this->assertEquals($expected, $this->getLogs()); |
|
59 | - } |
|
60 | - |
|
61 | - public function provideLevelsAndMessages() |
|
62 | - { |
|
63 | - return [ |
|
64 | - LogLevel::EMERGENCY => [LogLevel::EMERGENCY, 'message of level emergency with context: {user}'], |
|
65 | - LogLevel::ALERT => [LogLevel::ALERT, 'message of level alert with context: {user}'], |
|
66 | - LogLevel::CRITICAL => [LogLevel::CRITICAL, 'message of level critical with context: {user}'], |
|
67 | - LogLevel::ERROR => [LogLevel::ERROR, 'message of level error with context: {user}'], |
|
68 | - LogLevel::WARNING => [LogLevel::WARNING, 'message of level warning with context: {user}'], |
|
69 | - LogLevel::NOTICE => [LogLevel::NOTICE, 'message of level notice with context: {user}'], |
|
70 | - LogLevel::INFO => [LogLevel::INFO, 'message of level info with context: {user}'], |
|
71 | - LogLevel::DEBUG => [LogLevel::DEBUG, 'message of level debug with context: {user}'], |
|
72 | - ]; |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * @expectedException \GravityView\Psr\Log\InvalidArgumentException |
|
77 | - */ |
|
78 | - public function testThrowsOnInvalidLevel() |
|
79 | - { |
|
80 | - $logger = $this->getLogger(); |
|
81 | - $logger->log('invalid level', 'Foo'); |
|
82 | - } |
|
83 | - |
|
84 | - public function testContextReplacement() |
|
85 | - { |
|
86 | - $logger = $this->getLogger(); |
|
87 | - $logger->info('{Message {nothing} {user} {foo.bar} a}', ['user' => 'Bob', 'foo.bar' => 'Bar']); |
|
88 | - |
|
89 | - $expected = ['info {Message {nothing} Bob Bar a}']; |
|
90 | - $this->assertEquals($expected, $this->getLogs()); |
|
91 | - } |
|
92 | - |
|
93 | - public function testObjectCastToString() |
|
94 | - { |
|
95 | - if (method_exists($this, 'createPartialMock')) { |
|
96 | - $dummy = $this->createPartialMock('GravityView\GravityView\Psr\Log\Test\DummyTest', ['__toString']); |
|
97 | - } else { |
|
98 | - $dummy = $this->getMock('GravityView\GravityView\Psr\Log\Test\DummyTest', ['__toString']); |
|
99 | - } |
|
100 | - $dummy->expects($this->once()) |
|
101 | - ->method('__toString') |
|
102 | - ->will($this->returnValue('DUMMY')); |
|
103 | - |
|
104 | - $this->getLogger()->warning($dummy); |
|
105 | - |
|
106 | - $expected = ['warning DUMMY']; |
|
107 | - $this->assertEquals($expected, $this->getLogs()); |
|
108 | - } |
|
109 | - |
|
110 | - public function testContextCanContainAnything() |
|
111 | - { |
|
112 | - $closed = fopen('php://memory', 'r'); |
|
113 | - fclose($closed); |
|
114 | - |
|
115 | - $context = [ |
|
116 | - 'bool' => true, |
|
117 | - 'null' => null, |
|
118 | - 'string' => 'Foo', |
|
119 | - 'int' => 0, |
|
120 | - 'float' => 0.5, |
|
121 | - 'nested' => ['with object' => new DummyTest()], |
|
122 | - 'object' => new \DateTime(), |
|
123 | - 'resource' => fopen('php://memory', 'r'), |
|
124 | - 'closed' => $closed, |
|
125 | - ]; |
|
126 | - |
|
127 | - $this->getLogger()->warning('Crazy context data', $context); |
|
128 | - |
|
129 | - $expected = ['warning Crazy context data']; |
|
130 | - $this->assertEquals($expected, $this->getLogs()); |
|
131 | - } |
|
132 | - |
|
133 | - public function testContextExceptionKeyCanBeExceptionOrOtherValues() |
|
134 | - { |
|
135 | - $logger = $this->getLogger(); |
|
136 | - $logger->warning('Random message', ['exception' => 'oops']); |
|
137 | - $logger->critical('Uncaught Exception!', ['exception' => new \LogicException('Fail')]); |
|
138 | - |
|
139 | - $expected = [ |
|
140 | - 'warning Random message', |
|
141 | - 'critical Uncaught Exception!', |
|
142 | - ]; |
|
143 | - $this->assertEquals($expected, $this->getLogs()); |
|
144 | - } |
|
24 | + /** |
|
25 | + * @return LoggerInterface |
|
26 | + */ |
|
27 | + abstract public function getLogger(); |
|
28 | + |
|
29 | + /** |
|
30 | + * This must return the log messages in order. |
|
31 | + * |
|
32 | + * The simple formatting of the messages is: "<LOG LEVEL> <MESSAGE>". |
|
33 | + * |
|
34 | + * Example ->error('Foo') would yield "error Foo". |
|
35 | + * |
|
36 | + * @return string[] |
|
37 | + */ |
|
38 | + abstract public function getLogs(); |
|
39 | + |
|
40 | + public function testImplements() |
|
41 | + { |
|
42 | + $this->assertInstanceOf('GravityView\Psr\Log\LoggerInterface', $this->getLogger()); |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * @dataProvider provideLevelsAndMessages |
|
47 | + */ |
|
48 | + public function testLogsAtAllLevels($level, $message) |
|
49 | + { |
|
50 | + $logger = $this->getLogger(); |
|
51 | + $logger->{$level}($message, ['user' => 'Bob']); |
|
52 | + $logger->log($level, $message, ['user' => 'Bob']); |
|
53 | + |
|
54 | + $expected = [ |
|
55 | + $level.' message of level '.$level.' with context: Bob', |
|
56 | + $level.' message of level '.$level.' with context: Bob', |
|
57 | + ]; |
|
58 | + $this->assertEquals($expected, $this->getLogs()); |
|
59 | + } |
|
60 | + |
|
61 | + public function provideLevelsAndMessages() |
|
62 | + { |
|
63 | + return [ |
|
64 | + LogLevel::EMERGENCY => [LogLevel::EMERGENCY, 'message of level emergency with context: {user}'], |
|
65 | + LogLevel::ALERT => [LogLevel::ALERT, 'message of level alert with context: {user}'], |
|
66 | + LogLevel::CRITICAL => [LogLevel::CRITICAL, 'message of level critical with context: {user}'], |
|
67 | + LogLevel::ERROR => [LogLevel::ERROR, 'message of level error with context: {user}'], |
|
68 | + LogLevel::WARNING => [LogLevel::WARNING, 'message of level warning with context: {user}'], |
|
69 | + LogLevel::NOTICE => [LogLevel::NOTICE, 'message of level notice with context: {user}'], |
|
70 | + LogLevel::INFO => [LogLevel::INFO, 'message of level info with context: {user}'], |
|
71 | + LogLevel::DEBUG => [LogLevel::DEBUG, 'message of level debug with context: {user}'], |
|
72 | + ]; |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * @expectedException \GravityView\Psr\Log\InvalidArgumentException |
|
77 | + */ |
|
78 | + public function testThrowsOnInvalidLevel() |
|
79 | + { |
|
80 | + $logger = $this->getLogger(); |
|
81 | + $logger->log('invalid level', 'Foo'); |
|
82 | + } |
|
83 | + |
|
84 | + public function testContextReplacement() |
|
85 | + { |
|
86 | + $logger = $this->getLogger(); |
|
87 | + $logger->info('{Message {nothing} {user} {foo.bar} a}', ['user' => 'Bob', 'foo.bar' => 'Bar']); |
|
88 | + |
|
89 | + $expected = ['info {Message {nothing} Bob Bar a}']; |
|
90 | + $this->assertEquals($expected, $this->getLogs()); |
|
91 | + } |
|
92 | + |
|
93 | + public function testObjectCastToString() |
|
94 | + { |
|
95 | + if (method_exists($this, 'createPartialMock')) { |
|
96 | + $dummy = $this->createPartialMock('GravityView\GravityView\Psr\Log\Test\DummyTest', ['__toString']); |
|
97 | + } else { |
|
98 | + $dummy = $this->getMock('GravityView\GravityView\Psr\Log\Test\DummyTest', ['__toString']); |
|
99 | + } |
|
100 | + $dummy->expects($this->once()) |
|
101 | + ->method('__toString') |
|
102 | + ->will($this->returnValue('DUMMY')); |
|
103 | + |
|
104 | + $this->getLogger()->warning($dummy); |
|
105 | + |
|
106 | + $expected = ['warning DUMMY']; |
|
107 | + $this->assertEquals($expected, $this->getLogs()); |
|
108 | + } |
|
109 | + |
|
110 | + public function testContextCanContainAnything() |
|
111 | + { |
|
112 | + $closed = fopen('php://memory', 'r'); |
|
113 | + fclose($closed); |
|
114 | + |
|
115 | + $context = [ |
|
116 | + 'bool' => true, |
|
117 | + 'null' => null, |
|
118 | + 'string' => 'Foo', |
|
119 | + 'int' => 0, |
|
120 | + 'float' => 0.5, |
|
121 | + 'nested' => ['with object' => new DummyTest()], |
|
122 | + 'object' => new \DateTime(), |
|
123 | + 'resource' => fopen('php://memory', 'r'), |
|
124 | + 'closed' => $closed, |
|
125 | + ]; |
|
126 | + |
|
127 | + $this->getLogger()->warning('Crazy context data', $context); |
|
128 | + |
|
129 | + $expected = ['warning Crazy context data']; |
|
130 | + $this->assertEquals($expected, $this->getLogs()); |
|
131 | + } |
|
132 | + |
|
133 | + public function testContextExceptionKeyCanBeExceptionOrOtherValues() |
|
134 | + { |
|
135 | + $logger = $this->getLogger(); |
|
136 | + $logger->warning('Random message', ['exception' => 'oops']); |
|
137 | + $logger->critical('Uncaught Exception!', ['exception' => new \LogicException('Fail')]); |
|
138 | + |
|
139 | + $expected = [ |
|
140 | + 'warning Random message', |
|
141 | + 'critical Uncaught Exception!', |
|
142 | + ]; |
|
143 | + $this->assertEquals($expected, $this->getLogs()); |
|
144 | + } |
|
145 | 145 | } |
@@ -39,36 +39,36 @@ discard block |
||
39 | 39 | |
40 | 40 | public function testImplements() |
41 | 41 | { |
42 | - $this->assertInstanceOf('GravityView\Psr\Log\LoggerInterface', $this->getLogger()); |
|
42 | + $this->assertInstanceOf( 'GravityView\Psr\Log\LoggerInterface', $this->getLogger() ); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
46 | 46 | * @dataProvider provideLevelsAndMessages |
47 | 47 | */ |
48 | - public function testLogsAtAllLevels($level, $message) |
|
48 | + public function testLogsAtAllLevels( $level, $message ) |
|
49 | 49 | { |
50 | 50 | $logger = $this->getLogger(); |
51 | - $logger->{$level}($message, ['user' => 'Bob']); |
|
52 | - $logger->log($level, $message, ['user' => 'Bob']); |
|
51 | + $logger->{$level}( $message, [ 'user' => 'Bob' ] ); |
|
52 | + $logger->log( $level, $message, [ 'user' => 'Bob' ] ); |
|
53 | 53 | |
54 | 54 | $expected = [ |
55 | - $level.' message of level '.$level.' with context: Bob', |
|
56 | - $level.' message of level '.$level.' with context: Bob', |
|
55 | + $level . ' message of level ' . $level . ' with context: Bob', |
|
56 | + $level . ' message of level ' . $level . ' with context: Bob', |
|
57 | 57 | ]; |
58 | - $this->assertEquals($expected, $this->getLogs()); |
|
58 | + $this->assertEquals( $expected, $this->getLogs() ); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | public function provideLevelsAndMessages() |
62 | 62 | { |
63 | 63 | return [ |
64 | - LogLevel::EMERGENCY => [LogLevel::EMERGENCY, 'message of level emergency with context: {user}'], |
|
65 | - LogLevel::ALERT => [LogLevel::ALERT, 'message of level alert with context: {user}'], |
|
66 | - LogLevel::CRITICAL => [LogLevel::CRITICAL, 'message of level critical with context: {user}'], |
|
67 | - LogLevel::ERROR => [LogLevel::ERROR, 'message of level error with context: {user}'], |
|
68 | - LogLevel::WARNING => [LogLevel::WARNING, 'message of level warning with context: {user}'], |
|
69 | - LogLevel::NOTICE => [LogLevel::NOTICE, 'message of level notice with context: {user}'], |
|
70 | - LogLevel::INFO => [LogLevel::INFO, 'message of level info with context: {user}'], |
|
71 | - LogLevel::DEBUG => [LogLevel::DEBUG, 'message of level debug with context: {user}'], |
|
64 | + LogLevel::EMERGENCY => [ LogLevel::EMERGENCY, 'message of level emergency with context: {user}' ], |
|
65 | + LogLevel::ALERT => [ LogLevel::ALERT, 'message of level alert with context: {user}' ], |
|
66 | + LogLevel::CRITICAL => [ LogLevel::CRITICAL, 'message of level critical with context: {user}' ], |
|
67 | + LogLevel::ERROR => [ LogLevel::ERROR, 'message of level error with context: {user}' ], |
|
68 | + LogLevel::WARNING => [ LogLevel::WARNING, 'message of level warning with context: {user}' ], |
|
69 | + LogLevel::NOTICE => [ LogLevel::NOTICE, 'message of level notice with context: {user}' ], |
|
70 | + LogLevel::INFO => [ LogLevel::INFO, 'message of level info with context: {user}' ], |
|
71 | + LogLevel::DEBUG => [ LogLevel::DEBUG, 'message of level debug with context: {user}' ], |
|
72 | 72 | ]; |
73 | 73 | } |
74 | 74 | |
@@ -78,39 +78,39 @@ discard block |
||
78 | 78 | public function testThrowsOnInvalidLevel() |
79 | 79 | { |
80 | 80 | $logger = $this->getLogger(); |
81 | - $logger->log('invalid level', 'Foo'); |
|
81 | + $logger->log( 'invalid level', 'Foo' ); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | public function testContextReplacement() |
85 | 85 | { |
86 | 86 | $logger = $this->getLogger(); |
87 | - $logger->info('{Message {nothing} {user} {foo.bar} a}', ['user' => 'Bob', 'foo.bar' => 'Bar']); |
|
87 | + $logger->info( '{Message {nothing} {user} {foo.bar} a}', [ 'user' => 'Bob', 'foo.bar' => 'Bar' ] ); |
|
88 | 88 | |
89 | - $expected = ['info {Message {nothing} Bob Bar a}']; |
|
90 | - $this->assertEquals($expected, $this->getLogs()); |
|
89 | + $expected = [ 'info {Message {nothing} Bob Bar a}' ]; |
|
90 | + $this->assertEquals( $expected, $this->getLogs() ); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | public function testObjectCastToString() |
94 | 94 | { |
95 | - if (method_exists($this, 'createPartialMock')) { |
|
96 | - $dummy = $this->createPartialMock('GravityView\GravityView\Psr\Log\Test\DummyTest', ['__toString']); |
|
95 | + if ( method_exists( $this, 'createPartialMock' ) ) { |
|
96 | + $dummy = $this->createPartialMock( 'GravityView\GravityView\Psr\Log\Test\DummyTest', [ '__toString' ] ); |
|
97 | 97 | } else { |
98 | - $dummy = $this->getMock('GravityView\GravityView\Psr\Log\Test\DummyTest', ['__toString']); |
|
98 | + $dummy = $this->getMock( 'GravityView\GravityView\Psr\Log\Test\DummyTest', [ '__toString' ] ); |
|
99 | 99 | } |
100 | - $dummy->expects($this->once()) |
|
101 | - ->method('__toString') |
|
102 | - ->will($this->returnValue('DUMMY')); |
|
100 | + $dummy->expects( $this->once() ) |
|
101 | + ->method( '__toString' ) |
|
102 | + ->will( $this->returnValue( 'DUMMY' ) ); |
|
103 | 103 | |
104 | - $this->getLogger()->warning($dummy); |
|
104 | + $this->getLogger()->warning( $dummy ); |
|
105 | 105 | |
106 | - $expected = ['warning DUMMY']; |
|
107 | - $this->assertEquals($expected, $this->getLogs()); |
|
106 | + $expected = [ 'warning DUMMY' ]; |
|
107 | + $this->assertEquals( $expected, $this->getLogs() ); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | public function testContextCanContainAnything() |
111 | 111 | { |
112 | - $closed = fopen('php://memory', 'r'); |
|
113 | - fclose($closed); |
|
112 | + $closed = fopen( 'php://memory', 'r' ); |
|
113 | + fclose( $closed ); |
|
114 | 114 | |
115 | 115 | $context = [ |
116 | 116 | 'bool' => true, |
@@ -118,28 +118,28 @@ discard block |
||
118 | 118 | 'string' => 'Foo', |
119 | 119 | 'int' => 0, |
120 | 120 | 'float' => 0.5, |
121 | - 'nested' => ['with object' => new DummyTest()], |
|
121 | + 'nested' => [ 'with object' => new DummyTest() ], |
|
122 | 122 | 'object' => new \DateTime(), |
123 | - 'resource' => fopen('php://memory', 'r'), |
|
123 | + 'resource' => fopen( 'php://memory', 'r' ), |
|
124 | 124 | 'closed' => $closed, |
125 | 125 | ]; |
126 | 126 | |
127 | - $this->getLogger()->warning('Crazy context data', $context); |
|
127 | + $this->getLogger()->warning( 'Crazy context data', $context ); |
|
128 | 128 | |
129 | - $expected = ['warning Crazy context data']; |
|
130 | - $this->assertEquals($expected, $this->getLogs()); |
|
129 | + $expected = [ 'warning Crazy context data' ]; |
|
130 | + $this->assertEquals( $expected, $this->getLogs() ); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | public function testContextExceptionKeyCanBeExceptionOrOtherValues() |
134 | 134 | { |
135 | 135 | $logger = $this->getLogger(); |
136 | - $logger->warning('Random message', ['exception' => 'oops']); |
|
137 | - $logger->critical('Uncaught Exception!', ['exception' => new \LogicException('Fail')]); |
|
136 | + $logger->warning( 'Random message', [ 'exception' => 'oops' ] ); |
|
137 | + $logger->critical( 'Uncaught Exception!', [ 'exception' => new \LogicException( 'Fail' ) ] ); |
|
138 | 138 | |
139 | 139 | $expected = [ |
140 | 140 | 'warning Random message', |
141 | 141 | 'critical Uncaught Exception!', |
142 | 142 | ]; |
143 | - $this->assertEquals($expected, $this->getLogs()); |
|
143 | + $this->assertEquals( $expected, $this->getLogs() ); |
|
144 | 144 | } |
145 | 145 | } |
@@ -19,8 +19,7 @@ discard block |
||
19 | 19 | * Implementors can extend the class and implement abstract methods to run this |
20 | 20 | * as part of their test suite. |
21 | 21 | */ |
22 | -abstract class LoggerInterfaceTest extends TestCase |
|
23 | -{ |
|
22 | +abstract class LoggerInterfaceTest extends TestCase { |
|
24 | 23 | /** |
25 | 24 | * @return LoggerInterface |
26 | 25 | */ |
@@ -37,16 +36,14 @@ discard block |
||
37 | 36 | */ |
38 | 37 | abstract public function getLogs(); |
39 | 38 | |
40 | - public function testImplements() |
|
41 | - { |
|
39 | + public function testImplements() { |
|
42 | 40 | $this->assertInstanceOf('GravityView\Psr\Log\LoggerInterface', $this->getLogger()); |
43 | 41 | } |
44 | 42 | |
45 | 43 | /** |
46 | 44 | * @dataProvider provideLevelsAndMessages |
47 | 45 | */ |
48 | - public function testLogsAtAllLevels($level, $message) |
|
49 | - { |
|
46 | + public function testLogsAtAllLevels($level, $message) { |
|
50 | 47 | $logger = $this->getLogger(); |
51 | 48 | $logger->{$level}($message, ['user' => 'Bob']); |
52 | 49 | $logger->log($level, $message, ['user' => 'Bob']); |
@@ -58,8 +55,7 @@ discard block |
||
58 | 55 | $this->assertEquals($expected, $this->getLogs()); |
59 | 56 | } |
60 | 57 | |
61 | - public function provideLevelsAndMessages() |
|
62 | - { |
|
58 | + public function provideLevelsAndMessages() { |
|
63 | 59 | return [ |
64 | 60 | LogLevel::EMERGENCY => [LogLevel::EMERGENCY, 'message of level emergency with context: {user}'], |
65 | 61 | LogLevel::ALERT => [LogLevel::ALERT, 'message of level alert with context: {user}'], |
@@ -75,14 +71,12 @@ discard block |
||
75 | 71 | /** |
76 | 72 | * @expectedException \GravityView\Psr\Log\InvalidArgumentException |
77 | 73 | */ |
78 | - public function testThrowsOnInvalidLevel() |
|
79 | - { |
|
74 | + public function testThrowsOnInvalidLevel() { |
|
80 | 75 | $logger = $this->getLogger(); |
81 | 76 | $logger->log('invalid level', 'Foo'); |
82 | 77 | } |
83 | 78 | |
84 | - public function testContextReplacement() |
|
85 | - { |
|
79 | + public function testContextReplacement() { |
|
86 | 80 | $logger = $this->getLogger(); |
87 | 81 | $logger->info('{Message {nothing} {user} {foo.bar} a}', ['user' => 'Bob', 'foo.bar' => 'Bar']); |
88 | 82 | |
@@ -90,8 +84,7 @@ discard block |
||
90 | 84 | $this->assertEquals($expected, $this->getLogs()); |
91 | 85 | } |
92 | 86 | |
93 | - public function testObjectCastToString() |
|
94 | - { |
|
87 | + public function testObjectCastToString() { |
|
95 | 88 | if (method_exists($this, 'createPartialMock')) { |
96 | 89 | $dummy = $this->createPartialMock('GravityView\GravityView\Psr\Log\Test\DummyTest', ['__toString']); |
97 | 90 | } else { |
@@ -107,8 +100,7 @@ discard block |
||
107 | 100 | $this->assertEquals($expected, $this->getLogs()); |
108 | 101 | } |
109 | 102 | |
110 | - public function testContextCanContainAnything() |
|
111 | - { |
|
103 | + public function testContextCanContainAnything() { |
|
112 | 104 | $closed = fopen('php://memory', 'r'); |
113 | 105 | fclose($closed); |
114 | 106 | |
@@ -130,8 +122,7 @@ discard block |
||
130 | 122 | $this->assertEquals($expected, $this->getLogs()); |
131 | 123 | } |
132 | 124 | |
133 | - public function testContextExceptionKeyCanBeExceptionOrOtherValues() |
|
134 | - { |
|
125 | + public function testContextExceptionKeyCanBeExceptionOrOtherValues() { |
|
135 | 126 | $logger = $this->getLogger(); |
136 | 127 | $logger->warning('Random message', ['exception' => 'oops']); |
137 | 128 | $logger->critical('Uncaught Exception!', ['exception' => new \LogicException('Fail')]); |
@@ -59,97 +59,97 @@ |
||
59 | 59 | */ |
60 | 60 | class TestLogger extends AbstractLogger |
61 | 61 | { |
62 | - /** |
|
63 | - * @var array |
|
64 | - */ |
|
65 | - public $records = []; |
|
66 | - |
|
67 | - public $recordsByLevel = []; |
|
68 | - |
|
69 | - /** |
|
70 | - * @inheritdoc |
|
71 | - */ |
|
72 | - public function log($level, $message, array $context = []) |
|
73 | - { |
|
74 | - $record = [ |
|
75 | - 'level' => $level, |
|
76 | - 'message' => $message, |
|
77 | - 'context' => $context, |
|
78 | - ]; |
|
79 | - |
|
80 | - $this->recordsByLevel[$record['level']][] = $record; |
|
81 | - $this->records[] = $record; |
|
82 | - } |
|
83 | - |
|
84 | - public function hasRecords($level) |
|
85 | - { |
|
86 | - return isset($this->recordsByLevel[$level]); |
|
87 | - } |
|
88 | - |
|
89 | - public function hasRecord($record, $level) |
|
90 | - { |
|
91 | - if (is_string($record)) { |
|
92 | - $record = ['message' => $record]; |
|
93 | - } |
|
94 | - |
|
95 | - return $this->hasRecordThatPasses(function ($rec) use ($record) { |
|
96 | - if ($rec['message'] !== $record['message']) { |
|
97 | - return false; |
|
98 | - } |
|
99 | - if (isset($record['context']) && $rec['context'] !== $record['context']) { |
|
100 | - return false; |
|
101 | - } |
|
102 | - |
|
103 | - return true; |
|
104 | - }, $level); |
|
105 | - } |
|
106 | - |
|
107 | - public function hasRecordThatContains($message, $level) |
|
108 | - { |
|
109 | - return $this->hasRecordThatPasses(function ($rec) use ($message) { |
|
110 | - return strpos($rec['message'], $message) !== false; |
|
111 | - }, $level); |
|
112 | - } |
|
113 | - |
|
114 | - public function hasRecordThatMatches($regex, $level) |
|
115 | - { |
|
116 | - return $this->hasRecordThatPasses(function ($rec) use ($regex) { |
|
117 | - return preg_match($regex, $rec['message']) > 0; |
|
118 | - }, $level); |
|
119 | - } |
|
120 | - |
|
121 | - public function hasRecordThatPasses(callable $predicate, $level) |
|
122 | - { |
|
123 | - if (!isset($this->recordsByLevel[$level])) { |
|
124 | - return false; |
|
125 | - } |
|
126 | - foreach ($this->recordsByLevel[$level] as $i => $rec) { |
|
127 | - if (call_user_func($predicate, $rec, $i)) { |
|
128 | - return true; |
|
129 | - } |
|
130 | - } |
|
131 | - |
|
132 | - return false; |
|
133 | - } |
|
134 | - |
|
135 | - public function __call($method, $args) |
|
136 | - { |
|
137 | - if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) { |
|
138 | - $genericMethod = $matches[1].('Records' !== $matches[3] ? 'Record' : '').$matches[3]; |
|
139 | - $level = strtolower($matches[2]); |
|
140 | - if (method_exists($this, $genericMethod)) { |
|
141 | - $args[] = $level; |
|
142 | - |
|
143 | - return call_user_func_array([$this, $genericMethod], $args); |
|
144 | - } |
|
145 | - } |
|
146 | - |
|
147 | - throw new \BadMethodCallException('Call to undefined method '.get_class($this).'::'.$method.'()'); |
|
148 | - } |
|
149 | - |
|
150 | - public function reset() |
|
151 | - { |
|
152 | - $this->records = []; |
|
153 | - $this->recordsByLevel = []; |
|
154 | - } |
|
62 | + /** |
|
63 | + * @var array |
|
64 | + */ |
|
65 | + public $records = []; |
|
66 | + |
|
67 | + public $recordsByLevel = []; |
|
68 | + |
|
69 | + /** |
|
70 | + * @inheritdoc |
|
71 | + */ |
|
72 | + public function log($level, $message, array $context = []) |
|
73 | + { |
|
74 | + $record = [ |
|
75 | + 'level' => $level, |
|
76 | + 'message' => $message, |
|
77 | + 'context' => $context, |
|
78 | + ]; |
|
79 | + |
|
80 | + $this->recordsByLevel[$record['level']][] = $record; |
|
81 | + $this->records[] = $record; |
|
82 | + } |
|
83 | + |
|
84 | + public function hasRecords($level) |
|
85 | + { |
|
86 | + return isset($this->recordsByLevel[$level]); |
|
87 | + } |
|
88 | + |
|
89 | + public function hasRecord($record, $level) |
|
90 | + { |
|
91 | + if (is_string($record)) { |
|
92 | + $record = ['message' => $record]; |
|
93 | + } |
|
94 | + |
|
95 | + return $this->hasRecordThatPasses(function ($rec) use ($record) { |
|
96 | + if ($rec['message'] !== $record['message']) { |
|
97 | + return false; |
|
98 | + } |
|
99 | + if (isset($record['context']) && $rec['context'] !== $record['context']) { |
|
100 | + return false; |
|
101 | + } |
|
102 | + |
|
103 | + return true; |
|
104 | + }, $level); |
|
105 | + } |
|
106 | + |
|
107 | + public function hasRecordThatContains($message, $level) |
|
108 | + { |
|
109 | + return $this->hasRecordThatPasses(function ($rec) use ($message) { |
|
110 | + return strpos($rec['message'], $message) !== false; |
|
111 | + }, $level); |
|
112 | + } |
|
113 | + |
|
114 | + public function hasRecordThatMatches($regex, $level) |
|
115 | + { |
|
116 | + return $this->hasRecordThatPasses(function ($rec) use ($regex) { |
|
117 | + return preg_match($regex, $rec['message']) > 0; |
|
118 | + }, $level); |
|
119 | + } |
|
120 | + |
|
121 | + public function hasRecordThatPasses(callable $predicate, $level) |
|
122 | + { |
|
123 | + if (!isset($this->recordsByLevel[$level])) { |
|
124 | + return false; |
|
125 | + } |
|
126 | + foreach ($this->recordsByLevel[$level] as $i => $rec) { |
|
127 | + if (call_user_func($predicate, $rec, $i)) { |
|
128 | + return true; |
|
129 | + } |
|
130 | + } |
|
131 | + |
|
132 | + return false; |
|
133 | + } |
|
134 | + |
|
135 | + public function __call($method, $args) |
|
136 | + { |
|
137 | + if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) { |
|
138 | + $genericMethod = $matches[1].('Records' !== $matches[3] ? 'Record' : '').$matches[3]; |
|
139 | + $level = strtolower($matches[2]); |
|
140 | + if (method_exists($this, $genericMethod)) { |
|
141 | + $args[] = $level; |
|
142 | + |
|
143 | + return call_user_func_array([$this, $genericMethod], $args); |
|
144 | + } |
|
145 | + } |
|
146 | + |
|
147 | + throw new \BadMethodCallException('Call to undefined method '.get_class($this).'::'.$method.'()'); |
|
148 | + } |
|
149 | + |
|
150 | + public function reset() |
|
151 | + { |
|
152 | + $this->records = []; |
|
153 | + $this->recordsByLevel = []; |
|
154 | + } |
|
155 | 155 | } |
@@ -62,14 +62,14 @@ discard block |
||
62 | 62 | /** |
63 | 63 | * @var array |
64 | 64 | */ |
65 | - public $records = []; |
|
65 | + public $records = [ ]; |
|
66 | 66 | |
67 | - public $recordsByLevel = []; |
|
67 | + public $recordsByLevel = [ ]; |
|
68 | 68 | |
69 | 69 | /** |
70 | 70 | * @inheritdoc |
71 | 71 | */ |
72 | - public function log($level, $message, array $context = []) |
|
72 | + public function log( $level, $message, array $context = [ ] ) |
|
73 | 73 | { |
74 | 74 | $record = [ |
75 | 75 | 'level' => $level, |
@@ -77,54 +77,54 @@ discard block |
||
77 | 77 | 'context' => $context, |
78 | 78 | ]; |
79 | 79 | |
80 | - $this->recordsByLevel[$record['level']][] = $record; |
|
81 | - $this->records[] = $record; |
|
80 | + $this->recordsByLevel[ $record[ 'level' ] ][ ] = $record; |
|
81 | + $this->records[ ] = $record; |
|
82 | 82 | } |
83 | 83 | |
84 | - public function hasRecords($level) |
|
84 | + public function hasRecords( $level ) |
|
85 | 85 | { |
86 | - return isset($this->recordsByLevel[$level]); |
|
86 | + return isset( $this->recordsByLevel[ $level ] ); |
|
87 | 87 | } |
88 | 88 | |
89 | - public function hasRecord($record, $level) |
|
89 | + public function hasRecord( $record, $level ) |
|
90 | 90 | { |
91 | - if (is_string($record)) { |
|
92 | - $record = ['message' => $record]; |
|
91 | + if ( is_string( $record ) ) { |
|
92 | + $record = [ 'message' => $record ]; |
|
93 | 93 | } |
94 | 94 | |
95 | - return $this->hasRecordThatPasses(function ($rec) use ($record) { |
|
96 | - if ($rec['message'] !== $record['message']) { |
|
95 | + return $this->hasRecordThatPasses( function( $rec ) use ( $record ) { |
|
96 | + if ( $rec[ 'message' ] !== $record[ 'message' ] ) { |
|
97 | 97 | return false; |
98 | 98 | } |
99 | - if (isset($record['context']) && $rec['context'] !== $record['context']) { |
|
99 | + if ( isset( $record[ 'context' ] ) && $rec[ 'context' ] !== $record[ 'context' ] ) { |
|
100 | 100 | return false; |
101 | 101 | } |
102 | 102 | |
103 | 103 | return true; |
104 | - }, $level); |
|
104 | + }, $level ); |
|
105 | 105 | } |
106 | 106 | |
107 | - public function hasRecordThatContains($message, $level) |
|
107 | + public function hasRecordThatContains( $message, $level ) |
|
108 | 108 | { |
109 | - return $this->hasRecordThatPasses(function ($rec) use ($message) { |
|
110 | - return strpos($rec['message'], $message) !== false; |
|
111 | - }, $level); |
|
109 | + return $this->hasRecordThatPasses( function( $rec ) use ( $message ) { |
|
110 | + return strpos( $rec[ 'message' ], $message ) !== false; |
|
111 | + }, $level ); |
|
112 | 112 | } |
113 | 113 | |
114 | - public function hasRecordThatMatches($regex, $level) |
|
114 | + public function hasRecordThatMatches( $regex, $level ) |
|
115 | 115 | { |
116 | - return $this->hasRecordThatPasses(function ($rec) use ($regex) { |
|
117 | - return preg_match($regex, $rec['message']) > 0; |
|
118 | - }, $level); |
|
116 | + return $this->hasRecordThatPasses( function( $rec ) use ( $regex ) { |
|
117 | + return preg_match( $regex, $rec[ 'message' ] ) > 0; |
|
118 | + }, $level ); |
|
119 | 119 | } |
120 | 120 | |
121 | - public function hasRecordThatPasses(callable $predicate, $level) |
|
121 | + public function hasRecordThatPasses( callable $predicate, $level ) |
|
122 | 122 | { |
123 | - if (!isset($this->recordsByLevel[$level])) { |
|
123 | + if ( ! isset( $this->recordsByLevel[ $level ] ) ) { |
|
124 | 124 | return false; |
125 | 125 | } |
126 | - foreach ($this->recordsByLevel[$level] as $i => $rec) { |
|
127 | - if (call_user_func($predicate, $rec, $i)) { |
|
126 | + foreach ( $this->recordsByLevel[ $level ] as $i => $rec ) { |
|
127 | + if ( call_user_func( $predicate, $rec, $i ) ) { |
|
128 | 128 | return true; |
129 | 129 | } |
130 | 130 | } |
@@ -132,24 +132,24 @@ discard block |
||
132 | 132 | return false; |
133 | 133 | } |
134 | 134 | |
135 | - public function __call($method, $args) |
|
135 | + public function __call( $method, $args ) |
|
136 | 136 | { |
137 | - if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) { |
|
138 | - $genericMethod = $matches[1].('Records' !== $matches[3] ? 'Record' : '').$matches[3]; |
|
139 | - $level = strtolower($matches[2]); |
|
140 | - if (method_exists($this, $genericMethod)) { |
|
141 | - $args[] = $level; |
|
137 | + if ( preg_match( '/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches ) > 0 ) { |
|
138 | + $genericMethod = $matches[ 1 ] . ( 'Records' !== $matches[ 3 ] ? 'Record' : '' ) . $matches[ 3 ]; |
|
139 | + $level = strtolower( $matches[ 2 ] ); |
|
140 | + if ( method_exists( $this, $genericMethod ) ) { |
|
141 | + $args[ ] = $level; |
|
142 | 142 | |
143 | - return call_user_func_array([$this, $genericMethod], $args); |
|
143 | + return call_user_func_array( [ $this, $genericMethod ], $args ); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
147 | - throw new \BadMethodCallException('Call to undefined method '.get_class($this).'::'.$method.'()'); |
|
147 | + throw new \BadMethodCallException( 'Call to undefined method ' . get_class( $this ) . '::' . $method . '()' ); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | public function reset() |
151 | 151 | { |
152 | - $this->records = []; |
|
153 | - $this->recordsByLevel = []; |
|
152 | + $this->records = [ ]; |
|
153 | + $this->recordsByLevel = [ ]; |
|
154 | 154 | } |
155 | 155 | } |
@@ -57,8 +57,7 @@ discard block |
||
57 | 57 | * @method bool hasInfoThatPasses($message) |
58 | 58 | * @method bool hasDebugThatPasses($message) |
59 | 59 | */ |
60 | -class TestLogger extends AbstractLogger |
|
61 | -{ |
|
60 | +class TestLogger extends AbstractLogger { |
|
62 | 61 | /** |
63 | 62 | * @var array |
64 | 63 | */ |
@@ -69,8 +68,7 @@ discard block |
||
69 | 68 | /** |
70 | 69 | * @inheritdoc |
71 | 70 | */ |
72 | - public function log($level, $message, array $context = []) |
|
73 | - { |
|
71 | + public function log($level, $message, array $context = []) { |
|
74 | 72 | $record = [ |
75 | 73 | 'level' => $level, |
76 | 74 | 'message' => $message, |
@@ -81,13 +79,11 @@ discard block |
||
81 | 79 | $this->records[] = $record; |
82 | 80 | } |
83 | 81 | |
84 | - public function hasRecords($level) |
|
85 | - { |
|
82 | + public function hasRecords($level) { |
|
86 | 83 | return isset($this->recordsByLevel[$level]); |
87 | 84 | } |
88 | 85 | |
89 | - public function hasRecord($record, $level) |
|
90 | - { |
|
86 | + public function hasRecord($record, $level) { |
|
91 | 87 | if (is_string($record)) { |
92 | 88 | $record = ['message' => $record]; |
93 | 89 | } |
@@ -104,22 +100,19 @@ discard block |
||
104 | 100 | }, $level); |
105 | 101 | } |
106 | 102 | |
107 | - public function hasRecordThatContains($message, $level) |
|
108 | - { |
|
103 | + public function hasRecordThatContains($message, $level) { |
|
109 | 104 | return $this->hasRecordThatPasses(function ($rec) use ($message) { |
110 | 105 | return strpos($rec['message'], $message) !== false; |
111 | 106 | }, $level); |
112 | 107 | } |
113 | 108 | |
114 | - public function hasRecordThatMatches($regex, $level) |
|
115 | - { |
|
109 | + public function hasRecordThatMatches($regex, $level) { |
|
116 | 110 | return $this->hasRecordThatPasses(function ($rec) use ($regex) { |
117 | 111 | return preg_match($regex, $rec['message']) > 0; |
118 | 112 | }, $level); |
119 | 113 | } |
120 | 114 | |
121 | - public function hasRecordThatPasses(callable $predicate, $level) |
|
122 | - { |
|
115 | + public function hasRecordThatPasses(callable $predicate, $level) { |
|
123 | 116 | if (!isset($this->recordsByLevel[$level])) { |
124 | 117 | return false; |
125 | 118 | } |
@@ -132,8 +125,7 @@ discard block |
||
132 | 125 | return false; |
133 | 126 | } |
134 | 127 | |
135 | - public function __call($method, $args) |
|
136 | - { |
|
128 | + public function __call($method, $args) { |
|
137 | 129 | if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) { |
138 | 130 | $genericMethod = $matches[1].('Records' !== $matches[3] ? 'Record' : '').$matches[3]; |
139 | 131 | $level = strtolower($matches[2]); |
@@ -147,8 +139,7 @@ discard block |
||
147 | 139 | throw new \BadMethodCallException('Call to undefined method '.get_class($this).'::'.$method.'()'); |
148 | 140 | } |
149 | 141 | |
150 | - public function reset() |
|
151 | - { |
|
142 | + public function reset() { |
|
152 | 143 | $this->records = []; |
153 | 144 | $this->recordsByLevel = []; |
154 | 145 | } |
@@ -19,19 +19,19 @@ |
||
19 | 19 | */ |
20 | 20 | class NullLogger extends AbstractLogger |
21 | 21 | { |
22 | - /** |
|
23 | - * Logs with an arbitrary level. |
|
24 | - * |
|
25 | - * @param mixed $level |
|
26 | - * @param string $message |
|
27 | - * @param array $context |
|
28 | - * |
|
29 | - * @throws \GravityView\Psr\Log\InvalidArgumentException |
|
30 | - * |
|
31 | - * @return void |
|
32 | - */ |
|
33 | - public function log($level, $message, array $context = []) |
|
34 | - { |
|
35 | - // noop |
|
36 | - } |
|
22 | + /** |
|
23 | + * Logs with an arbitrary level. |
|
24 | + * |
|
25 | + * @param mixed $level |
|
26 | + * @param string $message |
|
27 | + * @param array $context |
|
28 | + * |
|
29 | + * @throws \GravityView\Psr\Log\InvalidArgumentException |
|
30 | + * |
|
31 | + * @return void |
|
32 | + */ |
|
33 | + public function log($level, $message, array $context = []) |
|
34 | + { |
|
35 | + // noop |
|
36 | + } |
|
37 | 37 | } |
@@ -30,7 +30,7 @@ |
||
30 | 30 | * |
31 | 31 | * @return void |
32 | 32 | */ |
33 | - public function log($level, $message, array $context = []) |
|
33 | + public function log( $level, $message, array $context = [ ] ) |
|
34 | 34 | { |
35 | 35 | // noop |
36 | 36 | } |
@@ -17,8 +17,7 @@ discard block |
||
17 | 17 | * is a good way to avoid littering your code with `if ($this->logger) { }` |
18 | 18 | * blocks. |
19 | 19 | */ |
20 | -class NullLogger extends AbstractLogger |
|
21 | -{ |
|
20 | +class NullLogger extends AbstractLogger { |
|
22 | 21 | /** |
23 | 22 | * Logs with an arbitrary level. |
24 | 23 | * |
@@ -30,8 +29,7 @@ discard block |
||
30 | 29 | * |
31 | 30 | * @return void |
32 | 31 | */ |
33 | - public function log($level, $message, array $context = []) |
|
34 | - { |
|
32 | + public function log($level, $message, array $context = []) { |
|
35 | 33 | // noop |
36 | 34 | } |
37 | 35 | } |
@@ -19,131 +19,131 @@ |
||
19 | 19 | */ |
20 | 20 | trait LoggerTrait |
21 | 21 | { |
22 | - /** |
|
23 | - * System is unusable. |
|
24 | - * |
|
25 | - * @param string $message |
|
26 | - * @param array $context |
|
27 | - * |
|
28 | - * @return void |
|
29 | - */ |
|
30 | - public function emergency($message, array $context = []) |
|
31 | - { |
|
32 | - $this->log(LogLevel::EMERGENCY, $message, $context); |
|
33 | - } |
|
22 | + /** |
|
23 | + * System is unusable. |
|
24 | + * |
|
25 | + * @param string $message |
|
26 | + * @param array $context |
|
27 | + * |
|
28 | + * @return void |
|
29 | + */ |
|
30 | + public function emergency($message, array $context = []) |
|
31 | + { |
|
32 | + $this->log(LogLevel::EMERGENCY, $message, $context); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Action must be taken immediately. |
|
37 | - * |
|
38 | - * Example: Entire website down, database unavailable, etc. This should |
|
39 | - * trigger the SMS alerts and wake you up. |
|
40 | - * |
|
41 | - * @param string $message |
|
42 | - * @param array $context |
|
43 | - * |
|
44 | - * @return void |
|
45 | - */ |
|
46 | - public function alert($message, array $context = []) |
|
47 | - { |
|
48 | - $this->log(LogLevel::ALERT, $message, $context); |
|
49 | - } |
|
35 | + /** |
|
36 | + * Action must be taken immediately. |
|
37 | + * |
|
38 | + * Example: Entire website down, database unavailable, etc. This should |
|
39 | + * trigger the SMS alerts and wake you up. |
|
40 | + * |
|
41 | + * @param string $message |
|
42 | + * @param array $context |
|
43 | + * |
|
44 | + * @return void |
|
45 | + */ |
|
46 | + public function alert($message, array $context = []) |
|
47 | + { |
|
48 | + $this->log(LogLevel::ALERT, $message, $context); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * Critical conditions. |
|
53 | - * |
|
54 | - * Example: Application component unavailable, unexpected exception. |
|
55 | - * |
|
56 | - * @param string $message |
|
57 | - * @param array $context |
|
58 | - * |
|
59 | - * @return void |
|
60 | - */ |
|
61 | - public function critical($message, array $context = []) |
|
62 | - { |
|
63 | - $this->log(LogLevel::CRITICAL, $message, $context); |
|
64 | - } |
|
51 | + /** |
|
52 | + * Critical conditions. |
|
53 | + * |
|
54 | + * Example: Application component unavailable, unexpected exception. |
|
55 | + * |
|
56 | + * @param string $message |
|
57 | + * @param array $context |
|
58 | + * |
|
59 | + * @return void |
|
60 | + */ |
|
61 | + public function critical($message, array $context = []) |
|
62 | + { |
|
63 | + $this->log(LogLevel::CRITICAL, $message, $context); |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * Runtime errors that do not require immediate action but should typically |
|
68 | - * be logged and monitored. |
|
69 | - * |
|
70 | - * @param string $message |
|
71 | - * @param array $context |
|
72 | - * |
|
73 | - * @return void |
|
74 | - */ |
|
75 | - public function error($message, array $context = []) |
|
76 | - { |
|
77 | - $this->log(LogLevel::ERROR, $message, $context); |
|
78 | - } |
|
66 | + /** |
|
67 | + * Runtime errors that do not require immediate action but should typically |
|
68 | + * be logged and monitored. |
|
69 | + * |
|
70 | + * @param string $message |
|
71 | + * @param array $context |
|
72 | + * |
|
73 | + * @return void |
|
74 | + */ |
|
75 | + public function error($message, array $context = []) |
|
76 | + { |
|
77 | + $this->log(LogLevel::ERROR, $message, $context); |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * Exceptional occurrences that are not errors. |
|
82 | - * |
|
83 | - * Example: Use of deprecated APIs, poor use of an API, undesirable things |
|
84 | - * that are not necessarily wrong. |
|
85 | - * |
|
86 | - * @param string $message |
|
87 | - * @param array $context |
|
88 | - * |
|
89 | - * @return void |
|
90 | - */ |
|
91 | - public function warning($message, array $context = []) |
|
92 | - { |
|
93 | - $this->log(LogLevel::WARNING, $message, $context); |
|
94 | - } |
|
80 | + /** |
|
81 | + * Exceptional occurrences that are not errors. |
|
82 | + * |
|
83 | + * Example: Use of deprecated APIs, poor use of an API, undesirable things |
|
84 | + * that are not necessarily wrong. |
|
85 | + * |
|
86 | + * @param string $message |
|
87 | + * @param array $context |
|
88 | + * |
|
89 | + * @return void |
|
90 | + */ |
|
91 | + public function warning($message, array $context = []) |
|
92 | + { |
|
93 | + $this->log(LogLevel::WARNING, $message, $context); |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * Normal but significant events. |
|
98 | - * |
|
99 | - * @param string $message |
|
100 | - * @param array $context |
|
101 | - * |
|
102 | - * @return void |
|
103 | - */ |
|
104 | - public function notice($message, array $context = []) |
|
105 | - { |
|
106 | - $this->log(LogLevel::NOTICE, $message, $context); |
|
107 | - } |
|
96 | + /** |
|
97 | + * Normal but significant events. |
|
98 | + * |
|
99 | + * @param string $message |
|
100 | + * @param array $context |
|
101 | + * |
|
102 | + * @return void |
|
103 | + */ |
|
104 | + public function notice($message, array $context = []) |
|
105 | + { |
|
106 | + $this->log(LogLevel::NOTICE, $message, $context); |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * Interesting events. |
|
111 | - * |
|
112 | - * Example: User logs in, SQL logs. |
|
113 | - * |
|
114 | - * @param string $message |
|
115 | - * @param array $context |
|
116 | - * |
|
117 | - * @return void |
|
118 | - */ |
|
119 | - public function info($message, array $context = []) |
|
120 | - { |
|
121 | - $this->log(LogLevel::INFO, $message, $context); |
|
122 | - } |
|
109 | + /** |
|
110 | + * Interesting events. |
|
111 | + * |
|
112 | + * Example: User logs in, SQL logs. |
|
113 | + * |
|
114 | + * @param string $message |
|
115 | + * @param array $context |
|
116 | + * |
|
117 | + * @return void |
|
118 | + */ |
|
119 | + public function info($message, array $context = []) |
|
120 | + { |
|
121 | + $this->log(LogLevel::INFO, $message, $context); |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
125 | - * Detailed debug information. |
|
126 | - * |
|
127 | - * @param string $message |
|
128 | - * @param array $context |
|
129 | - * |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - public function debug($message, array $context = []) |
|
133 | - { |
|
134 | - $this->log(LogLevel::DEBUG, $message, $context); |
|
135 | - } |
|
124 | + /** |
|
125 | + * Detailed debug information. |
|
126 | + * |
|
127 | + * @param string $message |
|
128 | + * @param array $context |
|
129 | + * |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + public function debug($message, array $context = []) |
|
133 | + { |
|
134 | + $this->log(LogLevel::DEBUG, $message, $context); |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * Logs with an arbitrary level. |
|
139 | - * |
|
140 | - * @param mixed $level |
|
141 | - * @param string $message |
|
142 | - * @param array $context |
|
143 | - * |
|
144 | - * @throws \GravityView\Psr\Log\InvalidArgumentException |
|
145 | - * |
|
146 | - * @return void |
|
147 | - */ |
|
148 | - abstract public function log($level, $message, array $context = []); |
|
137 | + /** |
|
138 | + * Logs with an arbitrary level. |
|
139 | + * |
|
140 | + * @param mixed $level |
|
141 | + * @param string $message |
|
142 | + * @param array $context |
|
143 | + * |
|
144 | + * @throws \GravityView\Psr\Log\InvalidArgumentException |
|
145 | + * |
|
146 | + * @return void |
|
147 | + */ |
|
148 | + abstract public function log($level, $message, array $context = []); |
|
149 | 149 | } |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @return void |
29 | 29 | */ |
30 | - public function emergency($message, array $context = []) |
|
30 | + public function emergency( $message, array $context = [ ] ) |
|
31 | 31 | { |
32 | - $this->log(LogLevel::EMERGENCY, $message, $context); |
|
32 | + $this->log( LogLevel::EMERGENCY, $message, $context ); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return void |
45 | 45 | */ |
46 | - public function alert($message, array $context = []) |
|
46 | + public function alert( $message, array $context = [ ] ) |
|
47 | 47 | { |
48 | - $this->log(LogLevel::ALERT, $message, $context); |
|
48 | + $this->log( LogLevel::ALERT, $message, $context ); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @return void |
60 | 60 | */ |
61 | - public function critical($message, array $context = []) |
|
61 | + public function critical( $message, array $context = [ ] ) |
|
62 | 62 | { |
63 | - $this->log(LogLevel::CRITICAL, $message, $context); |
|
63 | + $this->log( LogLevel::CRITICAL, $message, $context ); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @return void |
74 | 74 | */ |
75 | - public function error($message, array $context = []) |
|
75 | + public function error( $message, array $context = [ ] ) |
|
76 | 76 | { |
77 | - $this->log(LogLevel::ERROR, $message, $context); |
|
77 | + $this->log( LogLevel::ERROR, $message, $context ); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -88,9 +88,9 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return void |
90 | 90 | */ |
91 | - public function warning($message, array $context = []) |
|
91 | + public function warning( $message, array $context = [ ] ) |
|
92 | 92 | { |
93 | - $this->log(LogLevel::WARNING, $message, $context); |
|
93 | + $this->log( LogLevel::WARNING, $message, $context ); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return void |
103 | 103 | */ |
104 | - public function notice($message, array $context = []) |
|
104 | + public function notice( $message, array $context = [ ] ) |
|
105 | 105 | { |
106 | - $this->log(LogLevel::NOTICE, $message, $context); |
|
106 | + $this->log( LogLevel::NOTICE, $message, $context ); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @return void |
118 | 118 | */ |
119 | - public function info($message, array $context = []) |
|
119 | + public function info( $message, array $context = [ ] ) |
|
120 | 120 | { |
121 | - $this->log(LogLevel::INFO, $message, $context); |
|
121 | + $this->log( LogLevel::INFO, $message, $context ); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -129,9 +129,9 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @return void |
131 | 131 | */ |
132 | - public function debug($message, array $context = []) |
|
132 | + public function debug( $message, array $context = [ ] ) |
|
133 | 133 | { |
134 | - $this->log(LogLevel::DEBUG, $message, $context); |
|
134 | + $this->log( LogLevel::DEBUG, $message, $context ); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -145,5 +145,5 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @return void |
147 | 147 | */ |
148 | - abstract public function log($level, $message, array $context = []); |
|
148 | + abstract public function log( $level, $message, array $context = [ ] ); |
|
149 | 149 | } |
@@ -17,8 +17,7 @@ discard block |
||
17 | 17 | * reduce boilerplate code that a simple Logger that does the same thing with |
18 | 18 | * messages regardless of the error level has to implement. |
19 | 19 | */ |
20 | -trait LoggerTrait |
|
21 | -{ |
|
20 | +trait LoggerTrait { |
|
22 | 21 | /** |
23 | 22 | * System is unusable. |
24 | 23 | * |
@@ -27,8 +26,7 @@ discard block |
||
27 | 26 | * |
28 | 27 | * @return void |
29 | 28 | */ |
30 | - public function emergency($message, array $context = []) |
|
31 | - { |
|
29 | + public function emergency($message, array $context = []) { |
|
32 | 30 | $this->log(LogLevel::EMERGENCY, $message, $context); |
33 | 31 | } |
34 | 32 | |
@@ -43,8 +41,7 @@ discard block |
||
43 | 41 | * |
44 | 42 | * @return void |
45 | 43 | */ |
46 | - public function alert($message, array $context = []) |
|
47 | - { |
|
44 | + public function alert($message, array $context = []) { |
|
48 | 45 | $this->log(LogLevel::ALERT, $message, $context); |
49 | 46 | } |
50 | 47 | |
@@ -58,8 +55,7 @@ discard block |
||
58 | 55 | * |
59 | 56 | * @return void |
60 | 57 | */ |
61 | - public function critical($message, array $context = []) |
|
62 | - { |
|
58 | + public function critical($message, array $context = []) { |
|
63 | 59 | $this->log(LogLevel::CRITICAL, $message, $context); |
64 | 60 | } |
65 | 61 | |
@@ -72,8 +68,7 @@ discard block |
||
72 | 68 | * |
73 | 69 | * @return void |
74 | 70 | */ |
75 | - public function error($message, array $context = []) |
|
76 | - { |
|
71 | + public function error($message, array $context = []) { |
|
77 | 72 | $this->log(LogLevel::ERROR, $message, $context); |
78 | 73 | } |
79 | 74 | |
@@ -88,8 +83,7 @@ discard block |
||
88 | 83 | * |
89 | 84 | * @return void |
90 | 85 | */ |
91 | - public function warning($message, array $context = []) |
|
92 | - { |
|
86 | + public function warning($message, array $context = []) { |
|
93 | 87 | $this->log(LogLevel::WARNING, $message, $context); |
94 | 88 | } |
95 | 89 | |
@@ -101,8 +95,7 @@ discard block |
||
101 | 95 | * |
102 | 96 | * @return void |
103 | 97 | */ |
104 | - public function notice($message, array $context = []) |
|
105 | - { |
|
98 | + public function notice($message, array $context = []) { |
|
106 | 99 | $this->log(LogLevel::NOTICE, $message, $context); |
107 | 100 | } |
108 | 101 | |
@@ -116,8 +109,7 @@ discard block |
||
116 | 109 | * |
117 | 110 | * @return void |
118 | 111 | */ |
119 | - public function info($message, array $context = []) |
|
120 | - { |
|
112 | + public function info($message, array $context = []) { |
|
121 | 113 | $this->log(LogLevel::INFO, $message, $context); |
122 | 114 | } |
123 | 115 | |
@@ -129,8 +121,7 @@ discard block |
||
129 | 121 | * |
130 | 122 | * @return void |
131 | 123 | */ |
132 | - public function debug($message, array $context = []) |
|
133 | - { |
|
124 | + public function debug($message, array $context = []) { |
|
134 | 125 | $this->log(LogLevel::DEBUG, $message, $context); |
135 | 126 | } |
136 | 127 |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | /** If this file is called directly, abort. */ |
16 | 16 | if (!defined('ABSPATH')) { |
17 | - exit; |
|
17 | + exit; |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | /** Constants */ |
@@ -93,198 +93,198 @@ discard block |
||
93 | 93 | */ |
94 | 94 | final class GravityView_Plugin |
95 | 95 | { |
96 | - /** |
|
97 | - * @deprecated Use \GV\Plugin::$version |
|
98 | - */ |
|
99 | - const version = GV_PLUGIN_VERSION; |
|
100 | - |
|
101 | - private static $instance; |
|
102 | - |
|
103 | - /** |
|
104 | - * Singleton instance. |
|
105 | - * |
|
106 | - * @deprecated See \GV\Plugin |
|
107 | - * |
|
108 | - * @return GravityView_Plugin GravityView_Plugin object |
|
109 | - */ |
|
110 | - public static function getInstance() |
|
111 | - { |
|
112 | - if (empty(self::$instance)) { |
|
113 | - self::$instance = new self(); |
|
114 | - } |
|
115 | - |
|
116 | - return self::$instance; |
|
117 | - } |
|
118 | - |
|
119 | - /** |
|
120 | - * @deprecated See \GV\Plugin |
|
121 | - */ |
|
122 | - private function __construct() |
|
123 | - { |
|
124 | - gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
125 | - } |
|
126 | - |
|
127 | - /** |
|
128 | - * Include global plugin files. |
|
129 | - * |
|
130 | - * @deprecated Use gravityview()->plugin->include_legacy_core |
|
131 | - * @since 1.12 |
|
132 | - */ |
|
133 | - public function include_files() |
|
134 | - { |
|
135 | - gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
136 | - gravityview()->plugin->include_legacy_core(); |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * Check whether GravityView is network activated. |
|
141 | - * |
|
142 | - * @deprecated See \GV\Plugin |
|
143 | - * @since 1.7.6 |
|
144 | - * |
|
145 | - * @return bool |
|
146 | - */ |
|
147 | - public static function is_network_activated() |
|
148 | - { |
|
149 | - gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
150 | - |
|
151 | - return gravityview()->plugin->is_network_activated(); |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * Plugin activate function. |
|
156 | - * |
|
157 | - * @static |
|
158 | - * |
|
159 | - * @return void |
|
160 | - */ |
|
161 | - public static function activate() |
|
162 | - { |
|
163 | - gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
164 | - } |
|
165 | - |
|
166 | - /** |
|
167 | - * Plugin deactivate function. |
|
168 | - * |
|
169 | - * @deprecated see \GV\Plugin::deactivate() |
|
170 | - * |
|
171 | - * @return void |
|
172 | - */ |
|
173 | - public static function deactivate() |
|
174 | - { |
|
175 | - gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
176 | - } |
|
177 | - |
|
178 | - /** |
|
179 | - * Include the extension class. |
|
180 | - * |
|
181 | - * @deprecated The extension framework is included by default now. |
|
182 | - * @since 1.5.1 |
|
183 | - * |
|
184 | - * @return void |
|
185 | - */ |
|
186 | - public static function include_extension_framework() |
|
187 | - { |
|
188 | - gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * Load GravityView_Widget class. |
|
193 | - * |
|
194 | - * @deprecated The widget class is loaded elsewhere in legacy core. |
|
195 | - * @since 1.7.5.1 |
|
196 | - */ |
|
197 | - public static function include_widget_class() |
|
198 | - { |
|
199 | - gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
200 | - } |
|
201 | - |
|
202 | - /** |
|
203 | - * Loads the plugin's translated strings. |
|
204 | - * |
|
205 | - * @deprecated Use \GV\Plugin::load_textdomain() |
|
206 | - * |
|
207 | - * @return void |
|
208 | - */ |
|
209 | - public function load_plugin_textdomain() |
|
210 | - { |
|
211 | - gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
212 | - gravityview()->plugin->load_textdomain(); |
|
213 | - } |
|
214 | - |
|
215 | - /** |
|
216 | - * Check if is_admin(), and make sure not DOING_AJAX. |
|
217 | - * |
|
218 | - * @since 1.7.5 |
|
219 | - * @deprecated |
|
220 | - * @see \GV\Frontend_Request::is_admin via gravityview()->request->is_admin() |
|
221 | - * |
|
222 | - * @return bool |
|
223 | - */ |
|
224 | - public static function is_admin() |
|
225 | - { |
|
226 | - gravityview()->log->notice('\GravityView_Plugin::is_admin() is deprecated. Use \GV\Request::is_admin() instead.'); |
|
227 | - |
|
228 | - return gravityview()->request->is_admin(); |
|
229 | - } |
|
230 | - |
|
231 | - /** |
|
232 | - * Function to launch frontend objects. |
|
233 | - * |
|
234 | - * @since 1.17 Added $force param |
|
235 | - * |
|
236 | - * @param bool $force Whether to force loading |
|
237 | - * |
|
238 | - * @return void |
|
239 | - */ |
|
240 | - public function frontend_actions($force = false) |
|
241 | - { |
|
242 | - gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
243 | - gravityview()->plugin->include_legacy_frontend($force); |
|
244 | - } |
|
245 | - |
|
246 | - /** |
|
247 | - * Helper function to define the default widget areas. |
|
248 | - * |
|
249 | - * @deprecated Moved to GravityView_Widget::get_default_widget_areas() |
|
250 | - * |
|
251 | - * @return array definition for default widget areas |
|
252 | - */ |
|
253 | - public static function get_default_widget_areas() |
|
254 | - { |
|
255 | - return GravityView_Widget::get_default_widget_areas(); |
|
256 | - } |
|
257 | - |
|
258 | - /** DEBUG */ |
|
259 | - |
|
260 | - /** |
|
261 | - * Logs messages using Gravity Forms logging add-on. |
|
262 | - * |
|
263 | - * @param string $message log message |
|
264 | - * @param mixed $data Additional data to display |
|
265 | - * |
|
266 | - * @deprecated use gravityview()->log |
|
267 | - * |
|
268 | - * @return void |
|
269 | - */ |
|
270 | - public static function log_debug($message, $data = null) |
|
271 | - { |
|
272 | - gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
273 | - gravityview()->log->debug($message, $data); |
|
274 | - } |
|
275 | - |
|
276 | - /** |
|
277 | - * Logs messages using Gravity Forms logging add-on. |
|
278 | - * |
|
279 | - * @param string $message log message |
|
280 | - * |
|
281 | - * @deprecated use gravityview()->log |
|
282 | - * |
|
283 | - * @return void |
|
284 | - */ |
|
285 | - public static function log_error($message, $data = null) |
|
286 | - { |
|
287 | - gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
288 | - gravityview()->log->error($message, $data); |
|
289 | - } |
|
96 | + /** |
|
97 | + * @deprecated Use \GV\Plugin::$version |
|
98 | + */ |
|
99 | + const version = GV_PLUGIN_VERSION; |
|
100 | + |
|
101 | + private static $instance; |
|
102 | + |
|
103 | + /** |
|
104 | + * Singleton instance. |
|
105 | + * |
|
106 | + * @deprecated See \GV\Plugin |
|
107 | + * |
|
108 | + * @return GravityView_Plugin GravityView_Plugin object |
|
109 | + */ |
|
110 | + public static function getInstance() |
|
111 | + { |
|
112 | + if (empty(self::$instance)) { |
|
113 | + self::$instance = new self(); |
|
114 | + } |
|
115 | + |
|
116 | + return self::$instance; |
|
117 | + } |
|
118 | + |
|
119 | + /** |
|
120 | + * @deprecated See \GV\Plugin |
|
121 | + */ |
|
122 | + private function __construct() |
|
123 | + { |
|
124 | + gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
125 | + } |
|
126 | + |
|
127 | + /** |
|
128 | + * Include global plugin files. |
|
129 | + * |
|
130 | + * @deprecated Use gravityview()->plugin->include_legacy_core |
|
131 | + * @since 1.12 |
|
132 | + */ |
|
133 | + public function include_files() |
|
134 | + { |
|
135 | + gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
136 | + gravityview()->plugin->include_legacy_core(); |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * Check whether GravityView is network activated. |
|
141 | + * |
|
142 | + * @deprecated See \GV\Plugin |
|
143 | + * @since 1.7.6 |
|
144 | + * |
|
145 | + * @return bool |
|
146 | + */ |
|
147 | + public static function is_network_activated() |
|
148 | + { |
|
149 | + gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
150 | + |
|
151 | + return gravityview()->plugin->is_network_activated(); |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * Plugin activate function. |
|
156 | + * |
|
157 | + * @static |
|
158 | + * |
|
159 | + * @return void |
|
160 | + */ |
|
161 | + public static function activate() |
|
162 | + { |
|
163 | + gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * Plugin deactivate function. |
|
168 | + * |
|
169 | + * @deprecated see \GV\Plugin::deactivate() |
|
170 | + * |
|
171 | + * @return void |
|
172 | + */ |
|
173 | + public static function deactivate() |
|
174 | + { |
|
175 | + gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
176 | + } |
|
177 | + |
|
178 | + /** |
|
179 | + * Include the extension class. |
|
180 | + * |
|
181 | + * @deprecated The extension framework is included by default now. |
|
182 | + * @since 1.5.1 |
|
183 | + * |
|
184 | + * @return void |
|
185 | + */ |
|
186 | + public static function include_extension_framework() |
|
187 | + { |
|
188 | + gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * Load GravityView_Widget class. |
|
193 | + * |
|
194 | + * @deprecated The widget class is loaded elsewhere in legacy core. |
|
195 | + * @since 1.7.5.1 |
|
196 | + */ |
|
197 | + public static function include_widget_class() |
|
198 | + { |
|
199 | + gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
200 | + } |
|
201 | + |
|
202 | + /** |
|
203 | + * Loads the plugin's translated strings. |
|
204 | + * |
|
205 | + * @deprecated Use \GV\Plugin::load_textdomain() |
|
206 | + * |
|
207 | + * @return void |
|
208 | + */ |
|
209 | + public function load_plugin_textdomain() |
|
210 | + { |
|
211 | + gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
212 | + gravityview()->plugin->load_textdomain(); |
|
213 | + } |
|
214 | + |
|
215 | + /** |
|
216 | + * Check if is_admin(), and make sure not DOING_AJAX. |
|
217 | + * |
|
218 | + * @since 1.7.5 |
|
219 | + * @deprecated |
|
220 | + * @see \GV\Frontend_Request::is_admin via gravityview()->request->is_admin() |
|
221 | + * |
|
222 | + * @return bool |
|
223 | + */ |
|
224 | + public static function is_admin() |
|
225 | + { |
|
226 | + gravityview()->log->notice('\GravityView_Plugin::is_admin() is deprecated. Use \GV\Request::is_admin() instead.'); |
|
227 | + |
|
228 | + return gravityview()->request->is_admin(); |
|
229 | + } |
|
230 | + |
|
231 | + /** |
|
232 | + * Function to launch frontend objects. |
|
233 | + * |
|
234 | + * @since 1.17 Added $force param |
|
235 | + * |
|
236 | + * @param bool $force Whether to force loading |
|
237 | + * |
|
238 | + * @return void |
|
239 | + */ |
|
240 | + public function frontend_actions($force = false) |
|
241 | + { |
|
242 | + gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
243 | + gravityview()->plugin->include_legacy_frontend($force); |
|
244 | + } |
|
245 | + |
|
246 | + /** |
|
247 | + * Helper function to define the default widget areas. |
|
248 | + * |
|
249 | + * @deprecated Moved to GravityView_Widget::get_default_widget_areas() |
|
250 | + * |
|
251 | + * @return array definition for default widget areas |
|
252 | + */ |
|
253 | + public static function get_default_widget_areas() |
|
254 | + { |
|
255 | + return GravityView_Widget::get_default_widget_areas(); |
|
256 | + } |
|
257 | + |
|
258 | + /** DEBUG */ |
|
259 | + |
|
260 | + /** |
|
261 | + * Logs messages using Gravity Forms logging add-on. |
|
262 | + * |
|
263 | + * @param string $message log message |
|
264 | + * @param mixed $data Additional data to display |
|
265 | + * |
|
266 | + * @deprecated use gravityview()->log |
|
267 | + * |
|
268 | + * @return void |
|
269 | + */ |
|
270 | + public static function log_debug($message, $data = null) |
|
271 | + { |
|
272 | + gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
273 | + gravityview()->log->debug($message, $data); |
|
274 | + } |
|
275 | + |
|
276 | + /** |
|
277 | + * Logs messages using Gravity Forms logging add-on. |
|
278 | + * |
|
279 | + * @param string $message log message |
|
280 | + * |
|
281 | + * @deprecated use gravityview()->log |
|
282 | + * |
|
283 | + * @return void |
|
284 | + */ |
|
285 | + public static function log_error($message, $data = null) |
|
286 | + { |
|
287 | + gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
288 | + gravityview()->log->error($message, $data); |
|
289 | + } |
|
290 | 290 | } // end class GravityView_Plugin |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | */ |
14 | 14 | |
15 | 15 | /** If this file is called directly, abort. */ |
16 | -if (!defined('ABSPATH')) { |
|
16 | +if ( ! defined( 'ABSPATH' ) ) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -22,55 +22,55 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * The plugin version. |
24 | 24 | */ |
25 | -define('GV_PLUGIN_VERSION', '2.14.4'); |
|
25 | +define( 'GV_PLUGIN_VERSION', '2.14.4' ); |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Full path to the GravityView file. |
29 | 29 | * |
30 | 30 | * @define "GRAVITYVIEW_FILE" "./gravityview.php" |
31 | 31 | */ |
32 | -define('GRAVITYVIEW_FILE', __FILE__); |
|
32 | +define( 'GRAVITYVIEW_FILE', __FILE__ ); |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * The URL to this file, with trailing slash. |
36 | 36 | */ |
37 | -define('GRAVITYVIEW_URL', plugin_dir_url(__FILE__)); |
|
37 | +define( 'GRAVITYVIEW_URL', plugin_dir_url( __FILE__ ) ); |
|
38 | 38 | |
39 | 39 | /** @define "GRAVITYVIEW_DIR" "./" The absolute path to the plugin directory, with trailing slash */ |
40 | -define('GRAVITYVIEW_DIR', plugin_dir_path(__FILE__)); |
|
40 | +define( 'GRAVITYVIEW_DIR', plugin_dir_path( __FILE__ ) ); |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * GravityView requires at least this version of Gravity Forms to function properly. |
44 | 44 | */ |
45 | -define('GV_MIN_GF_VERSION', '2.3'); |
|
45 | +define( 'GV_MIN_GF_VERSION', '2.3' ); |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * GravityView will soon require at least this version of Gravity Forms to function properly. |
49 | 49 | * |
50 | 50 | * @since 1.19.4 |
51 | 51 | */ |
52 | -define('GV_FUTURE_MIN_GF_VERSION', '2.5'); |
|
52 | +define( 'GV_FUTURE_MIN_GF_VERSION', '2.5' ); |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * GravityView requires at least this version of WordPress to function properly. |
56 | 56 | * |
57 | 57 | * @since 1.12 |
58 | 58 | */ |
59 | -define('GV_MIN_WP_VERSION', '4.7.0'); |
|
59 | +define( 'GV_MIN_WP_VERSION', '4.7.0' ); |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * GravityView will soon require at least this version of WordPress to function properly. |
63 | 63 | * |
64 | 64 | * @since 2.9.3 |
65 | 65 | */ |
66 | -define('GV_FUTURE_MIN_WP_VERSION', '5.3'); |
|
66 | +define( 'GV_FUTURE_MIN_WP_VERSION', '5.3' ); |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * GravityView requires at least this version of PHP to function properly. |
70 | 70 | * |
71 | 71 | * @since 1.12 |
72 | 72 | */ |
73 | -define('GV_MIN_PHP_VERSION', '5.6.30'); |
|
73 | +define( 'GV_MIN_PHP_VERSION', '5.6.30' ); |
|
74 | 74 | |
75 | 75 | /** |
76 | 76 | * GravityView will require this version of PHP soon. False if no future PHP version changes are planned. |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @var string|false |
81 | 81 | */ |
82 | -define('GV_FUTURE_MIN_PHP_VERSION', '7.2'); |
|
82 | +define( 'GV_FUTURE_MIN_PHP_VERSION', '7.2' ); |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * The future is here and now. |
86 | 86 | */ |
87 | -require GRAVITYVIEW_DIR.'future/loader.php'; |
|
87 | +require GRAVITYVIEW_DIR . 'future/loader.php'; |
|
88 | 88 | |
89 | 89 | /** |
90 | 90 | * GravityView_Plugin main class. |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public static function getInstance() |
111 | 111 | { |
112 | - if (empty(self::$instance)) { |
|
112 | + if ( empty( self::$instance ) ) { |
|
113 | 113 | self::$instance = new self(); |
114 | 114 | } |
115 | 115 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | private function __construct() |
123 | 123 | { |
124 | - gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
124 | + gravityview()->log->notice( '\GravityView_Plugin is deprecated. Use \GV\Plugin instead.' ); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function include_files() |
134 | 134 | { |
135 | - gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
135 | + gravityview()->log->notice( '\GravityView_Plugin is deprecated. Use \GV\Plugin instead.' ); |
|
136 | 136 | gravityview()->plugin->include_legacy_core(); |
137 | 137 | } |
138 | 138 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public static function is_network_activated() |
148 | 148 | { |
149 | - gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
149 | + gravityview()->log->notice( '\GravityView_Plugin is deprecated. Use \GV\Plugin instead.' ); |
|
150 | 150 | |
151 | 151 | return gravityview()->plugin->is_network_activated(); |
152 | 152 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public static function activate() |
162 | 162 | { |
163 | - gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
163 | + gravityview()->log->notice( '\GravityView_Plugin is deprecated. Use \GV\Plugin instead.' ); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | */ |
173 | 173 | public static function deactivate() |
174 | 174 | { |
175 | - gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
175 | + gravityview()->log->notice( '\GravityView_Plugin is deprecated. Use \GV\Plugin instead.' ); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public static function include_extension_framework() |
187 | 187 | { |
188 | - gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
188 | + gravityview()->log->notice( '\GravityView_Plugin is deprecated. Use \GV\Plugin instead.' ); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | */ |
197 | 197 | public static function include_widget_class() |
198 | 198 | { |
199 | - gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
199 | + gravityview()->log->notice( '\GravityView_Plugin is deprecated. Use \GV\Plugin instead.' ); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | */ |
209 | 209 | public function load_plugin_textdomain() |
210 | 210 | { |
211 | - gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
211 | + gravityview()->log->notice( '\GravityView_Plugin is deprecated. Use \GV\Plugin instead.' ); |
|
212 | 212 | gravityview()->plugin->load_textdomain(); |
213 | 213 | } |
214 | 214 | |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public static function is_admin() |
225 | 225 | { |
226 | - gravityview()->log->notice('\GravityView_Plugin::is_admin() is deprecated. Use \GV\Request::is_admin() instead.'); |
|
226 | + gravityview()->log->notice( '\GravityView_Plugin::is_admin() is deprecated. Use \GV\Request::is_admin() instead.' ); |
|
227 | 227 | |
228 | 228 | return gravityview()->request->is_admin(); |
229 | 229 | } |
@@ -237,10 +237,10 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return void |
239 | 239 | */ |
240 | - public function frontend_actions($force = false) |
|
240 | + public function frontend_actions( $force = false ) |
|
241 | 241 | { |
242 | - gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
243 | - gravityview()->plugin->include_legacy_frontend($force); |
|
242 | + gravityview()->log->notice( '\GravityView_Plugin is deprecated. Use \GV\Plugin instead.' ); |
|
243 | + gravityview()->plugin->include_legacy_frontend( $force ); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -267,10 +267,10 @@ discard block |
||
267 | 267 | * |
268 | 268 | * @return void |
269 | 269 | */ |
270 | - public static function log_debug($message, $data = null) |
|
270 | + public static function log_debug( $message, $data = null ) |
|
271 | 271 | { |
272 | - gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
273 | - gravityview()->log->debug($message, $data); |
|
272 | + gravityview()->log->notice( '\GravityView_Plugin is deprecated. Use \GV\Plugin instead.' ); |
|
273 | + gravityview()->log->debug( $message, $data ); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | /** |
@@ -282,9 +282,9 @@ discard block |
||
282 | 282 | * |
283 | 283 | * @return void |
284 | 284 | */ |
285 | - public static function log_error($message, $data = null) |
|
285 | + public static function log_error( $message, $data = null ) |
|
286 | 286 | { |
287 | - gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
|
288 | - gravityview()->log->error($message, $data); |
|
287 | + gravityview()->log->notice( '\GravityView_Plugin is deprecated. Use \GV\Plugin instead.' ); |
|
288 | + gravityview()->log->error( $message, $data ); |
|
289 | 289 | } |
290 | 290 | } // end class GravityView_Plugin |
@@ -91,8 +91,7 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @deprecated see `gravityview()->plugin` and `\GV\Plugin` |
93 | 93 | */ |
94 | -final class GravityView_Plugin |
|
95 | -{ |
|
94 | +final class GravityView_Plugin { |
|
96 | 95 | /** |
97 | 96 | * @deprecated Use \GV\Plugin::$version |
98 | 97 | */ |
@@ -107,8 +106,7 @@ discard block |
||
107 | 106 | * |
108 | 107 | * @return GravityView_Plugin GravityView_Plugin object |
109 | 108 | */ |
110 | - public static function getInstance() |
|
111 | - { |
|
109 | + public static function getInstance() { |
|
112 | 110 | if (empty(self::$instance)) { |
113 | 111 | self::$instance = new self(); |
114 | 112 | } |
@@ -119,8 +117,7 @@ discard block |
||
119 | 117 | /** |
120 | 118 | * @deprecated See \GV\Plugin |
121 | 119 | */ |
122 | - private function __construct() |
|
123 | - { |
|
120 | + private function __construct() { |
|
124 | 121 | gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
125 | 122 | } |
126 | 123 | |
@@ -130,8 +127,7 @@ discard block |
||
130 | 127 | * @deprecated Use gravityview()->plugin->include_legacy_core |
131 | 128 | * @since 1.12 |
132 | 129 | */ |
133 | - public function include_files() |
|
134 | - { |
|
130 | + public function include_files() { |
|
135 | 131 | gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
136 | 132 | gravityview()->plugin->include_legacy_core(); |
137 | 133 | } |
@@ -144,8 +140,7 @@ discard block |
||
144 | 140 | * |
145 | 141 | * @return bool |
146 | 142 | */ |
147 | - public static function is_network_activated() |
|
148 | - { |
|
143 | + public static function is_network_activated() { |
|
149 | 144 | gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
150 | 145 | |
151 | 146 | return gravityview()->plugin->is_network_activated(); |
@@ -158,8 +153,7 @@ discard block |
||
158 | 153 | * |
159 | 154 | * @return void |
160 | 155 | */ |
161 | - public static function activate() |
|
162 | - { |
|
156 | + public static function activate() { |
|
163 | 157 | gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
164 | 158 | } |
165 | 159 | |
@@ -170,8 +164,7 @@ discard block |
||
170 | 164 | * |
171 | 165 | * @return void |
172 | 166 | */ |
173 | - public static function deactivate() |
|
174 | - { |
|
167 | + public static function deactivate() { |
|
175 | 168 | gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
176 | 169 | } |
177 | 170 | |
@@ -183,8 +176,7 @@ discard block |
||
183 | 176 | * |
184 | 177 | * @return void |
185 | 178 | */ |
186 | - public static function include_extension_framework() |
|
187 | - { |
|
179 | + public static function include_extension_framework() { |
|
188 | 180 | gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
189 | 181 | } |
190 | 182 | |
@@ -194,8 +186,7 @@ discard block |
||
194 | 186 | * @deprecated The widget class is loaded elsewhere in legacy core. |
195 | 187 | * @since 1.7.5.1 |
196 | 188 | */ |
197 | - public static function include_widget_class() |
|
198 | - { |
|
189 | + public static function include_widget_class() { |
|
199 | 190 | gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
200 | 191 | } |
201 | 192 | |
@@ -206,8 +197,7 @@ discard block |
||
206 | 197 | * |
207 | 198 | * @return void |
208 | 199 | */ |
209 | - public function load_plugin_textdomain() |
|
210 | - { |
|
200 | + public function load_plugin_textdomain() { |
|
211 | 201 | gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
212 | 202 | gravityview()->plugin->load_textdomain(); |
213 | 203 | } |
@@ -221,8 +211,7 @@ discard block |
||
221 | 211 | * |
222 | 212 | * @return bool |
223 | 213 | */ |
224 | - public static function is_admin() |
|
225 | - { |
|
214 | + public static function is_admin() { |
|
226 | 215 | gravityview()->log->notice('\GravityView_Plugin::is_admin() is deprecated. Use \GV\Request::is_admin() instead.'); |
227 | 216 | |
228 | 217 | return gravityview()->request->is_admin(); |
@@ -237,8 +226,7 @@ discard block |
||
237 | 226 | * |
238 | 227 | * @return void |
239 | 228 | */ |
240 | - public function frontend_actions($force = false) |
|
241 | - { |
|
229 | + public function frontend_actions($force = false) { |
|
242 | 230 | gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
243 | 231 | gravityview()->plugin->include_legacy_frontend($force); |
244 | 232 | } |
@@ -250,8 +238,7 @@ discard block |
||
250 | 238 | * |
251 | 239 | * @return array definition for default widget areas |
252 | 240 | */ |
253 | - public static function get_default_widget_areas() |
|
254 | - { |
|
241 | + public static function get_default_widget_areas() { |
|
255 | 242 | return GravityView_Widget::get_default_widget_areas(); |
256 | 243 | } |
257 | 244 | |
@@ -267,8 +254,7 @@ discard block |
||
267 | 254 | * |
268 | 255 | * @return void |
269 | 256 | */ |
270 | - public static function log_debug($message, $data = null) |
|
271 | - { |
|
257 | + public static function log_debug($message, $data = null) { |
|
272 | 258 | gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
273 | 259 | gravityview()->log->debug($message, $data); |
274 | 260 | } |
@@ -282,8 +268,7 @@ discard block |
||
282 | 268 | * |
283 | 269 | * @return void |
284 | 270 | */ |
285 | - public static function log_error($message, $data = null) |
|
286 | - { |
|
271 | + public static function log_error($message, $data = null) { |
|
287 | 272 | gravityview()->log->notice('\GravityView_Plugin is deprecated. Use \GV\Plugin instead.'); |
288 | 273 | gravityview()->log->error($message, $data); |
289 | 274 | } |
@@ -5,30 +5,30 @@ |
||
5 | 5 | */ |
6 | 6 | class GV_Stub_Call |
7 | 7 | { |
8 | - public function __get($_) |
|
9 | - { |
|
10 | - return new GV_Stub_Call(); |
|
11 | - } |
|
8 | + public function __get($_) |
|
9 | + { |
|
10 | + return new GV_Stub_Call(); |
|
11 | + } |
|
12 | 12 | |
13 | - public function __call($_, $__) |
|
14 | - { |
|
15 | - } |
|
13 | + public function __call($_, $__) |
|
14 | + { |
|
15 | + } |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | class GravityView_Extension |
19 | 19 | { |
20 | - public static $is_compatible = false; |
|
20 | + public static $is_compatible = false; |
|
21 | 21 | |
22 | - public function __construct() |
|
23 | - { |
|
24 | - } |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | + } |
|
25 | 25 | |
26 | - public function add_notice() |
|
27 | - { |
|
28 | - } |
|
26 | + public function add_notice() |
|
27 | + { |
|
28 | + } |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | function gravityview() |
32 | 32 | { |
33 | - return new GV_Stub_Call(); |
|
33 | + return new GV_Stub_Call(); |
|
34 | 34 | } |
@@ -5,12 +5,12 @@ |
||
5 | 5 | */ |
6 | 6 | class GV_Stub_Call |
7 | 7 | { |
8 | - public function __get($_) |
|
8 | + public function __get( $_ ) |
|
9 | 9 | { |
10 | 10 | return new GV_Stub_Call(); |
11 | 11 | } |
12 | 12 | |
13 | - public function __call($_, $__) |
|
13 | + public function __call( $_, $__ ) |
|
14 | 14 | { |
15 | 15 | } |
16 | 16 | } |
@@ -3,32 +3,25 @@ |
||
3 | 3 | * PHP 5.2 class stubs. The core is not loaded but we need to |
4 | 4 | * provide some classes that gracefully fail. |
5 | 5 | */ |
6 | -class GV_Stub_Call |
|
7 | -{ |
|
8 | - public function __get($_) |
|
9 | - { |
|
6 | +class GV_Stub_Call { |
|
7 | + public function __get($_) { |
|
10 | 8 | return new GV_Stub_Call(); |
11 | 9 | } |
12 | 10 | |
13 | - public function __call($_, $__) |
|
14 | - { |
|
11 | + public function __call($_, $__) { |
|
15 | 12 | } |
16 | 13 | } |
17 | 14 | |
18 | -class GravityView_Extension |
|
19 | -{ |
|
15 | +class GravityView_Extension { |
|
20 | 16 | public static $is_compatible = false; |
21 | 17 | |
22 | - public function __construct() |
|
23 | - { |
|
18 | + public function __construct() { |
|
24 | 19 | } |
25 | 20 | |
26 | - public function add_notice() |
|
27 | - { |
|
21 | + public function add_notice() { |
|
28 | 22 | } |
29 | 23 | } |
30 | 24 | |
31 | -function gravityview() |
|
32 | -{ |
|
25 | +function gravityview() { |
|
33 | 26 | return new GV_Stub_Call(); |
34 | 27 | } |