@@ -13,20 +13,20 @@ |
||
13 | 13 | */ |
14 | 14 | trait LoggerAwareTrait |
15 | 15 | { |
16 | - /** |
|
17 | - * The logger instance. |
|
18 | - * |
|
19 | - * @var LoggerInterface|null |
|
20 | - */ |
|
21 | - protected $logger; |
|
16 | + /** |
|
17 | + * The logger instance. |
|
18 | + * |
|
19 | + * @var LoggerInterface|null |
|
20 | + */ |
|
21 | + protected $logger; |
|
22 | 22 | |
23 | - /** |
|
24 | - * Sets a logger. |
|
25 | - * |
|
26 | - * @param LoggerInterface $logger |
|
27 | - */ |
|
28 | - public function setLogger(LoggerInterface $logger) |
|
29 | - { |
|
30 | - $this->logger = $logger; |
|
31 | - } |
|
23 | + /** |
|
24 | + * Sets a logger. |
|
25 | + * |
|
26 | + * @param LoggerInterface $logger |
|
27 | + */ |
|
28 | + public function setLogger(LoggerInterface $logger) |
|
29 | + { |
|
30 | + $this->logger = $logger; |
|
31 | + } |
|
32 | 32 | } |
@@ -25,7 +25,7 @@ |
||
25 | 25 | * |
26 | 26 | * @param LoggerInterface $logger |
27 | 27 | */ |
28 | - public function setLogger(LoggerInterface $logger) |
|
28 | + public function setLogger( LoggerInterface $logger ) |
|
29 | 29 | { |
30 | 30 | $this->logger = $logger; |
31 | 31 | } |
@@ -11,8 +11,7 @@ discard block |
||
11 | 11 | /** |
12 | 12 | * Basic Implementation of LoggerAwareInterface. |
13 | 13 | */ |
14 | -trait LoggerAwareTrait |
|
15 | -{ |
|
14 | +trait LoggerAwareTrait { |
|
16 | 15 | /** |
17 | 16 | * The logger instance. |
18 | 17 | * |
@@ -25,8 +24,7 @@ discard block |
||
25 | 24 | * |
26 | 25 | * @param LoggerInterface $logger |
27 | 26 | */ |
28 | - public function setLogger(LoggerInterface $logger) |
|
29 | - { |
|
27 | + public function setLogger(LoggerInterface $logger) { |
|
30 | 28 | $this->logger = $logger; |
31 | 29 | } |
32 | 30 | } |
@@ -17,118 +17,118 @@ |
||
17 | 17 | */ |
18 | 18 | abstract class AbstractLogger implements LoggerInterface |
19 | 19 | { |
20 | - /** |
|
21 | - * System is unusable. |
|
22 | - * |
|
23 | - * @param string $message |
|
24 | - * @param mixed[] $context |
|
25 | - * |
|
26 | - * @return void |
|
27 | - */ |
|
28 | - public function emergency($message, array $context = array()) |
|
29 | - { |
|
30 | - $this->log(LogLevel::EMERGENCY, $message, $context); |
|
31 | - } |
|
20 | + /** |
|
21 | + * System is unusable. |
|
22 | + * |
|
23 | + * @param string $message |
|
24 | + * @param mixed[] $context |
|
25 | + * |
|
26 | + * @return void |
|
27 | + */ |
|
28 | + public function emergency($message, array $context = array()) |
|
29 | + { |
|
30 | + $this->log(LogLevel::EMERGENCY, $message, $context); |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * Action must be taken immediately. |
|
35 | - * |
|
36 | - * Example: Entire website down, database unavailable, etc. This should |
|
37 | - * trigger the SMS alerts and wake you up. |
|
38 | - * |
|
39 | - * @param string $message |
|
40 | - * @param mixed[] $context |
|
41 | - * |
|
42 | - * @return void |
|
43 | - */ |
|
44 | - public function alert($message, array $context = array()) |
|
45 | - { |
|
46 | - $this->log(LogLevel::ALERT, $message, $context); |
|
47 | - } |
|
33 | + /** |
|
34 | + * Action must be taken immediately. |
|
35 | + * |
|
36 | + * Example: Entire website down, database unavailable, etc. This should |
|
37 | + * trigger the SMS alerts and wake you up. |
|
38 | + * |
|
39 | + * @param string $message |
|
40 | + * @param mixed[] $context |
|
41 | + * |
|
42 | + * @return void |
|
43 | + */ |
|
44 | + public function alert($message, array $context = array()) |
|
45 | + { |
|
46 | + $this->log(LogLevel::ALERT, $message, $context); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Critical conditions. |
|
51 | - * |
|
52 | - * Example: Application component unavailable, unexpected exception. |
|
53 | - * |
|
54 | - * @param string $message |
|
55 | - * @param mixed[] $context |
|
56 | - * |
|
57 | - * @return void |
|
58 | - */ |
|
59 | - public function critical($message, array $context = array()) |
|
60 | - { |
|
61 | - $this->log(LogLevel::CRITICAL, $message, $context); |
|
62 | - } |
|
49 | + /** |
|
50 | + * Critical conditions. |
|
51 | + * |
|
52 | + * Example: Application component unavailable, unexpected exception. |
|
53 | + * |
|
54 | + * @param string $message |
|
55 | + * @param mixed[] $context |
|
56 | + * |
|
57 | + * @return void |
|
58 | + */ |
|
59 | + public function critical($message, array $context = array()) |
|
60 | + { |
|
61 | + $this->log(LogLevel::CRITICAL, $message, $context); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Runtime errors that do not require immediate action but should typically |
|
66 | - * be logged and monitored. |
|
67 | - * |
|
68 | - * @param string $message |
|
69 | - * @param mixed[] $context |
|
70 | - * |
|
71 | - * @return void |
|
72 | - */ |
|
73 | - public function error($message, array $context = array()) |
|
74 | - { |
|
75 | - $this->log(LogLevel::ERROR, $message, $context); |
|
76 | - } |
|
64 | + /** |
|
65 | + * Runtime errors that do not require immediate action but should typically |
|
66 | + * be logged and monitored. |
|
67 | + * |
|
68 | + * @param string $message |
|
69 | + * @param mixed[] $context |
|
70 | + * |
|
71 | + * @return void |
|
72 | + */ |
|
73 | + public function error($message, array $context = array()) |
|
74 | + { |
|
75 | + $this->log(LogLevel::ERROR, $message, $context); |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * Exceptional occurrences that are not errors. |
|
80 | - * |
|
81 | - * Example: Use of deprecated APIs, poor use of an API, undesirable things |
|
82 | - * that are not necessarily wrong. |
|
83 | - * |
|
84 | - * @param string $message |
|
85 | - * @param mixed[] $context |
|
86 | - * |
|
87 | - * @return void |
|
88 | - */ |
|
89 | - public function warning($message, array $context = array()) |
|
90 | - { |
|
91 | - $this->log(LogLevel::WARNING, $message, $context); |
|
92 | - } |
|
78 | + /** |
|
79 | + * Exceptional occurrences that are not errors. |
|
80 | + * |
|
81 | + * Example: Use of deprecated APIs, poor use of an API, undesirable things |
|
82 | + * that are not necessarily wrong. |
|
83 | + * |
|
84 | + * @param string $message |
|
85 | + * @param mixed[] $context |
|
86 | + * |
|
87 | + * @return void |
|
88 | + */ |
|
89 | + public function warning($message, array $context = array()) |
|
90 | + { |
|
91 | + $this->log(LogLevel::WARNING, $message, $context); |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * Normal but significant events. |
|
96 | - * |
|
97 | - * @param string $message |
|
98 | - * @param mixed[] $context |
|
99 | - * |
|
100 | - * @return void |
|
101 | - */ |
|
102 | - public function notice($message, array $context = array()) |
|
103 | - { |
|
104 | - $this->log(LogLevel::NOTICE, $message, $context); |
|
105 | - } |
|
94 | + /** |
|
95 | + * Normal but significant events. |
|
96 | + * |
|
97 | + * @param string $message |
|
98 | + * @param mixed[] $context |
|
99 | + * |
|
100 | + * @return void |
|
101 | + */ |
|
102 | + public function notice($message, array $context = array()) |
|
103 | + { |
|
104 | + $this->log(LogLevel::NOTICE, $message, $context); |
|
105 | + } |
|
106 | 106 | |
107 | - /** |
|
108 | - * Interesting events. |
|
109 | - * |
|
110 | - * Example: User logs in, SQL logs. |
|
111 | - * |
|
112 | - * @param string $message |
|
113 | - * @param mixed[] $context |
|
114 | - * |
|
115 | - * @return void |
|
116 | - */ |
|
117 | - public function info($message, array $context = array()) |
|
118 | - { |
|
119 | - $this->log(LogLevel::INFO, $message, $context); |
|
120 | - } |
|
107 | + /** |
|
108 | + * Interesting events. |
|
109 | + * |
|
110 | + * Example: User logs in, SQL logs. |
|
111 | + * |
|
112 | + * @param string $message |
|
113 | + * @param mixed[] $context |
|
114 | + * |
|
115 | + * @return void |
|
116 | + */ |
|
117 | + public function info($message, array $context = array()) |
|
118 | + { |
|
119 | + $this->log(LogLevel::INFO, $message, $context); |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * Detailed debug information. |
|
124 | - * |
|
125 | - * @param string $message |
|
126 | - * @param mixed[] $context |
|
127 | - * |
|
128 | - * @return void |
|
129 | - */ |
|
130 | - public function debug($message, array $context = array()) |
|
131 | - { |
|
132 | - $this->log(LogLevel::DEBUG, $message, $context); |
|
133 | - } |
|
122 | + /** |
|
123 | + * Detailed debug information. |
|
124 | + * |
|
125 | + * @param string $message |
|
126 | + * @param mixed[] $context |
|
127 | + * |
|
128 | + * @return void |
|
129 | + */ |
|
130 | + public function debug($message, array $context = array()) |
|
131 | + { |
|
132 | + $this->log(LogLevel::DEBUG, $message, $context); |
|
133 | + } |
|
134 | 134 | } |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @return void |
27 | 27 | */ |
28 | - public function emergency($message, array $context = array()) |
|
28 | + public function emergency( $message, array $context = array() ) |
|
29 | 29 | { |
30 | - $this->log(LogLevel::EMERGENCY, $message, $context); |
|
30 | + $this->log( LogLevel::EMERGENCY, $message, $context ); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return void |
43 | 43 | */ |
44 | - public function alert($message, array $context = array()) |
|
44 | + public function alert( $message, array $context = array() ) |
|
45 | 45 | { |
46 | - $this->log(LogLevel::ALERT, $message, $context); |
|
46 | + $this->log( LogLevel::ALERT, $message, $context ); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @return void |
58 | 58 | */ |
59 | - public function critical($message, array $context = array()) |
|
59 | + public function critical( $message, array $context = array() ) |
|
60 | 60 | { |
61 | - $this->log(LogLevel::CRITICAL, $message, $context); |
|
61 | + $this->log( LogLevel::CRITICAL, $message, $context ); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @return void |
72 | 72 | */ |
73 | - public function error($message, array $context = array()) |
|
73 | + public function error( $message, array $context = array() ) |
|
74 | 74 | { |
75 | - $this->log(LogLevel::ERROR, $message, $context); |
|
75 | + $this->log( LogLevel::ERROR, $message, $context ); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -86,9 +86,9 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @return void |
88 | 88 | */ |
89 | - public function warning($message, array $context = array()) |
|
89 | + public function warning( $message, array $context = array() ) |
|
90 | 90 | { |
91 | - $this->log(LogLevel::WARNING, $message, $context); |
|
91 | + $this->log( LogLevel::WARNING, $message, $context ); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @return void |
101 | 101 | */ |
102 | - public function notice($message, array $context = array()) |
|
102 | + public function notice( $message, array $context = array() ) |
|
103 | 103 | { |
104 | - $this->log(LogLevel::NOTICE, $message, $context); |
|
104 | + $this->log( LogLevel::NOTICE, $message, $context ); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @return void |
116 | 116 | */ |
117 | - public function info($message, array $context = array()) |
|
117 | + public function info( $message, array $context = array() ) |
|
118 | 118 | { |
119 | - $this->log(LogLevel::INFO, $message, $context); |
|
119 | + $this->log( LogLevel::INFO, $message, $context ); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | * |
128 | 128 | * @return void |
129 | 129 | */ |
130 | - public function debug($message, array $context = array()) |
|
130 | + public function debug( $message, array $context = array() ) |
|
131 | 131 | { |
132 | - $this->log(LogLevel::DEBUG, $message, $context); |
|
132 | + $this->log( LogLevel::DEBUG, $message, $context ); |
|
133 | 133 | } |
134 | 134 | } |
@@ -15,8 +15,7 @@ discard block |
||
15 | 15 | * reduce boilerplate code that a simple Logger that does the same thing with |
16 | 16 | * messages regardless of the error level has to implement. |
17 | 17 | */ |
18 | -abstract class AbstractLogger implements LoggerInterface |
|
19 | -{ |
|
18 | +abstract class AbstractLogger implements LoggerInterface { |
|
20 | 19 | /** |
21 | 20 | * System is unusable. |
22 | 21 | * |
@@ -25,8 +24,7 @@ discard block |
||
25 | 24 | * |
26 | 25 | * @return void |
27 | 26 | */ |
28 | - public function emergency($message, array $context = array()) |
|
29 | - { |
|
27 | + public function emergency($message, array $context = array()) { |
|
30 | 28 | $this->log(LogLevel::EMERGENCY, $message, $context); |
31 | 29 | } |
32 | 30 | |
@@ -41,8 +39,7 @@ discard block |
||
41 | 39 | * |
42 | 40 | * @return void |
43 | 41 | */ |
44 | - public function alert($message, array $context = array()) |
|
45 | - { |
|
42 | + public function alert($message, array $context = array()) { |
|
46 | 43 | $this->log(LogLevel::ALERT, $message, $context); |
47 | 44 | } |
48 | 45 | |
@@ -56,8 +53,7 @@ discard block |
||
56 | 53 | * |
57 | 54 | * @return void |
58 | 55 | */ |
59 | - public function critical($message, array $context = array()) |
|
60 | - { |
|
56 | + public function critical($message, array $context = array()) { |
|
61 | 57 | $this->log(LogLevel::CRITICAL, $message, $context); |
62 | 58 | } |
63 | 59 | |
@@ -70,8 +66,7 @@ discard block |
||
70 | 66 | * |
71 | 67 | * @return void |
72 | 68 | */ |
73 | - public function error($message, array $context = array()) |
|
74 | - { |
|
69 | + public function error($message, array $context = array()) { |
|
75 | 70 | $this->log(LogLevel::ERROR, $message, $context); |
76 | 71 | } |
77 | 72 | |
@@ -86,8 +81,7 @@ discard block |
||
86 | 81 | * |
87 | 82 | * @return void |
88 | 83 | */ |
89 | - public function warning($message, array $context = array()) |
|
90 | - { |
|
84 | + public function warning($message, array $context = array()) { |
|
91 | 85 | $this->log(LogLevel::WARNING, $message, $context); |
92 | 86 | } |
93 | 87 | |
@@ -99,8 +93,7 @@ discard block |
||
99 | 93 | * |
100 | 94 | * @return void |
101 | 95 | */ |
102 | - public function notice($message, array $context = array()) |
|
103 | - { |
|
96 | + public function notice($message, array $context = array()) { |
|
104 | 97 | $this->log(LogLevel::NOTICE, $message, $context); |
105 | 98 | } |
106 | 99 | |
@@ -114,8 +107,7 @@ discard block |
||
114 | 107 | * |
115 | 108 | * @return void |
116 | 109 | */ |
117 | - public function info($message, array $context = array()) |
|
118 | - { |
|
110 | + public function info($message, array $context = array()) { |
|
119 | 111 | $this->log(LogLevel::INFO, $message, $context); |
120 | 112 | } |
121 | 113 | |
@@ -127,8 +119,7 @@ discard block |
||
127 | 119 | * |
128 | 120 | * @return void |
129 | 121 | */ |
130 | - public function debug($message, array $context = array()) |
|
131 | - { |
|
122 | + public function debug($message, array $context = array()) { |
|
132 | 123 | $this->log(LogLevel::DEBUG, $message, $context); |
133 | 124 | } |
134 | 125 | } |
@@ -13,12 +13,12 @@ |
||
13 | 13 | */ |
14 | 14 | interface LoggerAwareInterface |
15 | 15 | { |
16 | - /** |
|
17 | - * Sets a logger instance on the object. |
|
18 | - * |
|
19 | - * @param LoggerInterface $logger |
|
20 | - * |
|
21 | - * @return void |
|
22 | - */ |
|
23 | - public function setLogger(LoggerInterface $logger); |
|
16 | + /** |
|
17 | + * Sets a logger instance on the object. |
|
18 | + * |
|
19 | + * @param LoggerInterface $logger |
|
20 | + * |
|
21 | + * @return void |
|
22 | + */ |
|
23 | + public function setLogger(LoggerInterface $logger); |
|
24 | 24 | } |
@@ -20,5 +20,5 @@ |
||
20 | 20 | * |
21 | 21 | * @return void |
22 | 22 | */ |
23 | - public function setLogger(LoggerInterface $logger); |
|
23 | + public function setLogger( LoggerInterface $logger ); |
|
24 | 24 | } |
@@ -11,8 +11,7 @@ |
||
11 | 11 | /** |
12 | 12 | * Describes a logger-aware instance. |
13 | 13 | */ |
14 | -interface LoggerAwareInterface |
|
15 | -{ |
|
14 | +interface LoggerAwareInterface { |
|
16 | 15 | /** |
17 | 16 | * Sets a logger instance on the object. |
18 | 17 | * |
@@ -62,92 +62,92 @@ |
||
62 | 62 | */ |
63 | 63 | class TestLogger extends AbstractLogger |
64 | 64 | { |
65 | - /** |
|
66 | - * @var array |
|
67 | - */ |
|
68 | - public $records = []; |
|
65 | + /** |
|
66 | + * @var array |
|
67 | + */ |
|
68 | + public $records = []; |
|
69 | 69 | |
70 | - public $recordsByLevel = []; |
|
70 | + public $recordsByLevel = []; |
|
71 | 71 | |
72 | - /** |
|
73 | - * @inheritdoc |
|
74 | - */ |
|
75 | - public function log($level, $message, array $context = []) |
|
76 | - { |
|
77 | - $record = [ |
|
78 | - 'level' => $level, |
|
79 | - 'message' => $message, |
|
80 | - 'context' => $context, |
|
81 | - ]; |
|
72 | + /** |
|
73 | + * @inheritdoc |
|
74 | + */ |
|
75 | + public function log($level, $message, array $context = []) |
|
76 | + { |
|
77 | + $record = [ |
|
78 | + 'level' => $level, |
|
79 | + 'message' => $message, |
|
80 | + 'context' => $context, |
|
81 | + ]; |
|
82 | 82 | |
83 | - $this->recordsByLevel[$record['level']][] = $record; |
|
84 | - $this->records[] = $record; |
|
85 | - } |
|
83 | + $this->recordsByLevel[$record['level']][] = $record; |
|
84 | + $this->records[] = $record; |
|
85 | + } |
|
86 | 86 | |
87 | - public function hasRecords($level) |
|
88 | - { |
|
89 | - return isset($this->recordsByLevel[$level]); |
|
90 | - } |
|
87 | + public function hasRecords($level) |
|
88 | + { |
|
89 | + return isset($this->recordsByLevel[$level]); |
|
90 | + } |
|
91 | 91 | |
92 | - public function hasRecord($record, $level) |
|
93 | - { |
|
94 | - if (is_string($record)) { |
|
95 | - $record = ['message' => $record]; |
|
96 | - } |
|
97 | - return $this->hasRecordThatPasses(function ($rec) use ($record) { |
|
98 | - if ($rec['message'] !== $record['message']) { |
|
99 | - return false; |
|
100 | - } |
|
101 | - if (isset($record['context']) && $rec['context'] !== $record['context']) { |
|
102 | - return false; |
|
103 | - } |
|
104 | - return true; |
|
105 | - }, $level); |
|
106 | - } |
|
92 | + public function hasRecord($record, $level) |
|
93 | + { |
|
94 | + if (is_string($record)) { |
|
95 | + $record = ['message' => $record]; |
|
96 | + } |
|
97 | + return $this->hasRecordThatPasses(function ($rec) use ($record) { |
|
98 | + if ($rec['message'] !== $record['message']) { |
|
99 | + return false; |
|
100 | + } |
|
101 | + if (isset($record['context']) && $rec['context'] !== $record['context']) { |
|
102 | + return false; |
|
103 | + } |
|
104 | + return true; |
|
105 | + }, $level); |
|
106 | + } |
|
107 | 107 | |
108 | - public function hasRecordThatContains($message, $level) |
|
109 | - { |
|
110 | - return $this->hasRecordThatPasses(function ($rec) use ($message) { |
|
111 | - return strpos($rec['message'], $message) !== false; |
|
112 | - }, $level); |
|
113 | - } |
|
108 | + public function hasRecordThatContains($message, $level) |
|
109 | + { |
|
110 | + return $this->hasRecordThatPasses(function ($rec) use ($message) { |
|
111 | + return strpos($rec['message'], $message) !== false; |
|
112 | + }, $level); |
|
113 | + } |
|
114 | 114 | |
115 | - public function hasRecordThatMatches($regex, $level) |
|
116 | - { |
|
117 | - return $this->hasRecordThatPasses(function ($rec) use ($regex) { |
|
118 | - return preg_match($regex, $rec['message']) > 0; |
|
119 | - }, $level); |
|
120 | - } |
|
115 | + public function hasRecordThatMatches($regex, $level) |
|
116 | + { |
|
117 | + return $this->hasRecordThatPasses(function ($rec) use ($regex) { |
|
118 | + return preg_match($regex, $rec['message']) > 0; |
|
119 | + }, $level); |
|
120 | + } |
|
121 | 121 | |
122 | - public function hasRecordThatPasses(callable $predicate, $level) |
|
123 | - { |
|
124 | - if (!isset($this->recordsByLevel[$level])) { |
|
125 | - return false; |
|
126 | - } |
|
127 | - foreach ($this->recordsByLevel[$level] as $i => $rec) { |
|
128 | - if (call_user_func($predicate, $rec, $i)) { |
|
129 | - return true; |
|
130 | - } |
|
131 | - } |
|
132 | - return false; |
|
133 | - } |
|
122 | + public function hasRecordThatPasses(callable $predicate, $level) |
|
123 | + { |
|
124 | + if (!isset($this->recordsByLevel[$level])) { |
|
125 | + return false; |
|
126 | + } |
|
127 | + foreach ($this->recordsByLevel[$level] as $i => $rec) { |
|
128 | + if (call_user_func($predicate, $rec, $i)) { |
|
129 | + return true; |
|
130 | + } |
|
131 | + } |
|
132 | + return false; |
|
133 | + } |
|
134 | 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 | - return call_user_func_array([$this, $genericMethod], $args); |
|
143 | - } |
|
144 | - } |
|
145 | - throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()'); |
|
146 | - } |
|
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 | + return call_user_func_array([$this, $genericMethod], $args); |
|
143 | + } |
|
144 | + } |
|
145 | + throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()'); |
|
146 | + } |
|
147 | 147 | |
148 | - public function reset() |
|
149 | - { |
|
150 | - $this->records = []; |
|
151 | - $this->recordsByLevel = []; |
|
152 | - } |
|
148 | + public function reset() |
|
149 | + { |
|
150 | + $this->records = []; |
|
151 | + $this->recordsByLevel = []; |
|
152 | + } |
|
153 | 153 | } |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | /** |
66 | 66 | * @var array |
67 | 67 | */ |
68 | - public $records = []; |
|
68 | + public $records = [ ]; |
|
69 | 69 | |
70 | - public $recordsByLevel = []; |
|
70 | + public $recordsByLevel = [ ]; |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * @inheritdoc |
74 | 74 | */ |
75 | - public function log($level, $message, array $context = []) |
|
75 | + public function log( $level, $message, array $context = [ ] ) |
|
76 | 76 | { |
77 | 77 | $record = [ |
78 | 78 | 'level' => $level, |
@@ -80,74 +80,74 @@ discard block |
||
80 | 80 | 'context' => $context, |
81 | 81 | ]; |
82 | 82 | |
83 | - $this->recordsByLevel[$record['level']][] = $record; |
|
84 | - $this->records[] = $record; |
|
83 | + $this->recordsByLevel[ $record[ 'level' ] ][ ] = $record; |
|
84 | + $this->records[ ] = $record; |
|
85 | 85 | } |
86 | 86 | |
87 | - public function hasRecords($level) |
|
87 | + public function hasRecords( $level ) |
|
88 | 88 | { |
89 | - return isset($this->recordsByLevel[$level]); |
|
89 | + return isset( $this->recordsByLevel[ $level ] ); |
|
90 | 90 | } |
91 | 91 | |
92 | - public function hasRecord($record, $level) |
|
92 | + public function hasRecord( $record, $level ) |
|
93 | 93 | { |
94 | - if (is_string($record)) { |
|
95 | - $record = ['message' => $record]; |
|
94 | + if ( is_string( $record ) ) { |
|
95 | + $record = [ 'message' => $record ]; |
|
96 | 96 | } |
97 | - return $this->hasRecordThatPasses(function ($rec) use ($record) { |
|
98 | - if ($rec['message'] !== $record['message']) { |
|
97 | + return $this->hasRecordThatPasses( function( $rec ) use ( $record ) { |
|
98 | + if ( $rec[ 'message' ] !== $record[ 'message' ] ) { |
|
99 | 99 | return false; |
100 | 100 | } |
101 | - if (isset($record['context']) && $rec['context'] !== $record['context']) { |
|
101 | + if ( isset( $record[ 'context' ] ) && $rec[ 'context' ] !== $record[ 'context' ] ) { |
|
102 | 102 | return false; |
103 | 103 | } |
104 | 104 | return true; |
105 | - }, $level); |
|
105 | + }, $level ); |
|
106 | 106 | } |
107 | 107 | |
108 | - public function hasRecordThatContains($message, $level) |
|
108 | + public function hasRecordThatContains( $message, $level ) |
|
109 | 109 | { |
110 | - return $this->hasRecordThatPasses(function ($rec) use ($message) { |
|
111 | - return strpos($rec['message'], $message) !== false; |
|
112 | - }, $level); |
|
110 | + return $this->hasRecordThatPasses( function( $rec ) use ( $message ) { |
|
111 | + return strpos( $rec[ 'message' ], $message ) !== false; |
|
112 | + }, $level ); |
|
113 | 113 | } |
114 | 114 | |
115 | - public function hasRecordThatMatches($regex, $level) |
|
115 | + public function hasRecordThatMatches( $regex, $level ) |
|
116 | 116 | { |
117 | - return $this->hasRecordThatPasses(function ($rec) use ($regex) { |
|
118 | - return preg_match($regex, $rec['message']) > 0; |
|
119 | - }, $level); |
|
117 | + return $this->hasRecordThatPasses( function( $rec ) use ( $regex ) { |
|
118 | + return preg_match( $regex, $rec[ 'message' ] ) > 0; |
|
119 | + }, $level ); |
|
120 | 120 | } |
121 | 121 | |
122 | - public function hasRecordThatPasses(callable $predicate, $level) |
|
122 | + public function hasRecordThatPasses( callable $predicate, $level ) |
|
123 | 123 | { |
124 | - if (!isset($this->recordsByLevel[$level])) { |
|
124 | + if ( ! isset( $this->recordsByLevel[ $level ] ) ) { |
|
125 | 125 | return false; |
126 | 126 | } |
127 | - foreach ($this->recordsByLevel[$level] as $i => $rec) { |
|
128 | - if (call_user_func($predicate, $rec, $i)) { |
|
127 | + foreach ( $this->recordsByLevel[ $level ] as $i => $rec ) { |
|
128 | + if ( call_user_func( $predicate, $rec, $i ) ) { |
|
129 | 129 | return true; |
130 | 130 | } |
131 | 131 | } |
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; |
|
142 | - return call_user_func_array([$this, $genericMethod], $args); |
|
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 | + return call_user_func_array( [ $this, $genericMethod ], $args ); |
|
143 | 143 | } |
144 | 144 | } |
145 | - throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()'); |
|
145 | + throw new \BadMethodCallException( 'Call to undefined method ' . get_class( $this ) . '::' . $method . '()' ); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | public function reset() |
149 | 149 | { |
150 | - $this->records = []; |
|
151 | - $this->recordsByLevel = []; |
|
150 | + $this->records = [ ]; |
|
151 | + $this->recordsByLevel = [ ]; |
|
152 | 152 | } |
153 | 153 | } |
@@ -60,8 +60,7 @@ discard block |
||
60 | 60 | * @method bool hasInfoThatPasses($message) |
61 | 61 | * @method bool hasDebugThatPasses($message) |
62 | 62 | */ |
63 | -class TestLogger extends AbstractLogger |
|
64 | -{ |
|
63 | +class TestLogger extends AbstractLogger { |
|
65 | 64 | /** |
66 | 65 | * @var array |
67 | 66 | */ |
@@ -72,8 +71,7 @@ discard block |
||
72 | 71 | /** |
73 | 72 | * @inheritdoc |
74 | 73 | */ |
75 | - public function log($level, $message, array $context = []) |
|
76 | - { |
|
74 | + public function log($level, $message, array $context = []) { |
|
77 | 75 | $record = [ |
78 | 76 | 'level' => $level, |
79 | 77 | 'message' => $message, |
@@ -84,13 +82,11 @@ discard block |
||
84 | 82 | $this->records[] = $record; |
85 | 83 | } |
86 | 84 | |
87 | - public function hasRecords($level) |
|
88 | - { |
|
85 | + public function hasRecords($level) { |
|
89 | 86 | return isset($this->recordsByLevel[$level]); |
90 | 87 | } |
91 | 88 | |
92 | - public function hasRecord($record, $level) |
|
93 | - { |
|
89 | + public function hasRecord($record, $level) { |
|
94 | 90 | if (is_string($record)) { |
95 | 91 | $record = ['message' => $record]; |
96 | 92 | } |
@@ -105,22 +101,19 @@ discard block |
||
105 | 101 | }, $level); |
106 | 102 | } |
107 | 103 | |
108 | - public function hasRecordThatContains($message, $level) |
|
109 | - { |
|
104 | + public function hasRecordThatContains($message, $level) { |
|
110 | 105 | return $this->hasRecordThatPasses(function ($rec) use ($message) { |
111 | 106 | return strpos($rec['message'], $message) !== false; |
112 | 107 | }, $level); |
113 | 108 | } |
114 | 109 | |
115 | - public function hasRecordThatMatches($regex, $level) |
|
116 | - { |
|
110 | + public function hasRecordThatMatches($regex, $level) { |
|
117 | 111 | return $this->hasRecordThatPasses(function ($rec) use ($regex) { |
118 | 112 | return preg_match($regex, $rec['message']) > 0; |
119 | 113 | }, $level); |
120 | 114 | } |
121 | 115 | |
122 | - public function hasRecordThatPasses(callable $predicate, $level) |
|
123 | - { |
|
116 | + public function hasRecordThatPasses(callable $predicate, $level) { |
|
124 | 117 | if (!isset($this->recordsByLevel[$level])) { |
125 | 118 | return false; |
126 | 119 | } |
@@ -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]); |
@@ -145,8 +137,7 @@ discard block |
||
145 | 137 | throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()'); |
146 | 138 | } |
147 | 139 | |
148 | - public function reset() |
|
149 | - { |
|
140 | + public function reset() { |
|
150 | 141 | $this->records = []; |
151 | 142 | $this->recordsByLevel = []; |
152 | 143 | } |
@@ -17,8 +17,8 @@ |
||
17 | 17 | */ |
18 | 18 | class DummyTest |
19 | 19 | { |
20 | - public function __toString() |
|
21 | - { |
|
22 | - return 'DummyTest'; |
|
23 | - } |
|
20 | + public function __toString() |
|
21 | + { |
|
22 | + return 'DummyTest'; |
|
23 | + } |
|
24 | 24 | } |
@@ -15,10 +15,8 @@ |
||
15 | 15 | * |
16 | 16 | * @internal |
17 | 17 | */ |
18 | -class DummyTest |
|
19 | -{ |
|
20 | - public function __toString() |
|
21 | - { |
|
18 | +class DummyTest { |
|
19 | + public function __toString() { |
|
22 | 20 | return 'DummyTest'; |
23 | 21 | } |
24 | 22 | } |
@@ -13,12 +13,12 @@ |
||
13 | 13 | */ |
14 | 14 | class LogLevel |
15 | 15 | { |
16 | - const EMERGENCY = 'emergency'; |
|
17 | - const ALERT = 'alert'; |
|
18 | - const CRITICAL = 'critical'; |
|
19 | - const ERROR = 'error'; |
|
20 | - const WARNING = 'warning'; |
|
21 | - const NOTICE = 'notice'; |
|
22 | - const INFO = 'info'; |
|
23 | - const DEBUG = 'debug'; |
|
16 | + const EMERGENCY = 'emergency'; |
|
17 | + const ALERT = 'alert'; |
|
18 | + const CRITICAL = 'critical'; |
|
19 | + const ERROR = 'error'; |
|
20 | + const WARNING = 'warning'; |
|
21 | + const NOTICE = 'notice'; |
|
22 | + const INFO = 'info'; |
|
23 | + const DEBUG = 'debug'; |
|
24 | 24 | } |
@@ -11,8 +11,7 @@ |
||
11 | 11 | /** |
12 | 12 | * Describes log levels. |
13 | 13 | */ |
14 | -class LogLevel |
|
15 | -{ |
|
14 | +class LogLevel { |
|
16 | 15 | const EMERGENCY = 'emergency'; |
17 | 16 | const ALERT = 'alert'; |
18 | 17 | const CRITICAL = 'critical'; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | namespace GravityView\TrustedLogin; |
25 | 25 | |
26 | 26 | // Exit if accessed directly |
27 | -if ( ! defined('ABSPATH') ) { |
|
27 | +if ( ! defined( 'ABSPATH' ) ) { |
|
28 | 28 | exit; |
29 | 29 | } |
30 | 30 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $ns = $config->ns(); |
160 | 160 | |
161 | 161 | // Namespace isn't set; allow Config |
162 | - if( empty( $ns ) ) { |
|
162 | + if ( empty( $ns ) ) { |
|
163 | 163 | return true; |
164 | 164 | } |
165 | 165 | |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | return $created; |
344 | 344 | } |
345 | 345 | |
346 | - $return_data['timing']['remote'] = timer_stop( 0, 5 ); |
|
346 | + $return_data[ 'timing' ][ 'remote' ] = timer_stop( 0, 5 ); |
|
347 | 347 | |
348 | 348 | do_action( 'trustedlogin/' . $this->config->ns() . '/access/created', array( |
349 | 349 | 'url' => get_site_url(), |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | return $updated; |
448 | 448 | } |
449 | 449 | |
450 | - $return_data['timing']['remote'] = timer_stop( 0, 5 ); |
|
450 | + $return_data[ 'timing' ][ 'remote' ] = timer_stop( 0, 5 ); |
|
451 | 451 | |
452 | 452 | do_action( 'trustedlogin/' . $this->config->ns() . '/access/extended', array( |
453 | 453 | 'url' => get_site_url(), |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | $reference_id = self::get_reference_id(); |
544 | 544 | |
545 | 545 | if ( $reference_id ) { |
546 | - $metadata['reference_id'] = $reference_id; |
|
546 | + $metadata[ 'reference_id' ] = $reference_id; |
|
547 | 547 | } |
548 | 548 | |
549 | 549 | return $metadata; |
@@ -558,12 +558,12 @@ discard block |
||
558 | 558 | */ |
559 | 559 | public static function get_reference_id() { |
560 | 560 | |
561 | - if ( isset( $_REQUEST['reference_id'] ) ) { |
|
562 | - return esc_html( $_REQUEST['reference_id'] ); |
|
561 | + if ( isset( $_REQUEST[ 'reference_id' ] ) ) { |
|
562 | + return esc_html( $_REQUEST[ 'reference_id' ] ); |
|
563 | 563 | } |
564 | 564 | |
565 | - if ( isset( $_REQUEST['ref'] ) ) { |
|
566 | - return esc_html( $_REQUEST['ref'] ); |
|
565 | + if ( isset( $_REQUEST[ 'ref' ] ) ) { |
|
566 | + return esc_html( $_REQUEST[ 'ref' ] ); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | return null; |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | namespace GravityView\TrustedLogin; |
14 | 14 | |
15 | 15 | // Exit if accessed directly |
16 | -if ( ! defined('ABSPATH') ) { |
|
16 | +if ( ! defined( 'ABSPATH' ) ) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -72,14 +72,14 @@ discard block |
||
72 | 72 | // TODO: Support multiple roles |
73 | 73 | $role = is_array( $roles ) ? array_key_first( $roles ) : $roles; |
74 | 74 | |
75 | - return (string) $role; |
|
75 | + return (string)$role; |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | 79 | * @return string |
80 | 80 | */ |
81 | 81 | public function get_name() { |
82 | - return (string) $this->role_name; |
|
82 | + return (string)$this->role_name; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | |
151 | 151 | $add_caps = $this->config->get_setting( 'caps/add' ); |
152 | 152 | |
153 | - foreach ( (array) $add_caps as $add_cap => $reason ) { |
|
153 | + foreach ( (array)$add_caps as $add_cap => $reason ) { |
|
154 | 154 | $capabilities[ $add_cap ] = true; |
155 | 155 | } |
156 | 156 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | |
167 | 167 | $new_role = add_role( $new_role_slug, $role_display_name, $capabilities ); |
168 | 168 | |
169 | - if ( ! $new_role ){ |
|
169 | + if ( ! $new_role ) { |
|
170 | 170 | |
171 | 171 | return new WP_Error( |
172 | 172 | 'add_role_failed', |
@@ -181,11 +181,11 @@ discard block |
||
181 | 181 | |
182 | 182 | $remove_caps = $this->config->get_setting( 'caps/remove' ); |
183 | 183 | |
184 | - if ( ! empty( $remove_caps ) ){ |
|
184 | + if ( ! empty( $remove_caps ) ) { |
|
185 | 185 | |
186 | - foreach ( $remove_caps as $remove_cap => $description ){ |
|
186 | + foreach ( $remove_caps as $remove_cap => $description ) { |
|
187 | 187 | $new_role->remove_cap( $remove_cap ); |
188 | - $this->logging->log( 'Capability '. $remove_cap .' removed from role.', __METHOD__, 'info' ); |
|
188 | + $this->logging->log( 'Capability ' . $remove_cap . ' removed from role.', __METHOD__, 'info' ); |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | // Returns void; no way to tell if successful |
205 | 205 | remove_role( $this->get_name() ); |
206 | 206 | |
207 | - if( get_role( $this->get_name() ) ) { |
|
207 | + if ( get_role( $this->get_name() ) ) { |
|
208 | 208 | |
209 | 209 | $this->logging->log( "Role " . $this->get_name() . " was not removed successfully.", __METHOD__, 'error' ); |
210 | 210 |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | |
167 | 167 | $new_role = add_role( $new_role_slug, $role_display_name, $capabilities ); |
168 | 168 | |
169 | - if ( ! $new_role ){ |
|
169 | + if ( ! $new_role ) { |
|
170 | 170 | |
171 | 171 | return new WP_Error( |
172 | 172 | 'add_role_failed', |
@@ -181,9 +181,9 @@ discard block |
||
181 | 181 | |
182 | 182 | $remove_caps = $this->config->get_setting( 'caps/remove' ); |
183 | 183 | |
184 | - if ( ! empty( $remove_caps ) ){ |
|
184 | + if ( ! empty( $remove_caps ) ) { |
|
185 | 185 | |
186 | - foreach ( $remove_caps as $remove_cap => $description ){ |
|
186 | + foreach ( $remove_caps as $remove_cap => $description ) { |
|
187 | 187 | $new_role->remove_cap( $remove_cap ); |
188 | 188 | $this->logging->log( 'Capability '. $remove_cap .' removed from role.', __METHOD__, 'info' ); |
189 | 189 | } |
@@ -1130,7 +1130,7 @@ |
||
1130 | 1130 | <button id="tl-%1\$s-copy" class="tl-%1\$s-auth__accesskey_copy button" aria-live="off" title="%7\$s"><span class="screen-reader-text">%5\$s</span></button> |
1131 | 1131 | </div> |
1132 | 1132 | </%6\$s> |
1133 | -EOD; |
|
1133 | +eod; |
|
1134 | 1134 | |
1135 | 1135 | |
1136 | 1136 | $access_key_output = sprintf( |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | $registered = array(); |
126 | 126 | |
127 | - $registered['trustedlogin-js'] = wp_register_script( |
|
127 | + $registered[ 'trustedlogin-js' ] = wp_register_script( |
|
128 | 128 | 'trustedlogin-' . $this->config->ns(), |
129 | 129 | $this->config->get_setting( 'paths/js' ), |
130 | 130 | array( 'jquery', 'wp-a11y' ), |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | true |
133 | 133 | ); |
134 | 134 | |
135 | - $registered['trustedlogin-css'] = wp_register_style( |
|
135 | + $registered[ 'trustedlogin-css' ] = wp_register_style( |
|
136 | 136 | 'trustedlogin-' . $this->config->ns(), |
137 | 137 | $this->config->get_setting( 'paths/css' ), |
138 | 138 | array(), |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * @return bool |
226 | 226 | */ |
227 | 227 | private function is_login_screen() { |
228 | - return did_action( 'login_init' ) && isset( $_GET['ns'] ) && $_GET['ns'] === $this->config->ns(); |
|
228 | + return did_action( 'login_init' ) && isset( $_GET[ 'ns' ] ) && $_GET[ 'ns' ] === $this->config->ns(); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | |
242 | 242 | // Once logged-in, take user back to auth request screen. |
243 | 243 | if ( ! is_user_logged_in() ) { |
244 | - $_REQUEST['redirect_to'] = site_url( add_query_arg( array() ) ); |
|
244 | + $_REQUEST[ 'redirect_to' ] = site_url( add_query_arg( array() ) ); |
|
245 | 245 | return; |
246 | 246 | } |
247 | 247 | |
@@ -259,19 +259,19 @@ discard block |
||
259 | 259 | $interim_login = true; |
260 | 260 | |
261 | 261 | // The login_headertitle filter was deprecated in WP 5.2.0 for login_headertext |
262 | - if( version_compare( $wp_version, '5.2.0', '<' ) ) { |
|
262 | + if ( version_compare( $wp_version, '5.2.0', '<' ) ) { |
|
263 | 263 | add_filter( 'login_headertitle', '__return_empty_string' ); |
264 | 264 | } else { |
265 | 265 | add_filter( 'login_headertext', '__return_empty_string' ); |
266 | 266 | } |
267 | 267 | |
268 | - add_filter( 'login_headerurl', function () { |
|
268 | + add_filter( 'login_headerurl', function() { |
|
269 | 269 | return $this->config->get_setting( 'vendor/website' ); |
270 | 270 | }); |
271 | 271 | |
272 | 272 | login_header(); |
273 | 273 | |
274 | - wp_enqueue_style( 'common'); |
|
274 | + wp_enqueue_style( 'common' ); |
|
275 | 275 | |
276 | 276 | wp_add_inline_style( 'common', $this->get_login_inline_css() ); |
277 | 277 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | margin-top: 36px; |
302 | 302 | } |
303 | 303 | .login h1 a { |
304 | - background-image: url("' . $this->config->get_setting( 'vendor/logo_url' ). '")!important; |
|
304 | + background-image: url("' . $this->config->get_setting( 'vendor/logo_url' ) . '")!important; |
|
305 | 305 | background-size: contain!important; |
306 | 306 | } |
307 | 307 | '; |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | return ''; |
326 | 326 | } |
327 | 327 | |
328 | - $support_user = $support_users[0]; |
|
328 | + $support_user = $support_users[ 0 ]; |
|
329 | 329 | |
330 | 330 | $_user_creator_id = get_user_option( $this->support_user->created_by_meta_key, $support_user->ID ); |
331 | 331 | $_user_creator = $_user_creator_id ? get_user_by( 'id', $_user_creator_id ) : false; |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | return ''; |
451 | 451 | } |
452 | 452 | |
453 | - $template = '<div class="tl-{{ns}}-auth__ref"><p><span class="tl-{{ns}}-auth_ref__id">{{reference_text}}</span></p></div>'; |
|
453 | + $template = '<div class="tl-{{ns}}-auth__ref"><p><span class="tl-{{ns}}-auth_ref__id">{{reference_text}}</span></p></div>'; |
|
454 | 454 | |
455 | 455 | $content = array( |
456 | 456 | 'reference_text' => sprintf( esc_html__( 'Reference #%s', 'gravityview' ), $reference_id ), |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | if ( $has_access ) { |
469 | 469 | foreach ( $has_access as $access ) { |
470 | 470 | // translators: %1$s is replaced with the name of the software developer (e.g. "Acme Widgets"). %2$s is the amount of time remaining for access ("1 week") |
471 | - $intro = sprintf( esc_html__( '%1$s has site access that expires in %2$s.', 'gravityview' ), '<a href="' . esc_url( $this->config->get_setting('vendor/website') ) . '" target="_blank" rel="noopener noreferrer">' . $this->config->get_setting( 'vendor/title' ) . '</a>', str_replace( ' ', ' ', $this->support_user->get_expiration( $access, true, false ) ) ); |
|
471 | + $intro = sprintf( esc_html__( '%1$s has site access that expires in %2$s.', 'gravityview' ), '<a href="' . esc_url( $this->config->get_setting( 'vendor/website' ) ) . '" target="_blank" rel="noopener noreferrer">' . $this->config->get_setting( 'vendor/title' ) . '</a>', str_replace( ' ', ' ', $this->support_user->get_expiration( $access, true, false ) ) ); |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | return $intro; |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | |
477 | 477 | if ( $this->is_login_screen() ) { |
478 | 478 | // translators: %1$s is replaced with the name of the software developer (e.g. "Acme Widgets") |
479 | - $intro = sprintf( esc_html__( '%1$s would like support access to this site.', 'gravityview' ), '<a href="'. esc_url( $this->config->get_setting( 'vendor/website' ) ) . '">' . $this->config->get_display_name() . '</a>' ); |
|
479 | + $intro = sprintf( esc_html__( '%1$s would like support access to this site.', 'gravityview' ), '<a href="' . esc_url( $this->config->get_setting( 'vendor/website' ) ) . '">' . $this->config->get_display_name() . '</a>' ); |
|
480 | 480 | } else { |
481 | 481 | // translators: %1$s is replaced with the name of the software developer (e.g. "Acme Widgets") |
482 | 482 | $intro = sprintf( esc_html__( 'Grant %1$s access to this site.', 'gravityview' ), '<a href="' . esc_url( $this->config->get_setting( 'vendor/website' ) ) . '">' . $this->config->get_display_name() . '</a>' ); |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | */ |
570 | 570 | private function get_caps_section( $caps_array, $heading = '', $dashicon = '' ) { |
571 | 571 | |
572 | - $caps_array = array_filter( (array) $caps_array, array( $this->config, 'is_not_null' ) ); |
|
572 | + $caps_array = array_filter( (array)$caps_array, array( $this->config, 'is_not_null' ) ); |
|
573 | 573 | |
574 | 574 | if ( empty( $caps_array ) ) { |
575 | 575 | return ''; |
@@ -580,10 +580,10 @@ discard block |
||
580 | 580 | $output .= '<h3>' . esc_html( $heading ) . '</h3>'; |
581 | 581 | $output .= '<ul>'; |
582 | 582 | |
583 | - foreach ( (array) $caps_array as $cap => $reason ) { |
|
583 | + foreach ( (array)$caps_array as $cap => $reason ) { |
|
584 | 584 | $dashicon = '<span class="dashicons ' . esc_attr( $dashicon ) . ' dashicons--small"></span>'; |
585 | 585 | $reason = empty( $reason ) ? '' : '<small>' . esc_html( $reason ) . '</small>'; |
586 | - $output .= sprintf( '<li>%s<span class="code">%s</span>%s</li>', $dashicon, esc_html( $cap ), $reason ); |
|
586 | + $output .= sprintf( '<li>%s<span class="code">%s</span>%s</li>', $dashicon, esc_html( $cap ), $reason ); |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | $output .= '</ul>'; |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | |
715 | 715 | // Allow SVGs for logos |
716 | 716 | $allowed_protocols = wp_allowed_protocols(); |
717 | - $allowed_protocols[] = 'data'; |
|
717 | + $allowed_protocols[ ] = 'data'; |
|
718 | 718 | |
719 | 719 | $output_html = wp_kses( $output_html, array( |
720 | 720 | 'a' => array( |
@@ -756,10 +756,10 @@ discard block |
||
756 | 756 | 'p' => array( 'class' => array(), 'id' => array() ), |
757 | 757 | 'h1' => array( 'class' => array(), 'id' => array() ), |
758 | 758 | 'h2' => array( 'class' => array(), 'id' => array() ), |
759 | - 'h3' => array( 'class' => array(), 'id' => array(), 'style' => array(), ), |
|
759 | + 'h3' => array( 'class' => array(), 'id' => array(), 'style' => array(),), |
|
760 | 760 | 'h4' => array( 'class' => array(), 'id' => array() ), |
761 | 761 | 'h5' => array( 'class' => array(), 'id' => array() ), |
762 | - 'div' => array( 'class' => array(), 'id' => array(), 'aria-live' => array(), 'style' => array(), ), |
|
762 | + 'div' => array( 'class' => array(), 'id' => array(), 'aria-live' => array(), 'style' => array(),), |
|
763 | 763 | 'small' => array( 'class' => array(), 'id' => array(), 'data-toggle' => array() ), |
764 | 764 | 'header' => array( 'class' => array(), 'id' => array() ), |
765 | 765 | 'footer' => array( 'class' => array(), 'id' => array() ), |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | |
881 | 881 | $atts = wp_parse_args( $atts, $defaults ); |
882 | 882 | |
883 | - switch ( $atts['size'] ) { |
|
883 | + switch ( $atts[ 'size' ] ) { |
|
884 | 884 | case '': |
885 | 885 | $css_class = ''; |
886 | 886 | break; |
@@ -888,17 +888,17 @@ discard block |
||
888 | 888 | $css_class = 'button'; |
889 | 889 | break; |
890 | 890 | default: |
891 | - if ( ! in_array( $atts['size'], $sizes ) ) { |
|
892 | - $atts['size'] = 'hero'; |
|
891 | + if ( ! in_array( $atts[ 'size' ], $sizes ) ) { |
|
892 | + $atts[ 'size' ] = 'hero'; |
|
893 | 893 | } |
894 | 894 | |
895 | - $css_class = 'button button-' . $atts['size']; |
|
895 | + $css_class = 'button button-' . $atts[ 'size' ]; |
|
896 | 896 | } |
897 | 897 | |
898 | 898 | $_valid_tags = array( 'a', 'button', 'span' ); |
899 | 899 | |
900 | - if ( ! empty( $atts['tag'] ) && in_array( strtolower( $atts['tag'] ), $_valid_tags, true ) ) { |
|
901 | - $tag = $atts['tag']; |
|
900 | + if ( ! empty( $atts[ 'tag' ] ) && in_array( strtolower( $atts[ 'tag' ] ), $_valid_tags, true ) ) { |
|
901 | + $tag = $atts[ 'tag' ]; |
|
902 | 902 | } else { |
903 | 903 | $tag = 'a'; |
904 | 904 | } |
@@ -906,16 +906,16 @@ discard block |
||
906 | 906 | $data_atts = array(); |
907 | 907 | |
908 | 908 | if ( $this->support_user->get_all() ) { |
909 | - $text = '<span class="dashicons dashicons-update-alt"></span>' . esc_html( $atts['exists_text'] ); |
|
909 | + $text = '<span class="dashicons dashicons-update-alt"></span>' . esc_html( $atts[ 'exists_text' ] ); |
|
910 | 910 | $href = admin_url( 'users.php?role=' . $this->support_user->role->get_name() ); |
911 | - $data_atts['access'] = 'extend'; |
|
911 | + $data_atts[ 'access' ] = 'extend'; |
|
912 | 912 | } else { |
913 | - $text = esc_html( $atts['text'] ); |
|
914 | - $href = $atts['support_url']; |
|
915 | - $data_atts['access'] = 'grant'; |
|
913 | + $text = esc_html( $atts[ 'text' ] ); |
|
914 | + $href = $atts[ 'support_url' ]; |
|
915 | + $data_atts[ 'access' ] = 'grant'; |
|
916 | 916 | } |
917 | 917 | |
918 | - $css_class = implode( ' ', array( $css_class, $atts['class'] ) ); |
|
918 | + $css_class = implode( ' ', array( $css_class, $atts[ 'class' ] ) ); |
|
919 | 919 | $css_class = trim( $css_class ); |
920 | 920 | |
921 | 921 | $data_string = ''; |
@@ -924,7 +924,7 @@ discard block |
||
924 | 924 | } |
925 | 925 | |
926 | 926 | $powered_by = ''; |
927 | - if ( $atts['powered_by'] ) { |
|
927 | + if ( $atts[ 'powered_by' ] ) { |
|
928 | 928 | $powered_by = sprintf( '<small><span class="trustedlogin-logo"></span>%s</small>', |
929 | 929 | esc_html__( 'Secured by TrustedLogin', 'gravityview' ) |
930 | 930 | ); |