Completed
Push — develop ( e2688f...d26e21 )
by Zack
29:42 queued 09:43
created
vendor_prefixed/katzgrau/klogger/src/Logger.php 3 patches
Indentation   +318 added lines, -318 removed lines patch added patch discarded remove patch
@@ -34,322 +34,322 @@
 block discarded – undo
34 34
  */
35 35
 class Logger extends AbstractLogger
36 36
 {
37
-    /**
38
-     * KLogger options
39
-     *  Anything options not considered 'core' to the logging library should be
40
-     *  settable view the third parameter in the constructor
41
-     *
42
-     *  Core options include the log file path and the log threshold
43
-     *
44
-     * @var array
45
-     */
46
-    protected $options = array (
47
-        'extension'      => 'txt',
48
-        'dateFormat'     => 'Y-m-d G:i:s.u',
49
-        'filename'       => false,
50
-        'flushFrequency' => false,
51
-        'prefix'         => 'log_',
52
-        'logFormat'      => false,
53
-        'appendContext'  => true,
54
-    );
55
-
56
-    /**
57
-     * Path to the log file
58
-     * @var string
59
-     */
60
-    private $logFilePath;
61
-
62
-    /**
63
-     * Current minimum logging threshold
64
-     * @var integer
65
-     */
66
-    protected $logLevelThreshold = LogLevel::DEBUG;
67
-
68
-    /**
69
-     * The number of lines logged in this instance's lifetime
70
-     * @var int
71
-     */
72
-    private $logLineCount = 0;
73
-
74
-    /**
75
-     * Log Levels
76
-     * @var array
77
-     */
78
-    protected $logLevels = array(
79
-        LogLevel::EMERGENCY => 0,
80
-        LogLevel::ALERT     => 1,
81
-        LogLevel::CRITICAL  => 2,
82
-        LogLevel::ERROR     => 3,
83
-        LogLevel::WARNING   => 4,
84
-        LogLevel::NOTICE    => 5,
85
-        LogLevel::INFO      => 6,
86
-        LogLevel::DEBUG     => 7
87
-    );
88
-
89
-    /**
90
-     * This holds the file handle for this instance's log file
91
-     * @var resource
92
-     */
93
-    private $fileHandle;
94
-
95
-    /**
96
-     * This holds the last line logged to the logger
97
-     *  Used for unit tests
98
-     * @var string
99
-     */
100
-    private $lastLine = '';
101
-
102
-    /**
103
-     * Octal notation for default permissions of the log file
104
-     * @var integer
105
-     */
106
-    private $defaultPermissions = 0777;
107
-
108
-    /**
109
-     * Class constructor
110
-     *
111
-     * @param string $logDirectory      File path to the logging directory
112
-     * @param string $logLevelThreshold The LogLevel Threshold
113
-     * @param array  $options
114
-     *
115
-     * @internal param string $logFilePrefix The prefix for the log file name
116
-     * @internal param string $logFileExt The extension for the log file
117
-     */
118
-    public function __construct($logDirectory, $logLevelThreshold = LogLevel::DEBUG, array $options = array())
119
-    {
120
-        $this->logLevelThreshold = $logLevelThreshold;
121
-        $this->options = array_merge($this->options, $options);
122
-
123
-        $logDirectory = rtrim($logDirectory, DIRECTORY_SEPARATOR);
124
-        if ( ! file_exists($logDirectory)) {
125
-            mkdir($logDirectory, $this->defaultPermissions, true);
126
-        }
127
-
128
-        if(strpos($logDirectory, 'php://') === 0) {
129
-            $this->setLogToStdOut($logDirectory);
130
-            $this->setFileHandle('w+');
131
-        } else {
132
-            $this->setLogFilePath($logDirectory);
133
-            if(file_exists($this->logFilePath) && !is_writable($this->logFilePath)) {
134
-                throw new RuntimeException('The file could not be written to. Check that appropriate permissions have been set.');
135
-            }
136
-            $this->setFileHandle('a');
137
-        }
138
-
139
-        if ( ! $this->fileHandle) {
140
-            throw new RuntimeException('The file could not be opened. Check permissions.');
141
-        }
142
-    }
143
-
144
-    /**
145
-     * @param string $stdOutPath
146
-     */
147
-    public function setLogToStdOut($stdOutPath) {
148
-        $this->logFilePath = $stdOutPath;
149
-    }
150
-
151
-    /**
152
-     * @param string $logDirectory
153
-     */
154
-    public function setLogFilePath($logDirectory) {
155
-        if ($this->options['filename']) {
156
-            if (strpos($this->options['filename'], '.log') !== false || strpos($this->options['filename'], '.txt') !== false) {
157
-                $this->logFilePath = $logDirectory.DIRECTORY_SEPARATOR.$this->options['filename'];
158
-            }
159
-            else {
160
-                $this->logFilePath = $logDirectory.DIRECTORY_SEPARATOR.$this->options['filename'].'.'.$this->options['extension'];
161
-            }
162
-        } else {
163
-            $this->logFilePath = $logDirectory.DIRECTORY_SEPARATOR.$this->options['prefix'].date('Y-m-d').'.'.$this->options['extension'];
164
-        }
165
-    }
166
-
167
-    /**
168
-     * @param $writeMode
169
-     *
170
-     * @internal param resource $fileHandle
171
-     */
172
-    public function setFileHandle($writeMode) {
173
-        $this->fileHandle = fopen($this->logFilePath, $writeMode);
174
-    }
175
-
176
-
177
-    /**
178
-     * Class destructor
179
-     */
180
-    public function __destruct()
181
-    {
182
-        if ($this->fileHandle) {
183
-            fclose($this->fileHandle);
184
-        }
185
-    }
186
-
187
-    /**
188
-     * Sets the date format used by all instances of KLogger
189
-     *
190
-     * @param string $dateFormat Valid format string for date()
191
-     */
192
-    public function setDateFormat($dateFormat)
193
-    {
194
-        $this->options['dateFormat'] = $dateFormat;
195
-    }
196
-
197
-    /**
198
-     * Sets the Log Level Threshold
199
-     *
200
-     * @param string $logLevelThreshold The log level threshold
201
-     */
202
-    public function setLogLevelThreshold($logLevelThreshold)
203
-    {
204
-        $this->logLevelThreshold = $logLevelThreshold;
205
-    }
206
-
207
-    /**
208
-     * Logs with an arbitrary level.
209
-     *
210
-     * @param mixed $level
211
-     * @param string $message
212
-     * @param array $context
213
-     * @return null
214
-     */
215
-    public function log($level, $message, array $context = array())
216
-    {
217
-        if ($this->logLevels[$this->logLevelThreshold] < $this->logLevels[$level]) {
218
-            return;
219
-        }
220
-        $message = $this->formatMessage($level, $message, $context);
221
-        $this->write($message);
222
-    }
223
-
224
-    /**
225
-     * Writes a line to the log without prepending a status or timestamp
226
-     *
227
-     * @param string $message Line to write to the log
228
-     * @return void
229
-     */
230
-    public function write($message)
231
-    {
232
-        if (null !== $this->fileHandle) {
233
-            if (fwrite($this->fileHandle, $message) === false) {
234
-                throw new RuntimeException('The file could not be written to. Check that appropriate permissions have been set.');
235
-            } else {
236
-                $this->lastLine = trim($message);
237
-                $this->logLineCount++;
238
-
239
-                if ($this->options['flushFrequency'] && $this->logLineCount % $this->options['flushFrequency'] === 0) {
240
-                    fflush($this->fileHandle);
241
-                }
242
-            }
243
-        }
244
-    }
245
-
246
-    /**
247
-     * Get the file path that the log is currently writing to
248
-     *
249
-     * @return string
250
-     */
251
-    public function getLogFilePath()
252
-    {
253
-        return $this->logFilePath;
254
-    }
255
-
256
-    /**
257
-     * Get the last line logged to the log file
258
-     *
259
-     * @return string
260
-     */
261
-    public function getLastLogLine()
262
-    {
263
-        return $this->lastLine;
264
-    }
265
-
266
-    /**
267
-     * Formats the message for logging.
268
-     *
269
-     * @param  string $level   The Log Level of the message
270
-     * @param  string $message The message to log
271
-     * @param  array  $context The context
272
-     * @return string
273
-     */
274
-    protected function formatMessage($level, $message, $context)
275
-    {
276
-        if ($this->options['logFormat']) {
277
-            $parts = array(
278
-                'date'          => $this->getTimestamp(),
279
-                'level'         => strtoupper($level),
280
-                'level-padding' => str_repeat(' ', 9 - strlen($level)),
281
-                'priority'      => $this->logLevels[$level],
282
-                'message'       => $message,
283
-                'context'       => json_encode($context),
284
-            );
285
-            $message = $this->options['logFormat'];
286
-            foreach ($parts as $part => $value) {
287
-                $message = str_replace('{'.$part.'}', $value, $message);
288
-            }
289
-
290
-        } else {
291
-            $message = "[{$this->getTimestamp()}] [{$level}] {$message}";
292
-        }
293
-
294
-        if ($this->options['appendContext'] && ! empty($context)) {
295
-            $message .= PHP_EOL.$this->indent($this->contextToString($context));
296
-        }
297
-
298
-        return $message.PHP_EOL;
299
-
300
-    }
301
-
302
-    /**
303
-     * Gets the correctly formatted Date/Time for the log entry.
304
-     *
305
-     * PHP DateTime is dump, and you have to resort to trickery to get microseconds
306
-     * to work correctly, so here it is.
307
-     *
308
-     * @return string
309
-     */
310
-    private function getTimestamp()
311
-    {
312
-        $originalTime = microtime(true);
313
-        $micro = sprintf("%06d", ($originalTime - floor($originalTime)) * 1000000);
314
-        $date = new DateTime(date('Y-m-d H:i:s.'.$micro, (int)$originalTime));
315
-
316
-        return $date->format($this->options['dateFormat']);
317
-    }
318
-
319
-    /**
320
-     * Takes the given context and coverts it to a string.
321
-     *
322
-     * @param  array $context The Context
323
-     * @return string
324
-     */
325
-    protected function contextToString($context)
326
-    {
327
-        $export = '';
328
-        foreach ($context as $key => $value) {
329
-            $export .= "{$key}: ";
330
-            $export .= preg_replace(array(
331
-                '/=>\s+([a-zA-Z])/im',
332
-                '/array\(\s+\)/im',
333
-                '/^  |\G  /m'
334
-            ), array(
335
-                '=> $1',
336
-                'array()',
337
-                '    '
338
-            ), str_replace('array (', 'array(', var_export($value, true)));
339
-            $export .= PHP_EOL;
340
-        }
341
-        return str_replace(array('\\\\', '\\\''), array('\\', '\''), rtrim($export));
342
-    }
343
-
344
-    /**
345
-     * Indents the given string with the given indent.
346
-     *
347
-     * @param  string $string The string to indent
348
-     * @param  string $indent What to use as the indent.
349
-     * @return string
350
-     */
351
-    protected function indent($string, $indent = '    ')
352
-    {
353
-        return $indent.str_replace("\n", "\n".$indent, $string);
354
-    }
37
+	/**
38
+	 * KLogger options
39
+	 *  Anything options not considered 'core' to the logging library should be
40
+	 *  settable view the third parameter in the constructor
41
+	 *
42
+	 *  Core options include the log file path and the log threshold
43
+	 *
44
+	 * @var array
45
+	 */
46
+	protected $options = array (
47
+		'extension'      => 'txt',
48
+		'dateFormat'     => 'Y-m-d G:i:s.u',
49
+		'filename'       => false,
50
+		'flushFrequency' => false,
51
+		'prefix'         => 'log_',
52
+		'logFormat'      => false,
53
+		'appendContext'  => true,
54
+	);
55
+
56
+	/**
57
+	 * Path to the log file
58
+	 * @var string
59
+	 */
60
+	private $logFilePath;
61
+
62
+	/**
63
+	 * Current minimum logging threshold
64
+	 * @var integer
65
+	 */
66
+	protected $logLevelThreshold = LogLevel::DEBUG;
67
+
68
+	/**
69
+	 * The number of lines logged in this instance's lifetime
70
+	 * @var int
71
+	 */
72
+	private $logLineCount = 0;
73
+
74
+	/**
75
+	 * Log Levels
76
+	 * @var array
77
+	 */
78
+	protected $logLevels = array(
79
+		LogLevel::EMERGENCY => 0,
80
+		LogLevel::ALERT     => 1,
81
+		LogLevel::CRITICAL  => 2,
82
+		LogLevel::ERROR     => 3,
83
+		LogLevel::WARNING   => 4,
84
+		LogLevel::NOTICE    => 5,
85
+		LogLevel::INFO      => 6,
86
+		LogLevel::DEBUG     => 7
87
+	);
88
+
89
+	/**
90
+	 * This holds the file handle for this instance's log file
91
+	 * @var resource
92
+	 */
93
+	private $fileHandle;
94
+
95
+	/**
96
+	 * This holds the last line logged to the logger
97
+	 *  Used for unit tests
98
+	 * @var string
99
+	 */
100
+	private $lastLine = '';
101
+
102
+	/**
103
+	 * Octal notation for default permissions of the log file
104
+	 * @var integer
105
+	 */
106
+	private $defaultPermissions = 0777;
107
+
108
+	/**
109
+	 * Class constructor
110
+	 *
111
+	 * @param string $logDirectory      File path to the logging directory
112
+	 * @param string $logLevelThreshold The LogLevel Threshold
113
+	 * @param array  $options
114
+	 *
115
+	 * @internal param string $logFilePrefix The prefix for the log file name
116
+	 * @internal param string $logFileExt The extension for the log file
117
+	 */
118
+	public function __construct($logDirectory, $logLevelThreshold = LogLevel::DEBUG, array $options = array())
119
+	{
120
+		$this->logLevelThreshold = $logLevelThreshold;
121
+		$this->options = array_merge($this->options, $options);
122
+
123
+		$logDirectory = rtrim($logDirectory, DIRECTORY_SEPARATOR);
124
+		if ( ! file_exists($logDirectory)) {
125
+			mkdir($logDirectory, $this->defaultPermissions, true);
126
+		}
127
+
128
+		if(strpos($logDirectory, 'php://') === 0) {
129
+			$this->setLogToStdOut($logDirectory);
130
+			$this->setFileHandle('w+');
131
+		} else {
132
+			$this->setLogFilePath($logDirectory);
133
+			if(file_exists($this->logFilePath) && !is_writable($this->logFilePath)) {
134
+				throw new RuntimeException('The file could not be written to. Check that appropriate permissions have been set.');
135
+			}
136
+			$this->setFileHandle('a');
137
+		}
138
+
139
+		if ( ! $this->fileHandle) {
140
+			throw new RuntimeException('The file could not be opened. Check permissions.');
141
+		}
142
+	}
143
+
144
+	/**
145
+	 * @param string $stdOutPath
146
+	 */
147
+	public function setLogToStdOut($stdOutPath) {
148
+		$this->logFilePath = $stdOutPath;
149
+	}
150
+
151
+	/**
152
+	 * @param string $logDirectory
153
+	 */
154
+	public function setLogFilePath($logDirectory) {
155
+		if ($this->options['filename']) {
156
+			if (strpos($this->options['filename'], '.log') !== false || strpos($this->options['filename'], '.txt') !== false) {
157
+				$this->logFilePath = $logDirectory.DIRECTORY_SEPARATOR.$this->options['filename'];
158
+			}
159
+			else {
160
+				$this->logFilePath = $logDirectory.DIRECTORY_SEPARATOR.$this->options['filename'].'.'.$this->options['extension'];
161
+			}
162
+		} else {
163
+			$this->logFilePath = $logDirectory.DIRECTORY_SEPARATOR.$this->options['prefix'].date('Y-m-d').'.'.$this->options['extension'];
164
+		}
165
+	}
166
+
167
+	/**
168
+	 * @param $writeMode
169
+	 *
170
+	 * @internal param resource $fileHandle
171
+	 */
172
+	public function setFileHandle($writeMode) {
173
+		$this->fileHandle = fopen($this->logFilePath, $writeMode);
174
+	}
175
+
176
+
177
+	/**
178
+	 * Class destructor
179
+	 */
180
+	public function __destruct()
181
+	{
182
+		if ($this->fileHandle) {
183
+			fclose($this->fileHandle);
184
+		}
185
+	}
186
+
187
+	/**
188
+	 * Sets the date format used by all instances of KLogger
189
+	 *
190
+	 * @param string $dateFormat Valid format string for date()
191
+	 */
192
+	public function setDateFormat($dateFormat)
193
+	{
194
+		$this->options['dateFormat'] = $dateFormat;
195
+	}
196
+
197
+	/**
198
+	 * Sets the Log Level Threshold
199
+	 *
200
+	 * @param string $logLevelThreshold The log level threshold
201
+	 */
202
+	public function setLogLevelThreshold($logLevelThreshold)
203
+	{
204
+		$this->logLevelThreshold = $logLevelThreshold;
205
+	}
206
+
207
+	/**
208
+	 * Logs with an arbitrary level.
209
+	 *
210
+	 * @param mixed $level
211
+	 * @param string $message
212
+	 * @param array $context
213
+	 * @return null
214
+	 */
215
+	public function log($level, $message, array $context = array())
216
+	{
217
+		if ($this->logLevels[$this->logLevelThreshold] < $this->logLevels[$level]) {
218
+			return;
219
+		}
220
+		$message = $this->formatMessage($level, $message, $context);
221
+		$this->write($message);
222
+	}
223
+
224
+	/**
225
+	 * Writes a line to the log without prepending a status or timestamp
226
+	 *
227
+	 * @param string $message Line to write to the log
228
+	 * @return void
229
+	 */
230
+	public function write($message)
231
+	{
232
+		if (null !== $this->fileHandle) {
233
+			if (fwrite($this->fileHandle, $message) === false) {
234
+				throw new RuntimeException('The file could not be written to. Check that appropriate permissions have been set.');
235
+			} else {
236
+				$this->lastLine = trim($message);
237
+				$this->logLineCount++;
238
+
239
+				if ($this->options['flushFrequency'] && $this->logLineCount % $this->options['flushFrequency'] === 0) {
240
+					fflush($this->fileHandle);
241
+				}
242
+			}
243
+		}
244
+	}
245
+
246
+	/**
247
+	 * Get the file path that the log is currently writing to
248
+	 *
249
+	 * @return string
250
+	 */
251
+	public function getLogFilePath()
252
+	{
253
+		return $this->logFilePath;
254
+	}
255
+
256
+	/**
257
+	 * Get the last line logged to the log file
258
+	 *
259
+	 * @return string
260
+	 */
261
+	public function getLastLogLine()
262
+	{
263
+		return $this->lastLine;
264
+	}
265
+
266
+	/**
267
+	 * Formats the message for logging.
268
+	 *
269
+	 * @param  string $level   The Log Level of the message
270
+	 * @param  string $message The message to log
271
+	 * @param  array  $context The context
272
+	 * @return string
273
+	 */
274
+	protected function formatMessage($level, $message, $context)
275
+	{
276
+		if ($this->options['logFormat']) {
277
+			$parts = array(
278
+				'date'          => $this->getTimestamp(),
279
+				'level'         => strtoupper($level),
280
+				'level-padding' => str_repeat(' ', 9 - strlen($level)),
281
+				'priority'      => $this->logLevels[$level],
282
+				'message'       => $message,
283
+				'context'       => json_encode($context),
284
+			);
285
+			$message = $this->options['logFormat'];
286
+			foreach ($parts as $part => $value) {
287
+				$message = str_replace('{'.$part.'}', $value, $message);
288
+			}
289
+
290
+		} else {
291
+			$message = "[{$this->getTimestamp()}] [{$level}] {$message}";
292
+		}
293
+
294
+		if ($this->options['appendContext'] && ! empty($context)) {
295
+			$message .= PHP_EOL.$this->indent($this->contextToString($context));
296
+		}
297
+
298
+		return $message.PHP_EOL;
299
+
300
+	}
301
+
302
+	/**
303
+	 * Gets the correctly formatted Date/Time for the log entry.
304
+	 *
305
+	 * PHP DateTime is dump, and you have to resort to trickery to get microseconds
306
+	 * to work correctly, so here it is.
307
+	 *
308
+	 * @return string
309
+	 */
310
+	private function getTimestamp()
311
+	{
312
+		$originalTime = microtime(true);
313
+		$micro = sprintf("%06d", ($originalTime - floor($originalTime)) * 1000000);
314
+		$date = new DateTime(date('Y-m-d H:i:s.'.$micro, (int)$originalTime));
315
+
316
+		return $date->format($this->options['dateFormat']);
317
+	}
318
+
319
+	/**
320
+	 * Takes the given context and coverts it to a string.
321
+	 *
322
+	 * @param  array $context The Context
323
+	 * @return string
324
+	 */
325
+	protected function contextToString($context)
326
+	{
327
+		$export = '';
328
+		foreach ($context as $key => $value) {
329
+			$export .= "{$key}: ";
330
+			$export .= preg_replace(array(
331
+				'/=>\s+([a-zA-Z])/im',
332
+				'/array\(\s+\)/im',
333
+				'/^  |\G  /m'
334
+			), array(
335
+				'=> $1',
336
+				'array()',
337
+				'    '
338
+			), str_replace('array (', 'array(', var_export($value, true)));
339
+			$export .= PHP_EOL;
340
+		}
341
+		return str_replace(array('\\\\', '\\\''), array('\\', '\''), rtrim($export));
342
+	}
343
+
344
+	/**
345
+	 * Indents the given string with the given indent.
346
+	 *
347
+	 * @param  string $string The string to indent
348
+	 * @param  string $indent What to use as the indent.
349
+	 * @return string
350
+	 */
351
+	protected function indent($string, $indent = '    ')
352
+	{
353
+		return $indent.str_replace("\n", "\n".$indent, $string);
354
+	}
355 355
 }
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      *
44 44
      * @var array
45 45
      */
46
-    protected $options = array (
46
+    protected $options = array(
47 47
         'extension'      => 'txt',
48 48
         'dateFormat'     => 'Y-m-d G:i:s.u',
49 49
         'filename'       => false,
@@ -115,52 +115,52 @@  discard block
 block discarded – undo
115 115
      * @internal param string $logFilePrefix The prefix for the log file name
116 116
      * @internal param string $logFileExt The extension for the log file
117 117
      */
118
-    public function __construct($logDirectory, $logLevelThreshold = LogLevel::DEBUG, array $options = array())
118
+    public function __construct( $logDirectory, $logLevelThreshold = LogLevel::DEBUG, array $options = array() )
119 119
     {
120 120
         $this->logLevelThreshold = $logLevelThreshold;
121
-        $this->options = array_merge($this->options, $options);
121
+        $this->options = array_merge( $this->options, $options );
122 122
 
123
-        $logDirectory = rtrim($logDirectory, DIRECTORY_SEPARATOR);
124
-        if ( ! file_exists($logDirectory)) {
125
-            mkdir($logDirectory, $this->defaultPermissions, true);
123
+        $logDirectory = rtrim( $logDirectory, DIRECTORY_SEPARATOR );
124
+        if ( ! file_exists( $logDirectory ) ) {
125
+            mkdir( $logDirectory, $this->defaultPermissions, true );
126 126
         }
127 127
 
128
-        if(strpos($logDirectory, 'php://') === 0) {
129
-            $this->setLogToStdOut($logDirectory);
130
-            $this->setFileHandle('w+');
128
+        if ( strpos( $logDirectory, 'php://' ) === 0 ) {
129
+            $this->setLogToStdOut( $logDirectory );
130
+            $this->setFileHandle( 'w+' );
131 131
         } else {
132
-            $this->setLogFilePath($logDirectory);
133
-            if(file_exists($this->logFilePath) && !is_writable($this->logFilePath)) {
134
-                throw new RuntimeException('The file could not be written to. Check that appropriate permissions have been set.');
132
+            $this->setLogFilePath( $logDirectory );
133
+            if ( file_exists( $this->logFilePath ) && ! is_writable( $this->logFilePath ) ) {
134
+                throw new RuntimeException( 'The file could not be written to. Check that appropriate permissions have been set.' );
135 135
             }
136
-            $this->setFileHandle('a');
136
+            $this->setFileHandle( 'a' );
137 137
         }
138 138
 
139
-        if ( ! $this->fileHandle) {
140
-            throw new RuntimeException('The file could not be opened. Check permissions.');
139
+        if ( ! $this->fileHandle ) {
140
+            throw new RuntimeException( 'The file could not be opened. Check permissions.' );
141 141
         }
142 142
     }
143 143
 
144 144
     /**
145 145
      * @param string $stdOutPath
146 146
      */
147
-    public function setLogToStdOut($stdOutPath) {
147
+    public function setLogToStdOut( $stdOutPath ) {
148 148
         $this->logFilePath = $stdOutPath;
149 149
     }
150 150
 
151 151
     /**
152 152
      * @param string $logDirectory
153 153
      */
154
-    public function setLogFilePath($logDirectory) {
155
-        if ($this->options['filename']) {
156
-            if (strpos($this->options['filename'], '.log') !== false || strpos($this->options['filename'], '.txt') !== false) {
157
-                $this->logFilePath = $logDirectory.DIRECTORY_SEPARATOR.$this->options['filename'];
154
+    public function setLogFilePath( $logDirectory ) {
155
+        if ( $this->options[ 'filename' ] ) {
156
+            if ( strpos( $this->options[ 'filename' ], '.log' ) !== false || strpos( $this->options[ 'filename' ], '.txt' ) !== false ) {
157
+                $this->logFilePath = $logDirectory . DIRECTORY_SEPARATOR . $this->options[ 'filename' ];
158 158
             }
159 159
             else {
160
-                $this->logFilePath = $logDirectory.DIRECTORY_SEPARATOR.$this->options['filename'].'.'.$this->options['extension'];
160
+                $this->logFilePath = $logDirectory . DIRECTORY_SEPARATOR . $this->options[ 'filename' ] . '.' . $this->options[ 'extension' ];
161 161
             }
162 162
         } else {
163
-            $this->logFilePath = $logDirectory.DIRECTORY_SEPARATOR.$this->options['prefix'].date('Y-m-d').'.'.$this->options['extension'];
163
+            $this->logFilePath = $logDirectory . DIRECTORY_SEPARATOR . $this->options[ 'prefix' ] . date( 'Y-m-d' ) . '.' . $this->options[ 'extension' ];
164 164
         }
165 165
     }
166 166
 
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
      *
170 170
      * @internal param resource $fileHandle
171 171
      */
172
-    public function setFileHandle($writeMode) {
173
-        $this->fileHandle = fopen($this->logFilePath, $writeMode);
172
+    public function setFileHandle( $writeMode ) {
173
+        $this->fileHandle = fopen( $this->logFilePath, $writeMode );
174 174
     }
175 175
 
176 176
 
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
      */
180 180
     public function __destruct()
181 181
     {
182
-        if ($this->fileHandle) {
183
-            fclose($this->fileHandle);
182
+        if ( $this->fileHandle ) {
183
+            fclose( $this->fileHandle );
184 184
         }
185 185
     }
186 186
 
@@ -189,9 +189,9 @@  discard block
 block discarded – undo
189 189
      *
190 190
      * @param string $dateFormat Valid format string for date()
191 191
      */
192
-    public function setDateFormat($dateFormat)
192
+    public function setDateFormat( $dateFormat )
193 193
     {
194
-        $this->options['dateFormat'] = $dateFormat;
194
+        $this->options[ 'dateFormat' ] = $dateFormat;
195 195
     }
196 196
 
197 197
     /**
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
      *
200 200
      * @param string $logLevelThreshold The log level threshold
201 201
      */
202
-    public function setLogLevelThreshold($logLevelThreshold)
202
+    public function setLogLevelThreshold( $logLevelThreshold )
203 203
     {
204 204
         $this->logLevelThreshold = $logLevelThreshold;
205 205
     }
@@ -212,13 +212,13 @@  discard block
 block discarded – undo
212 212
      * @param array $context
213 213
      * @return null
214 214
      */
215
-    public function log($level, $message, array $context = array())
215
+    public function log( $level, $message, array $context = array() )
216 216
     {
217
-        if ($this->logLevels[$this->logLevelThreshold] < $this->logLevels[$level]) {
217
+        if ( $this->logLevels[ $this->logLevelThreshold ] < $this->logLevels[ $level ] ) {
218 218
             return;
219 219
         }
220
-        $message = $this->formatMessage($level, $message, $context);
221
-        $this->write($message);
220
+        $message = $this->formatMessage( $level, $message, $context );
221
+        $this->write( $message );
222 222
     }
223 223
 
224 224
     /**
@@ -227,17 +227,17 @@  discard block
 block discarded – undo
227 227
      * @param string $message Line to write to the log
228 228
      * @return void
229 229
      */
230
-    public function write($message)
230
+    public function write( $message )
231 231
     {
232
-        if (null !== $this->fileHandle) {
233
-            if (fwrite($this->fileHandle, $message) === false) {
234
-                throw new RuntimeException('The file could not be written to. Check that appropriate permissions have been set.');
232
+        if ( null !== $this->fileHandle ) {
233
+            if ( fwrite( $this->fileHandle, $message ) === false ) {
234
+                throw new RuntimeException( 'The file could not be written to. Check that appropriate permissions have been set.' );
235 235
             } else {
236
-                $this->lastLine = trim($message);
236
+                $this->lastLine = trim( $message );
237 237
                 $this->logLineCount++;
238 238
 
239
-                if ($this->options['flushFrequency'] && $this->logLineCount % $this->options['flushFrequency'] === 0) {
240
-                    fflush($this->fileHandle);
239
+                if ( $this->options[ 'flushFrequency' ] && $this->logLineCount % $this->options[ 'flushFrequency' ] === 0 ) {
240
+                    fflush( $this->fileHandle );
241 241
                 }
242 242
             }
243 243
         }
@@ -271,31 +271,31 @@  discard block
 block discarded – undo
271 271
      * @param  array  $context The context
272 272
      * @return string
273 273
      */
274
-    protected function formatMessage($level, $message, $context)
274
+    protected function formatMessage( $level, $message, $context )
275 275
     {
276
-        if ($this->options['logFormat']) {
276
+        if ( $this->options[ 'logFormat' ] ) {
277 277
             $parts = array(
278 278
                 'date'          => $this->getTimestamp(),
279
-                'level'         => strtoupper($level),
280
-                'level-padding' => str_repeat(' ', 9 - strlen($level)),
281
-                'priority'      => $this->logLevels[$level],
279
+                'level'         => strtoupper( $level ),
280
+                'level-padding' => str_repeat( ' ', 9 - strlen( $level ) ),
281
+                'priority'      => $this->logLevels[ $level ],
282 282
                 'message'       => $message,
283
-                'context'       => json_encode($context),
283
+                'context'       => json_encode( $context ),
284 284
             );
285
-            $message = $this->options['logFormat'];
286
-            foreach ($parts as $part => $value) {
287
-                $message = str_replace('{'.$part.'}', $value, $message);
285
+            $message = $this->options[ 'logFormat' ];
286
+            foreach ( $parts as $part => $value ) {
287
+                $message = str_replace( '{' . $part . '}', $value, $message );
288 288
             }
289 289
 
290 290
         } else {
291 291
             $message = "[{$this->getTimestamp()}] [{$level}] {$message}";
292 292
         }
293 293
 
294
-        if ($this->options['appendContext'] && ! empty($context)) {
295
-            $message .= PHP_EOL.$this->indent($this->contextToString($context));
294
+        if ( $this->options[ 'appendContext' ] && ! empty( $context ) ) {
295
+            $message .= PHP_EOL . $this->indent( $this->contextToString( $context ) );
296 296
         }
297 297
 
298
-        return $message.PHP_EOL;
298
+        return $message . PHP_EOL;
299 299
 
300 300
     }
301 301
 
@@ -309,11 +309,11 @@  discard block
 block discarded – undo
309 309
      */
310 310
     private function getTimestamp()
311 311
     {
312
-        $originalTime = microtime(true);
313
-        $micro = sprintf("%06d", ($originalTime - floor($originalTime)) * 1000000);
314
-        $date = new DateTime(date('Y-m-d H:i:s.'.$micro, (int)$originalTime));
312
+        $originalTime = microtime( true );
313
+        $micro = sprintf( "%06d", ( $originalTime - floor( $originalTime ) ) * 1000000 );
314
+        $date = new DateTime( date( 'Y-m-d H:i:s.' . $micro, (int)$originalTime ) );
315 315
 
316
-        return $date->format($this->options['dateFormat']);
316
+        return $date->format( $this->options[ 'dateFormat' ] );
317 317
     }
318 318
 
319 319
     /**
@@ -322,12 +322,12 @@  discard block
 block discarded – undo
322 322
      * @param  array $context The Context
323 323
      * @return string
324 324
      */
325
-    protected function contextToString($context)
325
+    protected function contextToString( $context )
326 326
     {
327 327
         $export = '';
328
-        foreach ($context as $key => $value) {
328
+        foreach ( $context as $key => $value ) {
329 329
             $export .= "{$key}: ";
330
-            $export .= preg_replace(array(
330
+            $export .= preg_replace( array(
331 331
                 '/=>\s+([a-zA-Z])/im',
332 332
                 '/array\(\s+\)/im',
333 333
                 '/^  |\G  /m'
@@ -335,10 +335,10 @@  discard block
 block discarded – undo
335 335
                 '=> $1',
336 336
                 'array()',
337 337
                 '    '
338
-            ), str_replace('array (', 'array(', var_export($value, true)));
338
+            ), str_replace( 'array (', 'array(', var_export( $value, true ) ) );
339 339
             $export .= PHP_EOL;
340 340
         }
341
-        return str_replace(array('\\\\', '\\\''), array('\\', '\''), rtrim($export));
341
+        return str_replace( array( '\\\\', '\\\'' ), array( '\\', '\'' ), rtrim( $export ) );
342 342
     }
343 343
 
344 344
     /**
@@ -348,8 +348,8 @@  discard block
 block discarded – undo
348 348
      * @param  string $indent What to use as the indent.
349 349
      * @return string
350 350
      */
351
-    protected function indent($string, $indent = '    ')
351
+    protected function indent( $string, $indent = '    ' )
352 352
     {
353
-        return $indent.str_replace("\n", "\n".$indent, $string);
353
+        return $indent . str_replace( "\n", "\n" . $indent, $string );
354 354
     }
355 355
 }
Please login to merge, or discard this patch.
Braces   +36 added lines, -50 removed lines patch added patch discarded remove patch
@@ -32,8 +32,7 @@  discard block
 block discarded – undo
32 32
 /**
33 33
  * Class documentation
34 34
  */
35
-class Logger extends AbstractLogger
36
-{
35
+class Logger extends AbstractLogger {
37 36
     /**
38 37
      * KLogger options
39 38
      *  Anything options not considered 'core' to the logging library should be
@@ -115,28 +114,27 @@  discard block
 block discarded – undo
115 114
      * @internal param string $logFilePrefix The prefix for the log file name
116 115
      * @internal param string $logFileExt The extension for the log file
117 116
      */
118
-    public function __construct($logDirectory, $logLevelThreshold = LogLevel::DEBUG, array $options = array())
119
-    {
117
+    public function __construct($logDirectory, $logLevelThreshold = LogLevel::DEBUG, array $options = array()) {
120 118
         $this->logLevelThreshold = $logLevelThreshold;
121 119
         $this->options = array_merge($this->options, $options);
122 120
 
123 121
         $logDirectory = rtrim($logDirectory, DIRECTORY_SEPARATOR);
124
-        if ( ! file_exists($logDirectory)) {
122
+        if ( ! file_exists($logDirectory)) {
125 123
             mkdir($logDirectory, $this->defaultPermissions, true);
126 124
         }
127 125
 
128
-        if(strpos($logDirectory, 'php://') === 0) {
126
+        if(strpos($logDirectory, 'php://') === 0) {
129 127
             $this->setLogToStdOut($logDirectory);
130 128
             $this->setFileHandle('w+');
131
-        } else {
129
+        } else {
132 130
             $this->setLogFilePath($logDirectory);
133
-            if(file_exists($this->logFilePath) && !is_writable($this->logFilePath)) {
131
+            if(file_exists($this->logFilePath) && !is_writable($this->logFilePath)) {
134 132
                 throw new RuntimeException('The file could not be written to. Check that appropriate permissions have been set.');
135 133
             }
136 134
             $this->setFileHandle('a');
137 135
         }
138 136
 
139
-        if ( ! $this->fileHandle) {
137
+        if ( ! $this->fileHandle) {
140 138
             throw new RuntimeException('The file could not be opened. Check permissions.');
141 139
         }
142 140
     }
@@ -144,22 +142,21 @@  discard block
 block discarded – undo
144 142
     /**
145 143
      * @param string $stdOutPath
146 144
      */
147
-    public function setLogToStdOut($stdOutPath) {
145
+    public function setLogToStdOut($stdOutPath) {
148 146
         $this->logFilePath = $stdOutPath;
149 147
     }
150 148
 
151 149
     /**
152 150
      * @param string $logDirectory
153 151
      */
154
-    public function setLogFilePath($logDirectory) {
155
-        if ($this->options['filename']) {
156
-            if (strpos($this->options['filename'], '.log') !== false || strpos($this->options['filename'], '.txt') !== false) {
152
+    public function setLogFilePath($logDirectory) {
153
+        if ($this->options['filename']) {
154
+            if (strpos($this->options['filename'], '.log') !== false || strpos($this->options['filename'], '.txt') !== false) {
157 155
                 $this->logFilePath = $logDirectory.DIRECTORY_SEPARATOR.$this->options['filename'];
158
-            }
159
-            else {
156
+            } else {
160 157
                 $this->logFilePath = $logDirectory.DIRECTORY_SEPARATOR.$this->options['filename'].'.'.$this->options['extension'];
161 158
             }
162
-        } else {
159
+        } else {
163 160
             $this->logFilePath = $logDirectory.DIRECTORY_SEPARATOR.$this->options['prefix'].date('Y-m-d').'.'.$this->options['extension'];
164 161
         }
165 162
     }
@@ -169,7 +166,7 @@  discard block
 block discarded – undo
169 166
      *
170 167
      * @internal param resource $fileHandle
171 168
      */
172
-    public function setFileHandle($writeMode) {
169
+    public function setFileHandle($writeMode) {
173 170
         $this->fileHandle = fopen($this->logFilePath, $writeMode);
174 171
     }
175 172
 
@@ -177,9 +174,8 @@  discard block
 block discarded – undo
177 174
     /**
178 175
      * Class destructor
179 176
      */
180
-    public function __destruct()
181
-    {
182
-        if ($this->fileHandle) {
177
+    public function __destruct() {
178
+        if ($this->fileHandle) {
183 179
             fclose($this->fileHandle);
184 180
         }
185 181
     }
@@ -189,8 +185,7 @@  discard block
 block discarded – undo
189 185
      *
190 186
      * @param string $dateFormat Valid format string for date()
191 187
      */
192
-    public function setDateFormat($dateFormat)
193
-    {
188
+    public function setDateFormat($dateFormat) {
194 189
         $this->options['dateFormat'] = $dateFormat;
195 190
     }
196 191
 
@@ -199,8 +194,7 @@  discard block
 block discarded – undo
199 194
      *
200 195
      * @param string $logLevelThreshold The log level threshold
201 196
      */
202
-    public function setLogLevelThreshold($logLevelThreshold)
203
-    {
197
+    public function setLogLevelThreshold($logLevelThreshold) {
204 198
         $this->logLevelThreshold = $logLevelThreshold;
205 199
     }
206 200
 
@@ -212,9 +206,8 @@  discard block
 block discarded – undo
212 206
      * @param array $context
213 207
      * @return null
214 208
      */
215
-    public function log($level, $message, array $context = array())
216
-    {
217
-        if ($this->logLevels[$this->logLevelThreshold] < $this->logLevels[$level]) {
209
+    public function log($level, $message, array $context = array()) {
210
+        if ($this->logLevels[$this->logLevelThreshold] < $this->logLevels[$level]) {
218 211
             return;
219 212
         }
220 213
         $message = $this->formatMessage($level, $message, $context);
@@ -227,16 +220,15 @@  discard block
 block discarded – undo
227 220
      * @param string $message Line to write to the log
228 221
      * @return void
229 222
      */
230
-    public function write($message)
231
-    {
232
-        if (null !== $this->fileHandle) {
233
-            if (fwrite($this->fileHandle, $message) === false) {
223
+    public function write($message) {
224
+        if (null !== $this->fileHandle) {
225
+            if (fwrite($this->fileHandle, $message) === false) {
234 226
                 throw new RuntimeException('The file could not be written to. Check that appropriate permissions have been set.');
235
-            } else {
227
+            } else {
236 228
                 $this->lastLine = trim($message);
237 229
                 $this->logLineCount++;
238 230
 
239
-                if ($this->options['flushFrequency'] && $this->logLineCount % $this->options['flushFrequency'] === 0) {
231
+                if ($this->options['flushFrequency'] && $this->logLineCount % $this->options['flushFrequency'] === 0) {
240 232
                     fflush($this->fileHandle);
241 233
                 }
242 234
             }
@@ -248,8 +240,7 @@  discard block
 block discarded – undo
248 240
      *
249 241
      * @return string
250 242
      */
251
-    public function getLogFilePath()
252
-    {
243
+    public function getLogFilePath() {
253 244
         return $this->logFilePath;
254 245
     }
255 246
 
@@ -258,8 +249,7 @@  discard block
 block discarded – undo
258 249
      *
259 250
      * @return string
260 251
      */
261
-    public function getLastLogLine()
262
-    {
252
+    public function getLastLogLine() {
263 253
         return $this->lastLine;
264 254
     }
265 255
 
@@ -271,9 +261,8 @@  discard block
 block discarded – undo
271 261
      * @param  array  $context The context
272 262
      * @return string
273 263
      */
274
-    protected function formatMessage($level, $message, $context)
275
-    {
276
-        if ($this->options['logFormat']) {
264
+    protected function formatMessage($level, $message, $context) {
265
+        if ($this->options['logFormat']) {
277 266
             $parts = array(
278 267
                 'date'          => $this->getTimestamp(),
279 268
                 'level'         => strtoupper($level),
@@ -283,15 +272,15 @@  discard block
 block discarded – undo
283 272
                 'context'       => json_encode($context),
284 273
             );
285 274
             $message = $this->options['logFormat'];
286
-            foreach ($parts as $part => $value) {
275
+            foreach ($parts as $part => $value) {
287 276
                 $message = str_replace('{'.$part.'}', $value, $message);
288 277
             }
289 278
 
290
-        } else {
279
+        } else {
291 280
             $message = "[{$this->getTimestamp()}] [{$level}] {$message}";
292 281
         }
293 282
 
294
-        if ($this->options['appendContext'] && ! empty($context)) {
283
+        if ($this->options['appendContext'] && ! empty($context)) {
295 284
             $message .= PHP_EOL.$this->indent($this->contextToString($context));
296 285
         }
297 286
 
@@ -307,8 +296,7 @@  discard block
 block discarded – undo
307 296
      *
308 297
      * @return string
309 298
      */
310
-    private function getTimestamp()
311
-    {
299
+    private function getTimestamp() {
312 300
         $originalTime = microtime(true);
313 301
         $micro = sprintf("%06d", ($originalTime - floor($originalTime)) * 1000000);
314 302
         $date = new DateTime(date('Y-m-d H:i:s.'.$micro, (int)$originalTime));
@@ -322,10 +310,9 @@  discard block
 block discarded – undo
322 310
      * @param  array $context The Context
323 311
      * @return string
324 312
      */
325
-    protected function contextToString($context)
326
-    {
313
+    protected function contextToString($context) {
327 314
         $export = '';
328
-        foreach ($context as $key => $value) {
315
+        foreach ($context as $key => $value) {
329 316
             $export .= "{$key}: ";
330 317
             $export .= preg_replace(array(
331 318
                 '/=>\s+([a-zA-Z])/im',
@@ -348,8 +335,7 @@  discard block
 block discarded – undo
348 335
      * @param  string $indent What to use as the indent.
349 336
      * @return string
350 337
      */
351
-    protected function indent($string, $indent = '    ')
352
-    {
338
+    protected function indent($string, $indent = '    ') {
353 339
         return $indent.str_replace("\n", "\n".$indent, $string);
354 340
     }
355 341
 }
Please login to merge, or discard this patch.
vendor_prefixed/illuminate/translation/FileLoader.php 3 patches
Indentation   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -12,152 +12,152 @@
 block discarded – undo
12 12
 
13 13
 class FileLoader implements LoaderInterface
14 14
 {
15
-    /**
16
-     * The filesystem instance.
17
-     *
18
-     * @var \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Filesystem\Filesystem
19
-     */
20
-    protected $files;
21
-
22
-    /**
23
-     * The default path for the loader.
24
-     *
25
-     * @var string
26
-     */
27
-    protected $path;
28
-
29
-    /**
30
-     * All of the namespace hints.
31
-     *
32
-     * @var array
33
-     */
34
-    protected $hints = [];
35
-
36
-    /**
37
-     * Create a new file loader instance.
38
-     *
39
-     * @param  \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Filesystem\Filesystem  $files
40
-     * @param  string  $path
41
-     * @return void
42
-     */
43
-    public function __construct(Filesystem $files, $path)
44
-    {
45
-        $this->path = $path;
46
-        $this->files = $files;
47
-    }
48
-
49
-    /**
50
-     * Load the messages for the given locale.
51
-     *
52
-     * @param  string  $locale
53
-     * @param  string  $group
54
-     * @param  string  $namespace
55
-     * @return array
56
-     */
57
-    public function load($locale, $group, $namespace = null)
58
-    {
59
-        if ($group == '*' && $namespace == '*') {
60
-            return $this->loadJsonPath($this->path, $locale);
61
-        }
62
-
63
-        if (is_null($namespace) || $namespace == '*') {
64
-            return $this->loadPath($this->path, $locale, $group);
65
-        }
66
-
67
-        return $this->loadNamespaced($locale, $group, $namespace);
68
-    }
69
-
70
-    /**
71
-     * Load a namespaced translation group.
72
-     *
73
-     * @param  string  $locale
74
-     * @param  string  $group
75
-     * @param  string  $namespace
76
-     * @return array
77
-     */
78
-    protected function loadNamespaced($locale, $group, $namespace)
79
-    {
80
-        if (isset($this->hints[$namespace])) {
81
-            $lines = $this->loadPath($this->hints[$namespace], $locale, $group);
82
-
83
-            return $this->loadNamespaceOverrides($lines, $locale, $group, $namespace);
84
-        }
85
-
86
-        return [];
87
-    }
88
-
89
-    /**
90
-     * Load a local namespaced translation group for overrides.
91
-     *
92
-     * @param  array  $lines
93
-     * @param  string  $locale
94
-     * @param  string  $group
95
-     * @param  string  $namespace
96
-     * @return array
97
-     */
98
-    protected function loadNamespaceOverrides(array $lines, $locale, $group, $namespace)
99
-    {
100
-        $file = "{$this->path}/vendor/{$namespace}/{$locale}/{$group}.php";
101
-
102
-        if ($this->files->exists($file)) {
103
-            return array_replace_recursive($lines, $this->files->getRequire($file));
104
-        }
105
-
106
-        return $lines;
107
-    }
108
-
109
-    /**
110
-     * Load a locale from a given path.
111
-     *
112
-     * @param  string  $path
113
-     * @param  string  $locale
114
-     * @param  string  $group
115
-     * @return array
116
-     */
117
-    protected function loadPath($path, $locale, $group)
118
-    {
119
-        if ($this->files->exists($full = "{$path}/{$locale}/{$group}.php")) {
120
-            return $this->files->getRequire($full);
121
-        }
122
-
123
-        return [];
124
-    }
125
-
126
-    /**
127
-     * Load a locale from the given JSON file path.
128
-     *
129
-     * @param  string  $path
130
-     * @param  string  $locale
131
-     * @return array
132
-     */
133
-    protected function loadJsonPath($path, $locale)
134
-    {
135
-        if ($this->files->exists($full = "{$path}/{$locale}.json")) {
136
-            return json_decode($this->files->get($full), true);
137
-        }
138
-
139
-        return [];
140
-    }
141
-
142
-    /**
143
-     * Add a new namespace to the loader.
144
-     *
145
-     * @param  string  $namespace
146
-     * @param  string  $hint
147
-     * @return void
148
-     */
149
-    public function addNamespace($namespace, $hint)
150
-    {
151
-        $this->hints[$namespace] = $hint;
152
-    }
153
-
154
-    /**
155
-     * Get an array of all the registered namespaces.
156
-     *
157
-     * @return array
158
-     */
159
-    public function namespaces()
160
-    {
161
-        return $this->hints;
162
-    }
15
+	/**
16
+	 * The filesystem instance.
17
+	 *
18
+	 * @var \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Filesystem\Filesystem
19
+	 */
20
+	protected $files;
21
+
22
+	/**
23
+	 * The default path for the loader.
24
+	 *
25
+	 * @var string
26
+	 */
27
+	protected $path;
28
+
29
+	/**
30
+	 * All of the namespace hints.
31
+	 *
32
+	 * @var array
33
+	 */
34
+	protected $hints = [];
35
+
36
+	/**
37
+	 * Create a new file loader instance.
38
+	 *
39
+	 * @param  \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Filesystem\Filesystem  $files
40
+	 * @param  string  $path
41
+	 * @return void
42
+	 */
43
+	public function __construct(Filesystem $files, $path)
44
+	{
45
+		$this->path = $path;
46
+		$this->files = $files;
47
+	}
48
+
49
+	/**
50
+	 * Load the messages for the given locale.
51
+	 *
52
+	 * @param  string  $locale
53
+	 * @param  string  $group
54
+	 * @param  string  $namespace
55
+	 * @return array
56
+	 */
57
+	public function load($locale, $group, $namespace = null)
58
+	{
59
+		if ($group == '*' && $namespace == '*') {
60
+			return $this->loadJsonPath($this->path, $locale);
61
+		}
62
+
63
+		if (is_null($namespace) || $namespace == '*') {
64
+			return $this->loadPath($this->path, $locale, $group);
65
+		}
66
+
67
+		return $this->loadNamespaced($locale, $group, $namespace);
68
+	}
69
+
70
+	/**
71
+	 * Load a namespaced translation group.
72
+	 *
73
+	 * @param  string  $locale
74
+	 * @param  string  $group
75
+	 * @param  string  $namespace
76
+	 * @return array
77
+	 */
78
+	protected function loadNamespaced($locale, $group, $namespace)
79
+	{
80
+		if (isset($this->hints[$namespace])) {
81
+			$lines = $this->loadPath($this->hints[$namespace], $locale, $group);
82
+
83
+			return $this->loadNamespaceOverrides($lines, $locale, $group, $namespace);
84
+		}
85
+
86
+		return [];
87
+	}
88
+
89
+	/**
90
+	 * Load a local namespaced translation group for overrides.
91
+	 *
92
+	 * @param  array  $lines
93
+	 * @param  string  $locale
94
+	 * @param  string  $group
95
+	 * @param  string  $namespace
96
+	 * @return array
97
+	 */
98
+	protected function loadNamespaceOverrides(array $lines, $locale, $group, $namespace)
99
+	{
100
+		$file = "{$this->path}/vendor/{$namespace}/{$locale}/{$group}.php";
101
+
102
+		if ($this->files->exists($file)) {
103
+			return array_replace_recursive($lines, $this->files->getRequire($file));
104
+		}
105
+
106
+		return $lines;
107
+	}
108
+
109
+	/**
110
+	 * Load a locale from a given path.
111
+	 *
112
+	 * @param  string  $path
113
+	 * @param  string  $locale
114
+	 * @param  string  $group
115
+	 * @return array
116
+	 */
117
+	protected function loadPath($path, $locale, $group)
118
+	{
119
+		if ($this->files->exists($full = "{$path}/{$locale}/{$group}.php")) {
120
+			return $this->files->getRequire($full);
121
+		}
122
+
123
+		return [];
124
+	}
125
+
126
+	/**
127
+	 * Load a locale from the given JSON file path.
128
+	 *
129
+	 * @param  string  $path
130
+	 * @param  string  $locale
131
+	 * @return array
132
+	 */
133
+	protected function loadJsonPath($path, $locale)
134
+	{
135
+		if ($this->files->exists($full = "{$path}/{$locale}.json")) {
136
+			return json_decode($this->files->get($full), true);
137
+		}
138
+
139
+		return [];
140
+	}
141
+
142
+	/**
143
+	 * Add a new namespace to the loader.
144
+	 *
145
+	 * @param  string  $namespace
146
+	 * @param  string  $hint
147
+	 * @return void
148
+	 */
149
+	public function addNamespace($namespace, $hint)
150
+	{
151
+		$this->hints[$namespace] = $hint;
152
+	}
153
+
154
+	/**
155
+	 * Get an array of all the registered namespaces.
156
+	 *
157
+	 * @return array
158
+	 */
159
+	public function namespaces()
160
+	{
161
+		return $this->hints;
162
+	}
163 163
 }
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      *
32 32
      * @var array
33 33
      */
34
-    protected $hints = [];
34
+    protected $hints = [ ];
35 35
 
36 36
     /**
37 37
      * Create a new file loader instance.
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      * @param  string  $path
41 41
      * @return void
42 42
      */
43
-    public function __construct(Filesystem $files, $path)
43
+    public function __construct( Filesystem $files, $path )
44 44
     {
45 45
         $this->path = $path;
46 46
         $this->files = $files;
@@ -54,17 +54,17 @@  discard block
 block discarded – undo
54 54
      * @param  string  $namespace
55 55
      * @return array
56 56
      */
57
-    public function load($locale, $group, $namespace = null)
57
+    public function load( $locale, $group, $namespace = null )
58 58
     {
59
-        if ($group == '*' && $namespace == '*') {
60
-            return $this->loadJsonPath($this->path, $locale);
59
+        if ( $group == '*' && $namespace == '*' ) {
60
+            return $this->loadJsonPath( $this->path, $locale );
61 61
         }
62 62
 
63
-        if (is_null($namespace) || $namespace == '*') {
64
-            return $this->loadPath($this->path, $locale, $group);
63
+        if ( is_null( $namespace ) || $namespace == '*' ) {
64
+            return $this->loadPath( $this->path, $locale, $group );
65 65
         }
66 66
 
67
-        return $this->loadNamespaced($locale, $group, $namespace);
67
+        return $this->loadNamespaced( $locale, $group, $namespace );
68 68
     }
69 69
 
70 70
     /**
@@ -75,15 +75,15 @@  discard block
 block discarded – undo
75 75
      * @param  string  $namespace
76 76
      * @return array
77 77
      */
78
-    protected function loadNamespaced($locale, $group, $namespace)
78
+    protected function loadNamespaced( $locale, $group, $namespace )
79 79
     {
80
-        if (isset($this->hints[$namespace])) {
81
-            $lines = $this->loadPath($this->hints[$namespace], $locale, $group);
80
+        if ( isset( $this->hints[ $namespace ] ) ) {
81
+            $lines = $this->loadPath( $this->hints[ $namespace ], $locale, $group );
82 82
 
83
-            return $this->loadNamespaceOverrides($lines, $locale, $group, $namespace);
83
+            return $this->loadNamespaceOverrides( $lines, $locale, $group, $namespace );
84 84
         }
85 85
 
86
-        return [];
86
+        return [ ];
87 87
     }
88 88
 
89 89
     /**
@@ -95,12 +95,12 @@  discard block
 block discarded – undo
95 95
      * @param  string  $namespace
96 96
      * @return array
97 97
      */
98
-    protected function loadNamespaceOverrides(array $lines, $locale, $group, $namespace)
98
+    protected function loadNamespaceOverrides( array $lines, $locale, $group, $namespace )
99 99
     {
100 100
         $file = "{$this->path}/vendor/{$namespace}/{$locale}/{$group}.php";
101 101
 
102
-        if ($this->files->exists($file)) {
103
-            return array_replace_recursive($lines, $this->files->getRequire($file));
102
+        if ( $this->files->exists( $file ) ) {
103
+            return array_replace_recursive( $lines, $this->files->getRequire( $file ) );
104 104
         }
105 105
 
106 106
         return $lines;
@@ -114,13 +114,13 @@  discard block
 block discarded – undo
114 114
      * @param  string  $group
115 115
      * @return array
116 116
      */
117
-    protected function loadPath($path, $locale, $group)
117
+    protected function loadPath( $path, $locale, $group )
118 118
     {
119
-        if ($this->files->exists($full = "{$path}/{$locale}/{$group}.php")) {
120
-            return $this->files->getRequire($full);
119
+        if ( $this->files->exists( $full = "{$path}/{$locale}/{$group}.php" ) ) {
120
+            return $this->files->getRequire( $full );
121 121
         }
122 122
 
123
-        return [];
123
+        return [ ];
124 124
     }
125 125
 
126 126
     /**
@@ -130,13 +130,13 @@  discard block
 block discarded – undo
130 130
      * @param  string  $locale
131 131
      * @return array
132 132
      */
133
-    protected function loadJsonPath($path, $locale)
133
+    protected function loadJsonPath( $path, $locale )
134 134
     {
135
-        if ($this->files->exists($full = "{$path}/{$locale}.json")) {
136
-            return json_decode($this->files->get($full), true);
135
+        if ( $this->files->exists( $full = "{$path}/{$locale}.json" ) ) {
136
+            return json_decode( $this->files->get( $full ), true );
137 137
         }
138 138
 
139
-        return [];
139
+        return [ ];
140 140
     }
141 141
 
142 142
     /**
@@ -146,9 +146,9 @@  discard block
 block discarded – undo
146 146
      * @param  string  $hint
147 147
      * @return void
148 148
      */
149
-    public function addNamespace($namespace, $hint)
149
+    public function addNamespace( $namespace, $hint )
150 150
     {
151
-        $this->hints[$namespace] = $hint;
151
+        $this->hints[ $namespace ] = $hint;
152 152
     }
153 153
 
154 154
     /**
Please login to merge, or discard this patch.
Braces   +9 added lines, -18 removed lines patch added patch discarded remove patch
@@ -10,8 +10,7 @@  discard block
 block discarded – undo
10 10
 
11 11
 use GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Filesystem\Filesystem;
12 12
 
13
-class FileLoader implements LoaderInterface
14
-{
13
+class FileLoader implements LoaderInterface {
15 14
     /**
16 15
      * The filesystem instance.
17 16
      *
@@ -40,8 +39,7 @@  discard block
 block discarded – undo
40 39
      * @param  string  $path
41 40
      * @return void
42 41
      */
43
-    public function __construct(Filesystem $files, $path)
44
-    {
42
+    public function __construct(Filesystem $files, $path) {
45 43
         $this->path = $path;
46 44
         $this->files = $files;
47 45
     }
@@ -54,8 +52,7 @@  discard block
 block discarded – undo
54 52
      * @param  string  $namespace
55 53
      * @return array
56 54
      */
57
-    public function load($locale, $group, $namespace = null)
58
-    {
55
+    public function load($locale, $group, $namespace = null) {
59 56
         if ($group == '*' && $namespace == '*') {
60 57
             return $this->loadJsonPath($this->path, $locale);
61 58
         }
@@ -75,8 +72,7 @@  discard block
 block discarded – undo
75 72
      * @param  string  $namespace
76 73
      * @return array
77 74
      */
78
-    protected function loadNamespaced($locale, $group, $namespace)
79
-    {
75
+    protected function loadNamespaced($locale, $group, $namespace) {
80 76
         if (isset($this->hints[$namespace])) {
81 77
             $lines = $this->loadPath($this->hints[$namespace], $locale, $group);
82 78
 
@@ -95,8 +91,7 @@  discard block
 block discarded – undo
95 91
      * @param  string  $namespace
96 92
      * @return array
97 93
      */
98
-    protected function loadNamespaceOverrides(array $lines, $locale, $group, $namespace)
99
-    {
94
+    protected function loadNamespaceOverrides(array $lines, $locale, $group, $namespace) {
100 95
         $file = "{$this->path}/vendor/{$namespace}/{$locale}/{$group}.php";
101 96
 
102 97
         if ($this->files->exists($file)) {
@@ -114,8 +109,7 @@  discard block
 block discarded – undo
114 109
      * @param  string  $group
115 110
      * @return array
116 111
      */
117
-    protected function loadPath($path, $locale, $group)
118
-    {
112
+    protected function loadPath($path, $locale, $group) {
119 113
         if ($this->files->exists($full = "{$path}/{$locale}/{$group}.php")) {
120 114
             return $this->files->getRequire($full);
121 115
         }
@@ -130,8 +124,7 @@  discard block
 block discarded – undo
130 124
      * @param  string  $locale
131 125
      * @return array
132 126
      */
133
-    protected function loadJsonPath($path, $locale)
134
-    {
127
+    protected function loadJsonPath($path, $locale) {
135 128
         if ($this->files->exists($full = "{$path}/{$locale}.json")) {
136 129
             return json_decode($this->files->get($full), true);
137 130
         }
@@ -146,8 +139,7 @@  discard block
 block discarded – undo
146 139
      * @param  string  $hint
147 140
      * @return void
148 141
      */
149
-    public function addNamespace($namespace, $hint)
150
-    {
142
+    public function addNamespace($namespace, $hint) {
151 143
         $this->hints[$namespace] = $hint;
152 144
     }
153 145
 
@@ -156,8 +148,7 @@  discard block
 block discarded – undo
156 148
      *
157 149
      * @return array
158 150
      */
159
-    public function namespaces()
160
-    {
151
+    public function namespaces() {
161 152
         return $this->hints;
162 153
     }
163 154
 }
Please login to merge, or discard this patch.
vendor_prefixed/illuminate/translation/TranslationServiceProvider.php 3 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -12,57 +12,57 @@
 block discarded – undo
12 12
 
13 13
 class TranslationServiceProvider extends ServiceProvider
14 14
 {
15
-    /**
16
-     * Indicates if loading of the provider is deferred.
17
-     *
18
-     * @var bool
19
-     */
20
-    protected $defer = true;
15
+	/**
16
+	 * Indicates if loading of the provider is deferred.
17
+	 *
18
+	 * @var bool
19
+	 */
20
+	protected $defer = true;
21 21
 
22
-    /**
23
-     * Register the service provider.
24
-     *
25
-     * @return void
26
-     */
27
-    public function register()
28
-    {
29
-        $this->registerLoader();
22
+	/**
23
+	 * Register the service provider.
24
+	 *
25
+	 * @return void
26
+	 */
27
+	public function register()
28
+	{
29
+		$this->registerLoader();
30 30
 
31
-        $this->app->singleton('translator', function ($app) {
32
-            $loader = $app['translation.loader'];
31
+		$this->app->singleton('translator', function ($app) {
32
+			$loader = $app['translation.loader'];
33 33
 
34
-            // When registering the translator component, we'll need to set the default
35
-            // locale as well as the fallback locale. So, we'll grab the application
36
-            // configuration so we can easily get both of these values from there.
37
-            $locale = $app['config']['app.locale'];
34
+			// When registering the translator component, we'll need to set the default
35
+			// locale as well as the fallback locale. So, we'll grab the application
36
+			// configuration so we can easily get both of these values from there.
37
+			$locale = $app['config']['app.locale'];
38 38
 
39
-            $trans = new Translator($loader, $locale);
39
+			$trans = new Translator($loader, $locale);
40 40
 
41
-            $trans->setFallback($app['config']['app.fallback_locale']);
41
+			$trans->setFallback($app['config']['app.fallback_locale']);
42 42
 
43
-            return $trans;
44
-        });
45
-    }
43
+			return $trans;
44
+		});
45
+	}
46 46
 
47
-    /**
48
-     * Register the translation line loader.
49
-     *
50
-     * @return void
51
-     */
52
-    protected function registerLoader()
53
-    {
54
-        $this->app->singleton('translation.loader', function ($app) {
55
-            return new FileLoader($app['files'], $app['path.lang']);
56
-        });
57
-    }
47
+	/**
48
+	 * Register the translation line loader.
49
+	 *
50
+	 * @return void
51
+	 */
52
+	protected function registerLoader()
53
+	{
54
+		$this->app->singleton('translation.loader', function ($app) {
55
+			return new FileLoader($app['files'], $app['path.lang']);
56
+		});
57
+	}
58 58
 
59
-    /**
60
-     * Get the services provided by the provider.
61
-     *
62
-     * @return array
63
-     */
64
-    public function provides()
65
-    {
66
-        return ['translator', 'translation.loader'];
67
-    }
59
+	/**
60
+	 * Get the services provided by the provider.
61
+	 *
62
+	 * @return array
63
+	 */
64
+	public function provides()
65
+	{
66
+		return ['translator', 'translation.loader'];
67
+	}
68 68
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -28,17 +28,17 @@  discard block
 block discarded – undo
28 28
     {
29 29
         $this->registerLoader();
30 30
 
31
-        $this->app->singleton('translator', function ($app) {
32
-            $loader = $app['translation.loader'];
31
+        $this->app->singleton( 'translator', function( $app ) {
32
+            $loader = $app[ 'translation.loader' ];
33 33
 
34 34
             // When registering the translator component, we'll need to set the default
35 35
             // locale as well as the fallback locale. So, we'll grab the application
36 36
             // configuration so we can easily get both of these values from there.
37
-            $locale = $app['config']['app.locale'];
37
+            $locale = $app[ 'config' ][ 'app.locale' ];
38 38
 
39
-            $trans = new Translator($loader, $locale);
39
+            $trans = new Translator( $loader, $locale );
40 40
 
41
-            $trans->setFallback($app['config']['app.fallback_locale']);
41
+            $trans->setFallback( $app[ 'config' ][ 'app.fallback_locale' ] );
42 42
 
43 43
             return $trans;
44 44
         });
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
      */
52 52
     protected function registerLoader()
53 53
     {
54
-        $this->app->singleton('translation.loader', function ($app) {
55
-            return new FileLoader($app['files'], $app['path.lang']);
54
+        $this->app->singleton( 'translation.loader', function( $app ) {
55
+            return new FileLoader( $app[ 'files' ], $app[ 'path.lang' ] );
56 56
         });
57 57
     }
58 58
 
@@ -63,6 +63,6 @@  discard block
 block discarded – undo
63 63
      */
64 64
     public function provides()
65 65
     {
66
-        return ['translator', 'translation.loader'];
66
+        return [ 'translator', 'translation.loader' ];
67 67
     }
68 68
 }
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -10,8 +10,7 @@  discard block
 block discarded – undo
10 10
 
11 11
 use GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Support\ServiceProvider;
12 12
 
13
-class TranslationServiceProvider extends ServiceProvider
14
-{
13
+class TranslationServiceProvider extends ServiceProvider {
15 14
     /**
16 15
      * Indicates if loading of the provider is deferred.
17 16
      *
@@ -24,8 +23,7 @@  discard block
 block discarded – undo
24 23
      *
25 24
      * @return void
26 25
      */
27
-    public function register()
28
-    {
26
+    public function register() {
29 27
         $this->registerLoader();
30 28
 
31 29
         $this->app->singleton('translator', function ($app) {
@@ -49,8 +47,7 @@  discard block
 block discarded – undo
49 47
      *
50 48
      * @return void
51 49
      */
52
-    protected function registerLoader()
53
-    {
50
+    protected function registerLoader() {
54 51
         $this->app->singleton('translation.loader', function ($app) {
55 52
             return new FileLoader($app['files'], $app['path.lang']);
56 53
         });
@@ -61,8 +58,7 @@  discard block
 block discarded – undo
61 58
      *
62 59
      * @return array
63 60
      */
64
-    public function provides()
65
-    {
61
+    public function provides() {
66 62
         return ['translator', 'translation.loader'];
67 63
     }
68 64
 }
Please login to merge, or discard this patch.
vendor_prefixed/illuminate/translation/Translator.php 3 patches
Indentation   +453 added lines, -453 removed lines patch added patch discarded remove patch
@@ -18,457 +18,457 @@
 block discarded – undo
18 18
 
19 19
 class Translator extends NamespacedItemResolver implements TranslatorContract
20 20
 {
21
-    use Macroable;
22
-
23
-    /**
24
-     * The loader implementation.
25
-     *
26
-     * @var \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Translation\LoaderInterface
27
-     */
28
-    protected $loader;
29
-
30
-    /**
31
-     * The default locale being used by the translator.
32
-     *
33
-     * @var string
34
-     */
35
-    protected $locale;
36
-
37
-    /**
38
-     * The fallback locale used by the translator.
39
-     *
40
-     * @var string
41
-     */
42
-    protected $fallback;
43
-
44
-    /**
45
-     * The array of loaded translation groups.
46
-     *
47
-     * @var array
48
-     */
49
-    protected $loaded = [];
50
-
51
-    /**
52
-     * The message selector.
53
-     *
54
-     * @var \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Translation\MessageSelector
55
-     */
56
-    protected $selector;
57
-
58
-    /**
59
-     * Create a new translator instance.
60
-     *
61
-     * @param  \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Translation\LoaderInterface  $loader
62
-     * @param  string  $locale
63
-     * @return void
64
-     */
65
-    public function __construct(LoaderInterface $loader, $locale)
66
-    {
67
-        $this->loader = $loader;
68
-        $this->locale = $locale;
69
-    }
70
-
71
-    /**
72
-     * Determine if a translation exists for a given locale.
73
-     *
74
-     * @param  string  $key
75
-     * @param  string|null  $locale
76
-     * @return bool
77
-     */
78
-    public function hasForLocale($key, $locale = null)
79
-    {
80
-        return $this->has($key, $locale, false);
81
-    }
82
-
83
-    /**
84
-     * Determine if a translation exists.
85
-     *
86
-     * @param  string  $key
87
-     * @param  string|null  $locale
88
-     * @param  bool  $fallback
89
-     * @return bool
90
-     */
91
-    public function has($key, $locale = null, $fallback = true)
92
-    {
93
-        return $this->get($key, [], $locale, $fallback) !== $key;
94
-    }
95
-
96
-    /**
97
-     * Get the translation for a given key.
98
-     *
99
-     * @param  string  $key
100
-     * @param  array   $replace
101
-     * @param  string  $locale
102
-     * @return string|array|null
103
-     */
104
-    public function trans($key, array $replace = [], $locale = null)
105
-    {
106
-        return $this->get($key, $replace, $locale);
107
-    }
108
-
109
-    /**
110
-     * Get the translation for the given key.
111
-     *
112
-     * @param  string  $key
113
-     * @param  array   $replace
114
-     * @param  string|null  $locale
115
-     * @param  bool  $fallback
116
-     * @return string|array|null
117
-     */
118
-    public function get($key, array $replace = [], $locale = null, $fallback = true)
119
-    {
120
-        list($namespace, $group, $item) = $this->parseKey($key);
121
-
122
-        // Here we will get the locale that should be used for the language line. If one
123
-        // was not passed, we will use the default locales which was given to us when
124
-        // the translator was instantiated. Then, we can load the lines and return.
125
-        $locales = $fallback ? $this->localeArray($locale)
126
-                             : [$locale ?: $this->locale];
127
-
128
-        foreach ($locales as $locale) {
129
-            if (! is_null($line = $this->getLine(
130
-                $namespace, $group, $locale, $item, $replace
131
-            ))) {
132
-                break;
133
-            }
134
-        }
135
-
136
-        // If the line doesn't exist, we will return back the key which was requested as
137
-        // that will be quick to spot in the UI if language keys are wrong or missing
138
-        // from the application's language files. Otherwise we can return the line.
139
-        if (isset($line)) {
140
-            return $line;
141
-        }
142
-
143
-        return $key;
144
-    }
145
-
146
-    /**
147
-     * Get the translation for a given key from the JSON translation files.
148
-     *
149
-     * @param  string  $key
150
-     * @param  array  $replace
151
-     * @param  string  $locale
152
-     * @return string
153
-     */
154
-    public function getFromJson($key, array $replace = [], $locale = null)
155
-    {
156
-        $locale = $locale ?: $this->locale;
157
-
158
-        // For JSON translations, there is only one file per locale, so we will simply load
159
-        // that file and then we will be ready to check the array for the key. These are
160
-        // only one level deep so we do not need to do any fancy searching through it.
161
-        $this->load('*', '*', $locale);
162
-
163
-        $line = isset($this->loaded['*']['*'][$locale][$key])
164
-                    ? $this->loaded['*']['*'][$locale][$key] : null;
165
-
166
-        // If we can't find a translation for the JSON key, we will attempt to translate it
167
-        // using the typical translation file. This way developers can always just use a
168
-        // helper such as __ instead of having to pick between trans or __ with views.
169
-        if (! isset($line)) {
170
-            $fallback = $this->get($key, $replace, $locale);
171
-
172
-            if ($fallback !== $key) {
173
-                return $fallback;
174
-            }
175
-        }
176
-
177
-        return $this->makeReplacements($line ?: $key, $replace);
178
-    }
179
-
180
-    /**
181
-     * Get a translation according to an integer value.
182
-     *
183
-     * @param  string  $key
184
-     * @param  int|array|\Countable  $number
185
-     * @param  array   $replace
186
-     * @param  string  $locale
187
-     * @return string
188
-     */
189
-    public function transChoice($key, $number, array $replace = [], $locale = null)
190
-    {
191
-        return $this->choice($key, $number, $replace, $locale);
192
-    }
193
-
194
-    /**
195
-     * Get a translation according to an integer value.
196
-     *
197
-     * @param  string  $key
198
-     * @param  int|array|\Countable  $number
199
-     * @param  array   $replace
200
-     * @param  string  $locale
201
-     * @return string
202
-     */
203
-    public function choice($key, $number, array $replace = [], $locale = null)
204
-    {
205
-        $line = $this->get(
206
-            $key, $replace, $locale = $this->localeForChoice($locale)
207
-        );
208
-
209
-        // If the given "number" is actually an array or countable we will simply count the
210
-        // number of elements in an instance. This allows developers to pass an array of
211
-        // items without having to count it on their end first which gives bad syntax.
212
-        if (is_array($number) || $number instanceof Countable) {
213
-            $number = count($number);
214
-        }
215
-
216
-        $replace['count'] = $number;
217
-
218
-        return $this->makeReplacements(
219
-            $this->getSelector()->choose($line, $number, $locale), $replace
220
-        );
221
-    }
222
-
223
-    /**
224
-     * Get the proper locale for a choice operation.
225
-     *
226
-     * @param  string|null  $locale
227
-     * @return string
228
-     */
229
-    protected function localeForChoice($locale)
230
-    {
231
-        return $locale ?: $this->locale ?: $this->fallback;
232
-    }
233
-
234
-    /**
235
-     * Retrieve a language line out the loaded array.
236
-     *
237
-     * @param  string  $namespace
238
-     * @param  string  $group
239
-     * @param  string  $locale
240
-     * @param  string  $item
241
-     * @param  array   $replace
242
-     * @return string|array|null
243
-     */
244
-    protected function getLine($namespace, $group, $locale, $item, array $replace)
245
-    {
246
-        $this->load($namespace, $group, $locale);
247
-
248
-        $line = Arr::get($this->loaded[$namespace][$group][$locale], $item);
249
-
250
-        if (is_string($line)) {
251
-            return $this->makeReplacements($line, $replace);
252
-        } elseif (is_array($line) && count($line) > 0) {
253
-            return $line;
254
-        }
255
-    }
256
-
257
-    /**
258
-     * Make the place-holder replacements on a line.
259
-     *
260
-     * @param  string  $line
261
-     * @param  array   $replace
262
-     * @return string
263
-     */
264
-    protected function makeReplacements($line, array $replace)
265
-    {
266
-        if (empty($replace)) {
267
-            return $line;
268
-        }
269
-
270
-        $replace = $this->sortReplacements($replace);
271
-
272
-        foreach ($replace as $key => $value) {
273
-            $line = str_replace(
274
-                [':'.$key, ':'.Str::upper($key), ':'.Str::ucfirst($key)],
275
-                [$value, Str::upper($value), Str::ucfirst($value)],
276
-                $line
277
-            );
278
-        }
279
-
280
-        return $line;
281
-    }
282
-
283
-    /**
284
-     * Sort the replacements array.
285
-     *
286
-     * @param  array  $replace
287
-     * @return array
288
-     */
289
-    protected function sortReplacements(array $replace)
290
-    {
291
-        return (new Collection($replace))->sortBy(function ($value, $key) {
292
-            return mb_strlen($key) * -1;
293
-        })->all();
294
-    }
295
-
296
-    /**
297
-     * Add translation lines to the given locale.
298
-     *
299
-     * @param  array  $lines
300
-     * @param  string  $locale
301
-     * @param  string  $namespace
302
-     * @return void
303
-     */
304
-    public function addLines(array $lines, $locale, $namespace = '*')
305
-    {
306
-        foreach ($lines as $key => $value) {
307
-            list($group, $item) = explode('.', $key, 2);
308
-
309
-            Arr::set($this->loaded, "$namespace.$group.$locale.$item", $value);
310
-        }
311
-    }
312
-
313
-    /**
314
-     * Load the specified language group.
315
-     *
316
-     * @param  string  $namespace
317
-     * @param  string  $group
318
-     * @param  string  $locale
319
-     * @return void
320
-     */
321
-    public function load($namespace, $group, $locale)
322
-    {
323
-        if ($this->isLoaded($namespace, $group, $locale)) {
324
-            return;
325
-        }
326
-
327
-        // The loader is responsible for returning the array of language lines for the
328
-        // given namespace, group, and locale. We'll set the lines in this array of
329
-        // lines that have already been loaded so that we can easily access them.
330
-        $lines = $this->loader->load($locale, $group, $namespace);
331
-
332
-        $this->loaded[$namespace][$group][$locale] = $lines;
333
-    }
334
-
335
-    /**
336
-     * Determine if the given group has been loaded.
337
-     *
338
-     * @param  string  $namespace
339
-     * @param  string  $group
340
-     * @param  string  $locale
341
-     * @return bool
342
-     */
343
-    protected function isLoaded($namespace, $group, $locale)
344
-    {
345
-        return isset($this->loaded[$namespace][$group][$locale]);
346
-    }
347
-
348
-    /**
349
-     * Add a new namespace to the loader.
350
-     *
351
-     * @param  string  $namespace
352
-     * @param  string  $hint
353
-     * @return void
354
-     */
355
-    public function addNamespace($namespace, $hint)
356
-    {
357
-        $this->loader->addNamespace($namespace, $hint);
358
-    }
359
-
360
-    /**
361
-     * Parse a key into namespace, group, and item.
362
-     *
363
-     * @param  string  $key
364
-     * @return array
365
-     */
366
-    public function parseKey($key)
367
-    {
368
-        $segments = parent::parseKey($key);
369
-
370
-        if (is_null($segments[0])) {
371
-            $segments[0] = '*';
372
-        }
373
-
374
-        return $segments;
375
-    }
376
-
377
-    /**
378
-     * Get the array of locales to be checked.
379
-     *
380
-     * @param  string|null  $locale
381
-     * @return array
382
-     */
383
-    protected function localeArray($locale)
384
-    {
385
-        return array_filter([$locale ?: $this->locale, $this->fallback]);
386
-    }
387
-
388
-    /**
389
-     * Get the message selector instance.
390
-     *
391
-     * @return \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Translation\MessageSelector
392
-     */
393
-    public function getSelector()
394
-    {
395
-        if (! isset($this->selector)) {
396
-            $this->selector = new MessageSelector;
397
-        }
398
-
399
-        return $this->selector;
400
-    }
401
-
402
-    /**
403
-     * Set the message selector instance.
404
-     *
405
-     * @param  \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Translation\MessageSelector  $selector
406
-     * @return void
407
-     */
408
-    public function setSelector(MessageSelector $selector)
409
-    {
410
-        $this->selector = $selector;
411
-    }
412
-
413
-    /**
414
-     * Get the language line loader implementation.
415
-     *
416
-     * @return \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Translation\LoaderInterface
417
-     */
418
-    public function getLoader()
419
-    {
420
-        return $this->loader;
421
-    }
422
-
423
-    /**
424
-     * Get the default locale being used.
425
-     *
426
-     * @return string
427
-     */
428
-    public function locale()
429
-    {
430
-        return $this->getLocale();
431
-    }
432
-
433
-    /**
434
-     * Get the default locale being used.
435
-     *
436
-     * @return string
437
-     */
438
-    public function getLocale()
439
-    {
440
-        return $this->locale;
441
-    }
442
-
443
-    /**
444
-     * Set the default locale.
445
-     *
446
-     * @param  string  $locale
447
-     * @return void
448
-     */
449
-    public function setLocale($locale)
450
-    {
451
-        $this->locale = $locale;
452
-    }
453
-
454
-    /**
455
-     * Get the fallback locale being used.
456
-     *
457
-     * @return string
458
-     */
459
-    public function getFallback()
460
-    {
461
-        return $this->fallback;
462
-    }
463
-
464
-    /**
465
-     * Set the fallback locale being used.
466
-     *
467
-     * @param  string  $fallback
468
-     * @return void
469
-     */
470
-    public function setFallback($fallback)
471
-    {
472
-        $this->fallback = $fallback;
473
-    }
21
+	use Macroable;
22
+
23
+	/**
24
+	 * The loader implementation.
25
+	 *
26
+	 * @var \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Translation\LoaderInterface
27
+	 */
28
+	protected $loader;
29
+
30
+	/**
31
+	 * The default locale being used by the translator.
32
+	 *
33
+	 * @var string
34
+	 */
35
+	protected $locale;
36
+
37
+	/**
38
+	 * The fallback locale used by the translator.
39
+	 *
40
+	 * @var string
41
+	 */
42
+	protected $fallback;
43
+
44
+	/**
45
+	 * The array of loaded translation groups.
46
+	 *
47
+	 * @var array
48
+	 */
49
+	protected $loaded = [];
50
+
51
+	/**
52
+	 * The message selector.
53
+	 *
54
+	 * @var \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Translation\MessageSelector
55
+	 */
56
+	protected $selector;
57
+
58
+	/**
59
+	 * Create a new translator instance.
60
+	 *
61
+	 * @param  \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Translation\LoaderInterface  $loader
62
+	 * @param  string  $locale
63
+	 * @return void
64
+	 */
65
+	public function __construct(LoaderInterface $loader, $locale)
66
+	{
67
+		$this->loader = $loader;
68
+		$this->locale = $locale;
69
+	}
70
+
71
+	/**
72
+	 * Determine if a translation exists for a given locale.
73
+	 *
74
+	 * @param  string  $key
75
+	 * @param  string|null  $locale
76
+	 * @return bool
77
+	 */
78
+	public function hasForLocale($key, $locale = null)
79
+	{
80
+		return $this->has($key, $locale, false);
81
+	}
82
+
83
+	/**
84
+	 * Determine if a translation exists.
85
+	 *
86
+	 * @param  string  $key
87
+	 * @param  string|null  $locale
88
+	 * @param  bool  $fallback
89
+	 * @return bool
90
+	 */
91
+	public function has($key, $locale = null, $fallback = true)
92
+	{
93
+		return $this->get($key, [], $locale, $fallback) !== $key;
94
+	}
95
+
96
+	/**
97
+	 * Get the translation for a given key.
98
+	 *
99
+	 * @param  string  $key
100
+	 * @param  array   $replace
101
+	 * @param  string  $locale
102
+	 * @return string|array|null
103
+	 */
104
+	public function trans($key, array $replace = [], $locale = null)
105
+	{
106
+		return $this->get($key, $replace, $locale);
107
+	}
108
+
109
+	/**
110
+	 * Get the translation for the given key.
111
+	 *
112
+	 * @param  string  $key
113
+	 * @param  array   $replace
114
+	 * @param  string|null  $locale
115
+	 * @param  bool  $fallback
116
+	 * @return string|array|null
117
+	 */
118
+	public function get($key, array $replace = [], $locale = null, $fallback = true)
119
+	{
120
+		list($namespace, $group, $item) = $this->parseKey($key);
121
+
122
+		// Here we will get the locale that should be used for the language line. If one
123
+		// was not passed, we will use the default locales which was given to us when
124
+		// the translator was instantiated. Then, we can load the lines and return.
125
+		$locales = $fallback ? $this->localeArray($locale)
126
+							 : [$locale ?: $this->locale];
127
+
128
+		foreach ($locales as $locale) {
129
+			if (! is_null($line = $this->getLine(
130
+				$namespace, $group, $locale, $item, $replace
131
+			))) {
132
+				break;
133
+			}
134
+		}
135
+
136
+		// If the line doesn't exist, we will return back the key which was requested as
137
+		// that will be quick to spot in the UI if language keys are wrong or missing
138
+		// from the application's language files. Otherwise we can return the line.
139
+		if (isset($line)) {
140
+			return $line;
141
+		}
142
+
143
+		return $key;
144
+	}
145
+
146
+	/**
147
+	 * Get the translation for a given key from the JSON translation files.
148
+	 *
149
+	 * @param  string  $key
150
+	 * @param  array  $replace
151
+	 * @param  string  $locale
152
+	 * @return string
153
+	 */
154
+	public function getFromJson($key, array $replace = [], $locale = null)
155
+	{
156
+		$locale = $locale ?: $this->locale;
157
+
158
+		// For JSON translations, there is only one file per locale, so we will simply load
159
+		// that file and then we will be ready to check the array for the key. These are
160
+		// only one level deep so we do not need to do any fancy searching through it.
161
+		$this->load('*', '*', $locale);
162
+
163
+		$line = isset($this->loaded['*']['*'][$locale][$key])
164
+					? $this->loaded['*']['*'][$locale][$key] : null;
165
+
166
+		// If we can't find a translation for the JSON key, we will attempt to translate it
167
+		// using the typical translation file. This way developers can always just use a
168
+		// helper such as __ instead of having to pick between trans or __ with views.
169
+		if (! isset($line)) {
170
+			$fallback = $this->get($key, $replace, $locale);
171
+
172
+			if ($fallback !== $key) {
173
+				return $fallback;
174
+			}
175
+		}
176
+
177
+		return $this->makeReplacements($line ?: $key, $replace);
178
+	}
179
+
180
+	/**
181
+	 * Get a translation according to an integer value.
182
+	 *
183
+	 * @param  string  $key
184
+	 * @param  int|array|\Countable  $number
185
+	 * @param  array   $replace
186
+	 * @param  string  $locale
187
+	 * @return string
188
+	 */
189
+	public function transChoice($key, $number, array $replace = [], $locale = null)
190
+	{
191
+		return $this->choice($key, $number, $replace, $locale);
192
+	}
193
+
194
+	/**
195
+	 * Get a translation according to an integer value.
196
+	 *
197
+	 * @param  string  $key
198
+	 * @param  int|array|\Countable  $number
199
+	 * @param  array   $replace
200
+	 * @param  string  $locale
201
+	 * @return string
202
+	 */
203
+	public function choice($key, $number, array $replace = [], $locale = null)
204
+	{
205
+		$line = $this->get(
206
+			$key, $replace, $locale = $this->localeForChoice($locale)
207
+		);
208
+
209
+		// If the given "number" is actually an array or countable we will simply count the
210
+		// number of elements in an instance. This allows developers to pass an array of
211
+		// items without having to count it on their end first which gives bad syntax.
212
+		if (is_array($number) || $number instanceof Countable) {
213
+			$number = count($number);
214
+		}
215
+
216
+		$replace['count'] = $number;
217
+
218
+		return $this->makeReplacements(
219
+			$this->getSelector()->choose($line, $number, $locale), $replace
220
+		);
221
+	}
222
+
223
+	/**
224
+	 * Get the proper locale for a choice operation.
225
+	 *
226
+	 * @param  string|null  $locale
227
+	 * @return string
228
+	 */
229
+	protected function localeForChoice($locale)
230
+	{
231
+		return $locale ?: $this->locale ?: $this->fallback;
232
+	}
233
+
234
+	/**
235
+	 * Retrieve a language line out the loaded array.
236
+	 *
237
+	 * @param  string  $namespace
238
+	 * @param  string  $group
239
+	 * @param  string  $locale
240
+	 * @param  string  $item
241
+	 * @param  array   $replace
242
+	 * @return string|array|null
243
+	 */
244
+	protected function getLine($namespace, $group, $locale, $item, array $replace)
245
+	{
246
+		$this->load($namespace, $group, $locale);
247
+
248
+		$line = Arr::get($this->loaded[$namespace][$group][$locale], $item);
249
+
250
+		if (is_string($line)) {
251
+			return $this->makeReplacements($line, $replace);
252
+		} elseif (is_array($line) && count($line) > 0) {
253
+			return $line;
254
+		}
255
+	}
256
+
257
+	/**
258
+	 * Make the place-holder replacements on a line.
259
+	 *
260
+	 * @param  string  $line
261
+	 * @param  array   $replace
262
+	 * @return string
263
+	 */
264
+	protected function makeReplacements($line, array $replace)
265
+	{
266
+		if (empty($replace)) {
267
+			return $line;
268
+		}
269
+
270
+		$replace = $this->sortReplacements($replace);
271
+
272
+		foreach ($replace as $key => $value) {
273
+			$line = str_replace(
274
+				[':'.$key, ':'.Str::upper($key), ':'.Str::ucfirst($key)],
275
+				[$value, Str::upper($value), Str::ucfirst($value)],
276
+				$line
277
+			);
278
+		}
279
+
280
+		return $line;
281
+	}
282
+
283
+	/**
284
+	 * Sort the replacements array.
285
+	 *
286
+	 * @param  array  $replace
287
+	 * @return array
288
+	 */
289
+	protected function sortReplacements(array $replace)
290
+	{
291
+		return (new Collection($replace))->sortBy(function ($value, $key) {
292
+			return mb_strlen($key) * -1;
293
+		})->all();
294
+	}
295
+
296
+	/**
297
+	 * Add translation lines to the given locale.
298
+	 *
299
+	 * @param  array  $lines
300
+	 * @param  string  $locale
301
+	 * @param  string  $namespace
302
+	 * @return void
303
+	 */
304
+	public function addLines(array $lines, $locale, $namespace = '*')
305
+	{
306
+		foreach ($lines as $key => $value) {
307
+			list($group, $item) = explode('.', $key, 2);
308
+
309
+			Arr::set($this->loaded, "$namespace.$group.$locale.$item", $value);
310
+		}
311
+	}
312
+
313
+	/**
314
+	 * Load the specified language group.
315
+	 *
316
+	 * @param  string  $namespace
317
+	 * @param  string  $group
318
+	 * @param  string  $locale
319
+	 * @return void
320
+	 */
321
+	public function load($namespace, $group, $locale)
322
+	{
323
+		if ($this->isLoaded($namespace, $group, $locale)) {
324
+			return;
325
+		}
326
+
327
+		// The loader is responsible for returning the array of language lines for the
328
+		// given namespace, group, and locale. We'll set the lines in this array of
329
+		// lines that have already been loaded so that we can easily access them.
330
+		$lines = $this->loader->load($locale, $group, $namespace);
331
+
332
+		$this->loaded[$namespace][$group][$locale] = $lines;
333
+	}
334
+
335
+	/**
336
+	 * Determine if the given group has been loaded.
337
+	 *
338
+	 * @param  string  $namespace
339
+	 * @param  string  $group
340
+	 * @param  string  $locale
341
+	 * @return bool
342
+	 */
343
+	protected function isLoaded($namespace, $group, $locale)
344
+	{
345
+		return isset($this->loaded[$namespace][$group][$locale]);
346
+	}
347
+
348
+	/**
349
+	 * Add a new namespace to the loader.
350
+	 *
351
+	 * @param  string  $namespace
352
+	 * @param  string  $hint
353
+	 * @return void
354
+	 */
355
+	public function addNamespace($namespace, $hint)
356
+	{
357
+		$this->loader->addNamespace($namespace, $hint);
358
+	}
359
+
360
+	/**
361
+	 * Parse a key into namespace, group, and item.
362
+	 *
363
+	 * @param  string  $key
364
+	 * @return array
365
+	 */
366
+	public function parseKey($key)
367
+	{
368
+		$segments = parent::parseKey($key);
369
+
370
+		if (is_null($segments[0])) {
371
+			$segments[0] = '*';
372
+		}
373
+
374
+		return $segments;
375
+	}
376
+
377
+	/**
378
+	 * Get the array of locales to be checked.
379
+	 *
380
+	 * @param  string|null  $locale
381
+	 * @return array
382
+	 */
383
+	protected function localeArray($locale)
384
+	{
385
+		return array_filter([$locale ?: $this->locale, $this->fallback]);
386
+	}
387
+
388
+	/**
389
+	 * Get the message selector instance.
390
+	 *
391
+	 * @return \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Translation\MessageSelector
392
+	 */
393
+	public function getSelector()
394
+	{
395
+		if (! isset($this->selector)) {
396
+			$this->selector = new MessageSelector;
397
+		}
398
+
399
+		return $this->selector;
400
+	}
401
+
402
+	/**
403
+	 * Set the message selector instance.
404
+	 *
405
+	 * @param  \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Translation\MessageSelector  $selector
406
+	 * @return void
407
+	 */
408
+	public function setSelector(MessageSelector $selector)
409
+	{
410
+		$this->selector = $selector;
411
+	}
412
+
413
+	/**
414
+	 * Get the language line loader implementation.
415
+	 *
416
+	 * @return \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Translation\LoaderInterface
417
+	 */
418
+	public function getLoader()
419
+	{
420
+		return $this->loader;
421
+	}
422
+
423
+	/**
424
+	 * Get the default locale being used.
425
+	 *
426
+	 * @return string
427
+	 */
428
+	public function locale()
429
+	{
430
+		return $this->getLocale();
431
+	}
432
+
433
+	/**
434
+	 * Get the default locale being used.
435
+	 *
436
+	 * @return string
437
+	 */
438
+	public function getLocale()
439
+	{
440
+		return $this->locale;
441
+	}
442
+
443
+	/**
444
+	 * Set the default locale.
445
+	 *
446
+	 * @param  string  $locale
447
+	 * @return void
448
+	 */
449
+	public function setLocale($locale)
450
+	{
451
+		$this->locale = $locale;
452
+	}
453
+
454
+	/**
455
+	 * Get the fallback locale being used.
456
+	 *
457
+	 * @return string
458
+	 */
459
+	public function getFallback()
460
+	{
461
+		return $this->fallback;
462
+	}
463
+
464
+	/**
465
+	 * Set the fallback locale being used.
466
+	 *
467
+	 * @param  string  $fallback
468
+	 * @return void
469
+	 */
470
+	public function setFallback($fallback)
471
+	{
472
+		$this->fallback = $fallback;
473
+	}
474 474
 }
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      *
47 47
      * @var array
48 48
      */
49
-    protected $loaded = [];
49
+    protected $loaded = [ ];
50 50
 
51 51
     /**
52 52
      * The message selector.
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
      * @param  string  $locale
63 63
      * @return void
64 64
      */
65
-    public function __construct(LoaderInterface $loader, $locale)
65
+    public function __construct( LoaderInterface $loader, $locale )
66 66
     {
67 67
         $this->loader = $loader;
68 68
         $this->locale = $locale;
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
      * @param  string|null  $locale
76 76
      * @return bool
77 77
      */
78
-    public function hasForLocale($key, $locale = null)
78
+    public function hasForLocale( $key, $locale = null )
79 79
     {
80
-        return $this->has($key, $locale, false);
80
+        return $this->has( $key, $locale, false );
81 81
     }
82 82
 
83 83
     /**
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
      * @param  bool  $fallback
89 89
      * @return bool
90 90
      */
91
-    public function has($key, $locale = null, $fallback = true)
91
+    public function has( $key, $locale = null, $fallback = true )
92 92
     {
93
-        return $this->get($key, [], $locale, $fallback) !== $key;
93
+        return $this->get( $key, [ ], $locale, $fallback ) !== $key;
94 94
     }
95 95
 
96 96
     /**
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
      * @param  string  $locale
102 102
      * @return string|array|null
103 103
      */
104
-    public function trans($key, array $replace = [], $locale = null)
104
+    public function trans( $key, array $replace = [ ], $locale = null )
105 105
     {
106
-        return $this->get($key, $replace, $locale);
106
+        return $this->get( $key, $replace, $locale );
107 107
     }
108 108
 
109 109
     /**
@@ -115,20 +115,20 @@  discard block
 block discarded – undo
115 115
      * @param  bool  $fallback
116 116
      * @return string|array|null
117 117
      */
118
-    public function get($key, array $replace = [], $locale = null, $fallback = true)
118
+    public function get( $key, array $replace = [ ], $locale = null, $fallback = true )
119 119
     {
120
-        list($namespace, $group, $item) = $this->parseKey($key);
120
+        list( $namespace, $group, $item ) = $this->parseKey( $key );
121 121
 
122 122
         // Here we will get the locale that should be used for the language line. If one
123 123
         // was not passed, we will use the default locales which was given to us when
124 124
         // the translator was instantiated. Then, we can load the lines and return.
125
-        $locales = $fallback ? $this->localeArray($locale)
126
-                             : [$locale ?: $this->locale];
125
+        $locales = $fallback ? $this->localeArray( $locale )
126
+                             : [ $locale ?: $this->locale ];
127 127
 
128
-        foreach ($locales as $locale) {
129
-            if (! is_null($line = $this->getLine(
128
+        foreach ( $locales as $locale ) {
129
+            if ( ! is_null( $line = $this->getLine(
130 130
                 $namespace, $group, $locale, $item, $replace
131
-            ))) {
131
+            ) ) ) {
132 132
                 break;
133 133
             }
134 134
         }
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
         // If the line doesn't exist, we will return back the key which was requested as
137 137
         // that will be quick to spot in the UI if language keys are wrong or missing
138 138
         // from the application's language files. Otherwise we can return the line.
139
-        if (isset($line)) {
139
+        if ( isset( $line ) ) {
140 140
             return $line;
141 141
         }
142 142
 
@@ -151,30 +151,30 @@  discard block
 block discarded – undo
151 151
      * @param  string  $locale
152 152
      * @return string
153 153
      */
154
-    public function getFromJson($key, array $replace = [], $locale = null)
154
+    public function getFromJson( $key, array $replace = [ ], $locale = null )
155 155
     {
156 156
         $locale = $locale ?: $this->locale;
157 157
 
158 158
         // For JSON translations, there is only one file per locale, so we will simply load
159 159
         // that file and then we will be ready to check the array for the key. These are
160 160
         // only one level deep so we do not need to do any fancy searching through it.
161
-        $this->load('*', '*', $locale);
161
+        $this->load( '*', '*', $locale );
162 162
 
163
-        $line = isset($this->loaded['*']['*'][$locale][$key])
164
-                    ? $this->loaded['*']['*'][$locale][$key] : null;
163
+        $line = isset( $this->loaded[ '*' ][ '*' ][ $locale ][ $key ] )
164
+                    ? $this->loaded[ '*' ][ '*' ][ $locale ][ $key ] : null;
165 165
 
166 166
         // If we can't find a translation for the JSON key, we will attempt to translate it
167 167
         // using the typical translation file. This way developers can always just use a
168 168
         // helper such as __ instead of having to pick between trans or __ with views.
169
-        if (! isset($line)) {
170
-            $fallback = $this->get($key, $replace, $locale);
169
+        if ( ! isset( $line ) ) {
170
+            $fallback = $this->get( $key, $replace, $locale );
171 171
 
172
-            if ($fallback !== $key) {
172
+            if ( $fallback !== $key ) {
173 173
                 return $fallback;
174 174
             }
175 175
         }
176 176
 
177
-        return $this->makeReplacements($line ?: $key, $replace);
177
+        return $this->makeReplacements( $line ?: $key, $replace );
178 178
     }
179 179
 
180 180
     /**
@@ -186,9 +186,9 @@  discard block
 block discarded – undo
186 186
      * @param  string  $locale
187 187
      * @return string
188 188
      */
189
-    public function transChoice($key, $number, array $replace = [], $locale = null)
189
+    public function transChoice( $key, $number, array $replace = [ ], $locale = null )
190 190
     {
191
-        return $this->choice($key, $number, $replace, $locale);
191
+        return $this->choice( $key, $number, $replace, $locale );
192 192
     }
193 193
 
194 194
     /**
@@ -200,23 +200,23 @@  discard block
 block discarded – undo
200 200
      * @param  string  $locale
201 201
      * @return string
202 202
      */
203
-    public function choice($key, $number, array $replace = [], $locale = null)
203
+    public function choice( $key, $number, array $replace = [ ], $locale = null )
204 204
     {
205 205
         $line = $this->get(
206
-            $key, $replace, $locale = $this->localeForChoice($locale)
206
+            $key, $replace, $locale = $this->localeForChoice( $locale )
207 207
         );
208 208
 
209 209
         // If the given "number" is actually an array or countable we will simply count the
210 210
         // number of elements in an instance. This allows developers to pass an array of
211 211
         // items without having to count it on their end first which gives bad syntax.
212
-        if (is_array($number) || $number instanceof Countable) {
213
-            $number = count($number);
212
+        if ( is_array( $number ) || $number instanceof Countable ) {
213
+            $number = count( $number );
214 214
         }
215 215
 
216
-        $replace['count'] = $number;
216
+        $replace[ 'count' ] = $number;
217 217
 
218 218
         return $this->makeReplacements(
219
-            $this->getSelector()->choose($line, $number, $locale), $replace
219
+            $this->getSelector()->choose( $line, $number, $locale ), $replace
220 220
         );
221 221
     }
222 222
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
      * @param  string|null  $locale
227 227
      * @return string
228 228
      */
229
-    protected function localeForChoice($locale)
229
+    protected function localeForChoice( $locale )
230 230
     {
231 231
         return $locale ?: $this->locale ?: $this->fallback;
232 232
     }
@@ -241,15 +241,15 @@  discard block
 block discarded – undo
241 241
      * @param  array   $replace
242 242
      * @return string|array|null
243 243
      */
244
-    protected function getLine($namespace, $group, $locale, $item, array $replace)
244
+    protected function getLine( $namespace, $group, $locale, $item, array $replace )
245 245
     {
246
-        $this->load($namespace, $group, $locale);
246
+        $this->load( $namespace, $group, $locale );
247 247
 
248
-        $line = Arr::get($this->loaded[$namespace][$group][$locale], $item);
248
+        $line = Arr::get( $this->loaded[ $namespace ][ $group ][ $locale ], $item );
249 249
 
250
-        if (is_string($line)) {
251
-            return $this->makeReplacements($line, $replace);
252
-        } elseif (is_array($line) && count($line) > 0) {
250
+        if ( is_string( $line ) ) {
251
+            return $this->makeReplacements( $line, $replace );
252
+        } elseif ( is_array( $line ) && count( $line ) > 0 ) {
253 253
             return $line;
254 254
         }
255 255
     }
@@ -261,18 +261,18 @@  discard block
 block discarded – undo
261 261
      * @param  array   $replace
262 262
      * @return string
263 263
      */
264
-    protected function makeReplacements($line, array $replace)
264
+    protected function makeReplacements( $line, array $replace )
265 265
     {
266
-        if (empty($replace)) {
266
+        if ( empty( $replace ) ) {
267 267
             return $line;
268 268
         }
269 269
 
270
-        $replace = $this->sortReplacements($replace);
270
+        $replace = $this->sortReplacements( $replace );
271 271
 
272
-        foreach ($replace as $key => $value) {
272
+        foreach ( $replace as $key => $value ) {
273 273
             $line = str_replace(
274
-                [':'.$key, ':'.Str::upper($key), ':'.Str::ucfirst($key)],
275
-                [$value, Str::upper($value), Str::ucfirst($value)],
274
+                [ ':' . $key, ':' . Str::upper( $key ), ':' . Str::ucfirst( $key ) ],
275
+                [ $value, Str::upper( $value ), Str::ucfirst( $value ) ],
276 276
                 $line
277 277
             );
278 278
         }
@@ -286,10 +286,10 @@  discard block
 block discarded – undo
286 286
      * @param  array  $replace
287 287
      * @return array
288 288
      */
289
-    protected function sortReplacements(array $replace)
289
+    protected function sortReplacements( array $replace )
290 290
     {
291
-        return (new Collection($replace))->sortBy(function ($value, $key) {
292
-            return mb_strlen($key) * -1;
291
+        return ( new Collection( $replace ) )->sortBy( function( $value, $key ) {
292
+            return mb_strlen( $key ) * -1;
293 293
         })->all();
294 294
     }
295 295
 
@@ -301,12 +301,12 @@  discard block
 block discarded – undo
301 301
      * @param  string  $namespace
302 302
      * @return void
303 303
      */
304
-    public function addLines(array $lines, $locale, $namespace = '*')
304
+    public function addLines( array $lines, $locale, $namespace = '*' )
305 305
     {
306
-        foreach ($lines as $key => $value) {
307
-            list($group, $item) = explode('.', $key, 2);
306
+        foreach ( $lines as $key => $value ) {
307
+            list( $group, $item ) = explode( '.', $key, 2 );
308 308
 
309
-            Arr::set($this->loaded, "$namespace.$group.$locale.$item", $value);
309
+            Arr::set( $this->loaded, "$namespace.$group.$locale.$item", $value );
310 310
         }
311 311
     }
312 312
 
@@ -318,18 +318,18 @@  discard block
 block discarded – undo
318 318
      * @param  string  $locale
319 319
      * @return void
320 320
      */
321
-    public function load($namespace, $group, $locale)
321
+    public function load( $namespace, $group, $locale )
322 322
     {
323
-        if ($this->isLoaded($namespace, $group, $locale)) {
323
+        if ( $this->isLoaded( $namespace, $group, $locale ) ) {
324 324
             return;
325 325
         }
326 326
 
327 327
         // The loader is responsible for returning the array of language lines for the
328 328
         // given namespace, group, and locale. We'll set the lines in this array of
329 329
         // lines that have already been loaded so that we can easily access them.
330
-        $lines = $this->loader->load($locale, $group, $namespace);
330
+        $lines = $this->loader->load( $locale, $group, $namespace );
331 331
 
332
-        $this->loaded[$namespace][$group][$locale] = $lines;
332
+        $this->loaded[ $namespace ][ $group ][ $locale ] = $lines;
333 333
     }
334 334
 
335 335
     /**
@@ -340,9 +340,9 @@  discard block
 block discarded – undo
340 340
      * @param  string  $locale
341 341
      * @return bool
342 342
      */
343
-    protected function isLoaded($namespace, $group, $locale)
343
+    protected function isLoaded( $namespace, $group, $locale )
344 344
     {
345
-        return isset($this->loaded[$namespace][$group][$locale]);
345
+        return isset( $this->loaded[ $namespace ][ $group ][ $locale ] );
346 346
     }
347 347
 
348 348
     /**
@@ -352,9 +352,9 @@  discard block
 block discarded – undo
352 352
      * @param  string  $hint
353 353
      * @return void
354 354
      */
355
-    public function addNamespace($namespace, $hint)
355
+    public function addNamespace( $namespace, $hint )
356 356
     {
357
-        $this->loader->addNamespace($namespace, $hint);
357
+        $this->loader->addNamespace( $namespace, $hint );
358 358
     }
359 359
 
360 360
     /**
@@ -363,12 +363,12 @@  discard block
 block discarded – undo
363 363
      * @param  string  $key
364 364
      * @return array
365 365
      */
366
-    public function parseKey($key)
366
+    public function parseKey( $key )
367 367
     {
368
-        $segments = parent::parseKey($key);
368
+        $segments = parent::parseKey( $key );
369 369
 
370
-        if (is_null($segments[0])) {
371
-            $segments[0] = '*';
370
+        if ( is_null( $segments[ 0 ] ) ) {
371
+            $segments[ 0 ] = '*';
372 372
         }
373 373
 
374 374
         return $segments;
@@ -380,9 +380,9 @@  discard block
 block discarded – undo
380 380
      * @param  string|null  $locale
381 381
      * @return array
382 382
      */
383
-    protected function localeArray($locale)
383
+    protected function localeArray( $locale )
384 384
     {
385
-        return array_filter([$locale ?: $this->locale, $this->fallback]);
385
+        return array_filter( [ $locale ?: $this->locale, $this->fallback ] );
386 386
     }
387 387
 
388 388
     /**
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
      */
393 393
     public function getSelector()
394 394
     {
395
-        if (! isset($this->selector)) {
395
+        if ( ! isset( $this->selector ) ) {
396 396
             $this->selector = new MessageSelector;
397 397
         }
398 398
 
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
      * @param  \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Translation\MessageSelector  $selector
406 406
      * @return void
407 407
      */
408
-    public function setSelector(MessageSelector $selector)
408
+    public function setSelector( MessageSelector $selector )
409 409
     {
410 410
         $this->selector = $selector;
411 411
     }
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
      * @param  string  $locale
447 447
      * @return void
448 448
      */
449
-    public function setLocale($locale)
449
+    public function setLocale( $locale )
450 450
     {
451 451
         $this->locale = $locale;
452 452
     }
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
      * @param  string  $fallback
468 468
      * @return void
469 469
      */
470
-    public function setFallback($fallback)
470
+    public function setFallback( $fallback )
471 471
     {
472 472
         $this->fallback = $fallback;
473 473
     }
Please login to merge, or discard this patch.
Braces   +27 added lines, -54 removed lines patch added patch discarded remove patch
@@ -16,8 +16,7 @@  discard block
 block discarded – undo
16 16
 use GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Support\NamespacedItemResolver;
17 17
 use GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Contracts\Translation\Translator as TranslatorContract;
18 18
 
19
-class Translator extends NamespacedItemResolver implements TranslatorContract
20
-{
19
+class Translator extends NamespacedItemResolver implements TranslatorContract {
21 20
     use Macroable;
22 21
 
23 22
     /**
@@ -62,8 +61,7 @@  discard block
 block discarded – undo
62 61
      * @param  string  $locale
63 62
      * @return void
64 63
      */
65
-    public function __construct(LoaderInterface $loader, $locale)
66
-    {
64
+    public function __construct(LoaderInterface $loader, $locale) {
67 65
         $this->loader = $loader;
68 66
         $this->locale = $locale;
69 67
     }
@@ -75,8 +73,7 @@  discard block
 block discarded – undo
75 73
      * @param  string|null  $locale
76 74
      * @return bool
77 75
      */
78
-    public function hasForLocale($key, $locale = null)
79
-    {
76
+    public function hasForLocale($key, $locale = null) {
80 77
         return $this->has($key, $locale, false);
81 78
     }
82 79
 
@@ -88,8 +85,7 @@  discard block
 block discarded – undo
88 85
      * @param  bool  $fallback
89 86
      * @return bool
90 87
      */
91
-    public function has($key, $locale = null, $fallback = true)
92
-    {
88
+    public function has($key, $locale = null, $fallback = true) {
93 89
         return $this->get($key, [], $locale, $fallback) !== $key;
94 90
     }
95 91
 
@@ -101,8 +97,7 @@  discard block
 block discarded – undo
101 97
      * @param  string  $locale
102 98
      * @return string|array|null
103 99
      */
104
-    public function trans($key, array $replace = [], $locale = null)
105
-    {
100
+    public function trans($key, array $replace = [], $locale = null) {
106 101
         return $this->get($key, $replace, $locale);
107 102
     }
108 103
 
@@ -115,8 +110,7 @@  discard block
 block discarded – undo
115 110
      * @param  bool  $fallback
116 111
      * @return string|array|null
117 112
      */
118
-    public function get($key, array $replace = [], $locale = null, $fallback = true)
119
-    {
113
+    public function get($key, array $replace = [], $locale = null, $fallback = true) {
120 114
         list($namespace, $group, $item) = $this->parseKey($key);
121 115
 
122 116
         // Here we will get the locale that should be used for the language line. If one
@@ -151,8 +145,7 @@  discard block
 block discarded – undo
151 145
      * @param  string  $locale
152 146
      * @return string
153 147
      */
154
-    public function getFromJson($key, array $replace = [], $locale = null)
155
-    {
148
+    public function getFromJson($key, array $replace = [], $locale = null) {
156 149
         $locale = $locale ?: $this->locale;
157 150
 
158 151
         // For JSON translations, there is only one file per locale, so we will simply load
@@ -186,8 +179,7 @@  discard block
 block discarded – undo
186 179
      * @param  string  $locale
187 180
      * @return string
188 181
      */
189
-    public function transChoice($key, $number, array $replace = [], $locale = null)
190
-    {
182
+    public function transChoice($key, $number, array $replace = [], $locale = null) {
191 183
         return $this->choice($key, $number, $replace, $locale);
192 184
     }
193 185
 
@@ -200,8 +192,7 @@  discard block
 block discarded – undo
200 192
      * @param  string  $locale
201 193
      * @return string
202 194
      */
203
-    public function choice($key, $number, array $replace = [], $locale = null)
204
-    {
195
+    public function choice($key, $number, array $replace = [], $locale = null) {
205 196
         $line = $this->get(
206 197
             $key, $replace, $locale = $this->localeForChoice($locale)
207 198
         );
@@ -226,8 +217,7 @@  discard block
 block discarded – undo
226 217
      * @param  string|null  $locale
227 218
      * @return string
228 219
      */
229
-    protected function localeForChoice($locale)
230
-    {
220
+    protected function localeForChoice($locale) {
231 221
         return $locale ?: $this->locale ?: $this->fallback;
232 222
     }
233 223
 
@@ -241,8 +231,7 @@  discard block
 block discarded – undo
241 231
      * @param  array   $replace
242 232
      * @return string|array|null
243 233
      */
244
-    protected function getLine($namespace, $group, $locale, $item, array $replace)
245
-    {
234
+    protected function getLine($namespace, $group, $locale, $item, array $replace) {
246 235
         $this->load($namespace, $group, $locale);
247 236
 
248 237
         $line = Arr::get($this->loaded[$namespace][$group][$locale], $item);
@@ -261,8 +250,7 @@  discard block
 block discarded – undo
261 250
      * @param  array   $replace
262 251
      * @return string
263 252
      */
264
-    protected function makeReplacements($line, array $replace)
265
-    {
253
+    protected function makeReplacements($line, array $replace) {
266 254
         if (empty($replace)) {
267 255
             return $line;
268 256
         }
@@ -286,8 +274,7 @@  discard block
 block discarded – undo
286 274
      * @param  array  $replace
287 275
      * @return array
288 276
      */
289
-    protected function sortReplacements(array $replace)
290
-    {
277
+    protected function sortReplacements(array $replace) {
291 278
         return (new Collection($replace))->sortBy(function ($value, $key) {
292 279
             return mb_strlen($key) * -1;
293 280
         })->all();
@@ -301,8 +288,7 @@  discard block
 block discarded – undo
301 288
      * @param  string  $namespace
302 289
      * @return void
303 290
      */
304
-    public function addLines(array $lines, $locale, $namespace = '*')
305
-    {
291
+    public function addLines(array $lines, $locale, $namespace = '*') {
306 292
         foreach ($lines as $key => $value) {
307 293
             list($group, $item) = explode('.', $key, 2);
308 294
 
@@ -318,8 +304,7 @@  discard block
 block discarded – undo
318 304
      * @param  string  $locale
319 305
      * @return void
320 306
      */
321
-    public function load($namespace, $group, $locale)
322
-    {
307
+    public function load($namespace, $group, $locale) {
323 308
         if ($this->isLoaded($namespace, $group, $locale)) {
324 309
             return;
325 310
         }
@@ -340,8 +325,7 @@  discard block
 block discarded – undo
340 325
      * @param  string  $locale
341 326
      * @return bool
342 327
      */
343
-    protected function isLoaded($namespace, $group, $locale)
344
-    {
328
+    protected function isLoaded($namespace, $group, $locale) {
345 329
         return isset($this->loaded[$namespace][$group][$locale]);
346 330
     }
347 331
 
@@ -352,8 +336,7 @@  discard block
 block discarded – undo
352 336
      * @param  string  $hint
353 337
      * @return void
354 338
      */
355
-    public function addNamespace($namespace, $hint)
356
-    {
339
+    public function addNamespace($namespace, $hint) {
357 340
         $this->loader->addNamespace($namespace, $hint);
358 341
     }
359 342
 
@@ -363,8 +346,7 @@  discard block
 block discarded – undo
363 346
      * @param  string  $key
364 347
      * @return array
365 348
      */
366
-    public function parseKey($key)
367
-    {
349
+    public function parseKey($key) {
368 350
         $segments = parent::parseKey($key);
369 351
 
370 352
         if (is_null($segments[0])) {
@@ -380,8 +362,7 @@  discard block
 block discarded – undo
380 362
      * @param  string|null  $locale
381 363
      * @return array
382 364
      */
383
-    protected function localeArray($locale)
384
-    {
365
+    protected function localeArray($locale) {
385 366
         return array_filter([$locale ?: $this->locale, $this->fallback]);
386 367
     }
387 368
 
@@ -390,8 +371,7 @@  discard block
 block discarded – undo
390 371
      *
391 372
      * @return \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Translation\MessageSelector
392 373
      */
393
-    public function getSelector()
394
-    {
374
+    public function getSelector() {
395 375
         if (! isset($this->selector)) {
396 376
             $this->selector = new MessageSelector;
397 377
         }
@@ -405,8 +385,7 @@  discard block
 block discarded – undo
405 385
      * @param  \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Translation\MessageSelector  $selector
406 386
      * @return void
407 387
      */
408
-    public function setSelector(MessageSelector $selector)
409
-    {
388
+    public function setSelector(MessageSelector $selector) {
410 389
         $this->selector = $selector;
411 390
     }
412 391
 
@@ -415,8 +394,7 @@  discard block
 block discarded – undo
415 394
      *
416 395
      * @return \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Translation\LoaderInterface
417 396
      */
418
-    public function getLoader()
419
-    {
397
+    public function getLoader() {
420 398
         return $this->loader;
421 399
     }
422 400
 
@@ -425,8 +403,7 @@  discard block
 block discarded – undo
425 403
      *
426 404
      * @return string
427 405
      */
428
-    public function locale()
429
-    {
406
+    public function locale() {
430 407
         return $this->getLocale();
431 408
     }
432 409
 
@@ -435,8 +412,7 @@  discard block
 block discarded – undo
435 412
      *
436 413
      * @return string
437 414
      */
438
-    public function getLocale()
439
-    {
415
+    public function getLocale() {
440 416
         return $this->locale;
441 417
     }
442 418
 
@@ -446,8 +422,7 @@  discard block
 block discarded – undo
446 422
      * @param  string  $locale
447 423
      * @return void
448 424
      */
449
-    public function setLocale($locale)
450
-    {
425
+    public function setLocale($locale) {
451 426
         $this->locale = $locale;
452 427
     }
453 428
 
@@ -456,8 +431,7 @@  discard block
 block discarded – undo
456 431
      *
457 432
      * @return string
458 433
      */
459
-    public function getFallback()
460
-    {
434
+    public function getFallback() {
461 435
         return $this->fallback;
462 436
     }
463 437
 
@@ -467,8 +441,7 @@  discard block
 block discarded – undo
467 441
      * @param  string  $fallback
468 442
      * @return void
469 443
      */
470
-    public function setFallback($fallback)
471
-    {
444
+    public function setFallback($fallback) {
472 445
         $this->fallback = $fallback;
473 446
     }
474 447
 }
Please login to merge, or discard this patch.
vendor_prefixed/illuminate/translation/MessageSelector.php 3 patches
Indentation   +388 added lines, -388 removed lines patch added patch discarded remove patch
@@ -12,407 +12,407 @@
 block discarded – undo
12 12
 
13 13
 class MessageSelector
14 14
 {
15
-    /**
16
-     * Select a proper translation string based on the given number.
17
-     *
18
-     * @param  string  $line
19
-     * @param  int  $number
20
-     * @param  string  $locale
21
-     * @return mixed
22
-     */
23
-    public function choose($line, $number, $locale)
24
-    {
25
-        $segments = explode('|', $line);
15
+	/**
16
+	 * Select a proper translation string based on the given number.
17
+	 *
18
+	 * @param  string  $line
19
+	 * @param  int  $number
20
+	 * @param  string  $locale
21
+	 * @return mixed
22
+	 */
23
+	public function choose($line, $number, $locale)
24
+	{
25
+		$segments = explode('|', $line);
26 26
 
27
-        if (($value = $this->extract($segments, $number)) !== null) {
28
-            return trim($value);
29
-        }
27
+		if (($value = $this->extract($segments, $number)) !== null) {
28
+			return trim($value);
29
+		}
30 30
 
31
-        $segments = $this->stripConditions($segments);
31
+		$segments = $this->stripConditions($segments);
32 32
 
33
-        $pluralIndex = $this->getPluralIndex($locale, $number);
33
+		$pluralIndex = $this->getPluralIndex($locale, $number);
34 34
 
35
-        if (count($segments) == 1 || ! isset($segments[$pluralIndex])) {
36
-            return $segments[0];
37
-        }
35
+		if (count($segments) == 1 || ! isset($segments[$pluralIndex])) {
36
+			return $segments[0];
37
+		}
38 38
 
39
-        return $segments[$pluralIndex];
40
-    }
39
+		return $segments[$pluralIndex];
40
+	}
41 41
 
42
-    /**
43
-     * Extract a translation string using inline conditions.
44
-     *
45
-     * @param  array  $segments
46
-     * @param  int  $number
47
-     * @return mixed
48
-     */
49
-    private function extract($segments, $number)
50
-    {
51
-        foreach ($segments as $part) {
52
-            if (! is_null($line = $this->extractFromString($part, $number))) {
53
-                return $line;
54
-            }
55
-        }
56
-    }
42
+	/**
43
+	 * Extract a translation string using inline conditions.
44
+	 *
45
+	 * @param  array  $segments
46
+	 * @param  int  $number
47
+	 * @return mixed
48
+	 */
49
+	private function extract($segments, $number)
50
+	{
51
+		foreach ($segments as $part) {
52
+			if (! is_null($line = $this->extractFromString($part, $number))) {
53
+				return $line;
54
+			}
55
+		}
56
+	}
57 57
 
58
-    /**
59
-     * Get the translation string if the condition matches.
60
-     *
61
-     * @param  string  $part
62
-     * @param  int  $number
63
-     * @return mixed
64
-     */
65
-    private function extractFromString($part, $number)
66
-    {
67
-        preg_match('/^[\{\[]([^\[\]\{\}]*)[\}\]](.*)/s', $part, $matches);
58
+	/**
59
+	 * Get the translation string if the condition matches.
60
+	 *
61
+	 * @param  string  $part
62
+	 * @param  int  $number
63
+	 * @return mixed
64
+	 */
65
+	private function extractFromString($part, $number)
66
+	{
67
+		preg_match('/^[\{\[]([^\[\]\{\}]*)[\}\]](.*)/s', $part, $matches);
68 68
 
69
-        if (count($matches) != 3) {
70
-            return;
71
-        }
69
+		if (count($matches) != 3) {
70
+			return;
71
+		}
72 72
 
73
-        $condition = $matches[1];
73
+		$condition = $matches[1];
74 74
 
75
-        $value = $matches[2];
75
+		$value = $matches[2];
76 76
 
77
-        if (Str::contains($condition, ',')) {
78
-            list($from, $to) = explode(',', $condition, 2);
77
+		if (Str::contains($condition, ',')) {
78
+			list($from, $to) = explode(',', $condition, 2);
79 79
 
80
-            if ($to == '*' && $number >= $from) {
81
-                return $value;
82
-            } elseif ($from == '*' && $number <= $to) {
83
-                return $value;
84
-            } elseif ($number >= $from && $number <= $to) {
85
-                return $value;
86
-            }
87
-        }
80
+			if ($to == '*' && $number >= $from) {
81
+				return $value;
82
+			} elseif ($from == '*' && $number <= $to) {
83
+				return $value;
84
+			} elseif ($number >= $from && $number <= $to) {
85
+				return $value;
86
+			}
87
+		}
88 88
 
89
-        return $condition == $number ? $value : null;
90
-    }
89
+		return $condition == $number ? $value : null;
90
+	}
91 91
 
92
-    /**
93
-     * Strip the inline conditions from each segment, just leaving the text.
94
-     *
95
-     * @param  array  $segments
96
-     * @return array
97
-     */
98
-    private function stripConditions($segments)
99
-    {
100
-        return collect($segments)->map(function ($part) {
101
-            return preg_replace('/^[\{\[]([^\[\]\{\}]*)[\}\]]/', '', $part);
102
-        })->all();
103
-    }
92
+	/**
93
+	 * Strip the inline conditions from each segment, just leaving the text.
94
+	 *
95
+	 * @param  array  $segments
96
+	 * @return array
97
+	 */
98
+	private function stripConditions($segments)
99
+	{
100
+		return collect($segments)->map(function ($part) {
101
+			return preg_replace('/^[\{\[]([^\[\]\{\}]*)[\}\]]/', '', $part);
102
+		})->all();
103
+	}
104 104
 
105
-    /**
106
-     * Get the index to use for pluralization.
107
-     *
108
-     * The plural rules are derived from code of the Zend Framework (2010-09-25), which
109
-     * is subject to the new BSD license (http://framework.zend.com/license/new-bsd)
110
-     * Copyright (c) 2005-2010 - Zend Technologies USA Inc. (http://www.zend.com)
111
-     *
112
-     * @param  string  $locale
113
-     * @param  int  $number
114
-     * @return int
115
-     */
116
-    public function getPluralIndex($locale, $number)
117
-    {
118
-        switch ($locale) {
119
-            case 'az':
120
-            case 'az_AZ':
121
-            case 'bo':
122
-            case 'bo_CN':
123
-            case 'bo_IN':
124
-            case 'dz':
125
-            case 'dz_BT':
126
-            case 'id':
127
-            case 'id_ID':
128
-            case 'ja':
129
-            case 'ja_JP':
130
-            case 'jv':
131
-            case 'ka':
132
-            case 'ka_GE':
133
-            case 'km':
134
-            case 'km_KH':
135
-            case 'kn':
136
-            case 'kn_IN':
137
-            case 'ko':
138
-            case 'ko_KR':
139
-            case 'ms':
140
-            case 'ms_MY':
141
-            case 'th':
142
-            case 'th_TH':
143
-            case 'tr':
144
-            case 'tr_CY':
145
-            case 'tr_TR':
146
-            case 'vi':
147
-            case 'vi_VN':
148
-            case 'zh':
149
-            case 'zh_CN':
150
-            case 'zh_HK':
151
-            case 'zh_SG':
152
-            case 'zh_TW':
153
-                return 0;
154
-            case 'af':
155
-            case 'af_ZA':
156
-            case 'bn':
157
-            case 'bn_BD':
158
-            case 'bn_IN':
159
-            case 'bg':
160
-            case 'bg_BG':
161
-            case 'ca':
162
-            case 'ca_AD':
163
-            case 'ca_ES':
164
-            case 'ca_FR':
165
-            case 'ca_IT':
166
-            case 'da':
167
-            case 'da_DK':
168
-            case 'de':
169
-            case 'de_AT':
170
-            case 'de_BE':
171
-            case 'de_CH':
172
-            case 'de_DE':
173
-            case 'de_LI':
174
-            case 'de_LU':
175
-            case 'el':
176
-            case 'el_CY':
177
-            case 'el_GR':
178
-            case 'en':
179
-            case 'en_AG':
180
-            case 'en_AU':
181
-            case 'en_BW':
182
-            case 'en_CA':
183
-            case 'en_DK':
184
-            case 'en_GB':
185
-            case 'en_HK':
186
-            case 'en_IE':
187
-            case 'en_IN':
188
-            case 'en_NG':
189
-            case 'en_NZ':
190
-            case 'en_PH':
191
-            case 'en_SG':
192
-            case 'en_US':
193
-            case 'en_ZA':
194
-            case 'en_ZM':
195
-            case 'en_ZW':
196
-            case 'eo':
197
-            case 'eo_US':
198
-            case 'es':
199
-            case 'es_AR':
200
-            case 'es_BO':
201
-            case 'es_CL':
202
-            case 'es_CO':
203
-            case 'es_CR':
204
-            case 'es_CU':
205
-            case 'es_DO':
206
-            case 'es_EC':
207
-            case 'es_ES':
208
-            case 'es_GT':
209
-            case 'es_HN':
210
-            case 'es_MX':
211
-            case 'es_NI':
212
-            case 'es_PA':
213
-            case 'es_PE':
214
-            case 'es_PR':
215
-            case 'es_PY':
216
-            case 'es_SV':
217
-            case 'es_US':
218
-            case 'es_UY':
219
-            case 'es_VE':
220
-            case 'et':
221
-            case 'et_EE':
222
-            case 'eu':
223
-            case 'eu_ES':
224
-            case 'eu_FR':
225
-            case 'fa':
226
-            case 'fa_IR':
227
-            case 'fi':
228
-            case 'fi_FI':
229
-            case 'fo':
230
-            case 'fo_FO':
231
-            case 'fur':
232
-            case 'fur_IT':
233
-            case 'fy':
234
-            case 'fy_DE':
235
-            case 'fy_NL':
236
-            case 'gl':
237
-            case 'gl_ES':
238
-            case 'gu':
239
-            case 'gu_IN':
240
-            case 'ha':
241
-            case 'ha_NG':
242
-            case 'he':
243
-            case 'he_IL':
244
-            case 'hu':
245
-            case 'hu_HU':
246
-            case 'is':
247
-            case 'is_IS':
248
-            case 'it':
249
-            case 'it_CH':
250
-            case 'it_IT':
251
-            case 'ku':
252
-            case 'ku_TR':
253
-            case 'lb':
254
-            case 'lb_LU':
255
-            case 'ml':
256
-            case 'ml_IN':
257
-            case 'mn':
258
-            case 'mn_MN':
259
-            case 'mr':
260
-            case 'mr_IN':
261
-            case 'nah':
262
-            case 'nb':
263
-            case 'nb_NO':
264
-            case 'ne':
265
-            case 'ne_NP':
266
-            case 'nl':
267
-            case 'nl_AW':
268
-            case 'nl_BE':
269
-            case 'nl_NL':
270
-            case 'nn':
271
-            case 'nn_NO':
272
-            case 'no':
273
-            case 'om':
274
-            case 'om_ET':
275
-            case 'om_KE':
276
-            case 'or':
277
-            case 'or_IN':
278
-            case 'pa':
279
-            case 'pa_IN':
280
-            case 'pa_PK':
281
-            case 'pap':
282
-            case 'pap_AN':
283
-            case 'pap_AW':
284
-            case 'pap_CW':
285
-            case 'ps':
286
-            case 'ps_AF':
287
-            case 'pt':
288
-            case 'pt_BR':
289
-            case 'pt_PT':
290
-            case 'so':
291
-            case 'so_DJ':
292
-            case 'so_ET':
293
-            case 'so_KE':
294
-            case 'so_SO':
295
-            case 'sq':
296
-            case 'sq_AL':
297
-            case 'sq_MK':
298
-            case 'sv':
299
-            case 'sv_FI':
300
-            case 'sv_SE':
301
-            case 'sw':
302
-            case 'sw_KE':
303
-            case 'sw_TZ':
304
-            case 'ta':
305
-            case 'ta_IN':
306
-            case 'ta_LK':
307
-            case 'te':
308
-            case 'te_IN':
309
-            case 'tk':
310
-            case 'tk_TM':
311
-            case 'ur':
312
-            case 'ur_IN':
313
-            case 'ur_PK':
314
-            case 'zu':
315
-            case 'zu_ZA':
316
-                return ($number == 1) ? 0 : 1;
317
-            case 'am':
318
-            case 'am_ET':
319
-            case 'bh':
320
-            case 'fil':
321
-            case 'fil_PH':
322
-            case 'fr':
323
-            case 'fr_BE':
324
-            case 'fr_CA':
325
-            case 'fr_CH':
326
-            case 'fr_FR':
327
-            case 'fr_LU':
328
-            case 'gun':
329
-            case 'hi':
330
-            case 'hi_IN':
331
-            case 'hy':
332
-            case 'hy_AM':
333
-            case 'ln':
334
-            case 'ln_CD':
335
-            case 'mg':
336
-            case 'mg_MG':
337
-            case 'nso':
338
-            case 'nso_ZA':
339
-            case 'ti':
340
-            case 'ti_ER':
341
-            case 'ti_ET':
342
-            case 'wa':
343
-            case 'wa_BE':
344
-            case 'xbr':
345
-                return (($number == 0) || ($number == 1)) ? 0 : 1;
346
-            case 'be':
347
-            case 'be_BY':
348
-            case 'bs':
349
-            case 'bs_BA':
350
-            case 'hr':
351
-            case 'hr_HR':
352
-            case 'ru':
353
-            case 'ru_RU':
354
-            case 'ru_UA':
355
-            case 'sr':
356
-            case 'sr_ME':
357
-            case 'sr_RS':
358
-            case 'uk':
359
-            case 'uk_UA':
360
-                return (($number % 10 == 1) && ($number % 100 != 11)) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2);
361
-            case 'cs':
362
-            case 'cs_CZ':
363
-            case 'sk':
364
-            case 'sk_SK':
365
-                return ($number == 1) ? 0 : ((($number >= 2) && ($number <= 4)) ? 1 : 2);
366
-            case 'ga':
367
-            case 'ga_IE':
368
-                return ($number == 1) ? 0 : (($number == 2) ? 1 : 2);
369
-            case 'lt':
370
-            case 'lt_LT':
371
-                return (($number % 10 == 1) && ($number % 100 != 11)) ? 0 : ((($number % 10 >= 2) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2);
372
-            case 'sl':
373
-            case 'sl_SI':
374
-                return ($number % 100 == 1) ? 0 : (($number % 100 == 2) ? 1 : ((($number % 100 == 3) || ($number % 100 == 4)) ? 2 : 3));
375
-            case 'mk':
376
-            case 'mk_MK':
377
-                return ($number % 10 == 1) ? 0 : 1;
378
-            case 'mt':
379
-            case 'mt_MT':
380
-                return ($number == 1) ? 0 : ((($number == 0) || (($number % 100 > 1) && ($number % 100 < 11))) ? 1 : ((($number % 100 > 10) && ($number % 100 < 20)) ? 2 : 3));
381
-            case 'lv':
382
-            case 'lv_LV':
383
-                return ($number == 0) ? 0 : ((($number % 10 == 1) && ($number % 100 != 11)) ? 1 : 2);
384
-            case 'pl':
385
-            case 'pl_PL':
386
-                return ($number == 1) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 12) || ($number % 100 > 14))) ? 1 : 2);
387
-            case 'cy':
388
-            case 'cy_GB':
389
-                return ($number == 1) ? 0 : (($number == 2) ? 1 : ((($number == 8) || ($number == 11)) ? 2 : 3));
390
-            case 'ro':
391
-            case 'ro_RO':
392
-                return ($number == 1) ? 0 : ((($number == 0) || (($number % 100 > 0) && ($number % 100 < 20))) ? 1 : 2);
393
-            case 'ar':
394
-            case 'ar_AE':
395
-            case 'ar_BH':
396
-            case 'ar_DZ':
397
-            case 'ar_EG':
398
-            case 'ar_IN':
399
-            case 'ar_IQ':
400
-            case 'ar_JO':
401
-            case 'ar_KW':
402
-            case 'ar_LB':
403
-            case 'ar_LY':
404
-            case 'ar_MA':
405
-            case 'ar_OM':
406
-            case 'ar_QA':
407
-            case 'ar_SA':
408
-            case 'ar_SD':
409
-            case 'ar_SS':
410
-            case 'ar_SY':
411
-            case 'ar_TN':
412
-            case 'ar_YE':
413
-                return ($number == 0) ? 0 : (($number == 1) ? 1 : (($number == 2) ? 2 : ((($number % 100 >= 3) && ($number % 100 <= 10)) ? 3 : ((($number % 100 >= 11) && ($number % 100 <= 99)) ? 4 : 5))));
414
-            default:
415
-                return 0;
416
-        }
417
-    }
105
+	/**
106
+	 * Get the index to use for pluralization.
107
+	 *
108
+	 * The plural rules are derived from code of the Zend Framework (2010-09-25), which
109
+	 * is subject to the new BSD license (http://framework.zend.com/license/new-bsd)
110
+	 * Copyright (c) 2005-2010 - Zend Technologies USA Inc. (http://www.zend.com)
111
+	 *
112
+	 * @param  string  $locale
113
+	 * @param  int  $number
114
+	 * @return int
115
+	 */
116
+	public function getPluralIndex($locale, $number)
117
+	{
118
+		switch ($locale) {
119
+			case 'az':
120
+			case 'az_AZ':
121
+			case 'bo':
122
+			case 'bo_CN':
123
+			case 'bo_IN':
124
+			case 'dz':
125
+			case 'dz_BT':
126
+			case 'id':
127
+			case 'id_ID':
128
+			case 'ja':
129
+			case 'ja_JP':
130
+			case 'jv':
131
+			case 'ka':
132
+			case 'ka_GE':
133
+			case 'km':
134
+			case 'km_KH':
135
+			case 'kn':
136
+			case 'kn_IN':
137
+			case 'ko':
138
+			case 'ko_KR':
139
+			case 'ms':
140
+			case 'ms_MY':
141
+			case 'th':
142
+			case 'th_TH':
143
+			case 'tr':
144
+			case 'tr_CY':
145
+			case 'tr_TR':
146
+			case 'vi':
147
+			case 'vi_VN':
148
+			case 'zh':
149
+			case 'zh_CN':
150
+			case 'zh_HK':
151
+			case 'zh_SG':
152
+			case 'zh_TW':
153
+				return 0;
154
+			case 'af':
155
+			case 'af_ZA':
156
+			case 'bn':
157
+			case 'bn_BD':
158
+			case 'bn_IN':
159
+			case 'bg':
160
+			case 'bg_BG':
161
+			case 'ca':
162
+			case 'ca_AD':
163
+			case 'ca_ES':
164
+			case 'ca_FR':
165
+			case 'ca_IT':
166
+			case 'da':
167
+			case 'da_DK':
168
+			case 'de':
169
+			case 'de_AT':
170
+			case 'de_BE':
171
+			case 'de_CH':
172
+			case 'de_DE':
173
+			case 'de_LI':
174
+			case 'de_LU':
175
+			case 'el':
176
+			case 'el_CY':
177
+			case 'el_GR':
178
+			case 'en':
179
+			case 'en_AG':
180
+			case 'en_AU':
181
+			case 'en_BW':
182
+			case 'en_CA':
183
+			case 'en_DK':
184
+			case 'en_GB':
185
+			case 'en_HK':
186
+			case 'en_IE':
187
+			case 'en_IN':
188
+			case 'en_NG':
189
+			case 'en_NZ':
190
+			case 'en_PH':
191
+			case 'en_SG':
192
+			case 'en_US':
193
+			case 'en_ZA':
194
+			case 'en_ZM':
195
+			case 'en_ZW':
196
+			case 'eo':
197
+			case 'eo_US':
198
+			case 'es':
199
+			case 'es_AR':
200
+			case 'es_BO':
201
+			case 'es_CL':
202
+			case 'es_CO':
203
+			case 'es_CR':
204
+			case 'es_CU':
205
+			case 'es_DO':
206
+			case 'es_EC':
207
+			case 'es_ES':
208
+			case 'es_GT':
209
+			case 'es_HN':
210
+			case 'es_MX':
211
+			case 'es_NI':
212
+			case 'es_PA':
213
+			case 'es_PE':
214
+			case 'es_PR':
215
+			case 'es_PY':
216
+			case 'es_SV':
217
+			case 'es_US':
218
+			case 'es_UY':
219
+			case 'es_VE':
220
+			case 'et':
221
+			case 'et_EE':
222
+			case 'eu':
223
+			case 'eu_ES':
224
+			case 'eu_FR':
225
+			case 'fa':
226
+			case 'fa_IR':
227
+			case 'fi':
228
+			case 'fi_FI':
229
+			case 'fo':
230
+			case 'fo_FO':
231
+			case 'fur':
232
+			case 'fur_IT':
233
+			case 'fy':
234
+			case 'fy_DE':
235
+			case 'fy_NL':
236
+			case 'gl':
237
+			case 'gl_ES':
238
+			case 'gu':
239
+			case 'gu_IN':
240
+			case 'ha':
241
+			case 'ha_NG':
242
+			case 'he':
243
+			case 'he_IL':
244
+			case 'hu':
245
+			case 'hu_HU':
246
+			case 'is':
247
+			case 'is_IS':
248
+			case 'it':
249
+			case 'it_CH':
250
+			case 'it_IT':
251
+			case 'ku':
252
+			case 'ku_TR':
253
+			case 'lb':
254
+			case 'lb_LU':
255
+			case 'ml':
256
+			case 'ml_IN':
257
+			case 'mn':
258
+			case 'mn_MN':
259
+			case 'mr':
260
+			case 'mr_IN':
261
+			case 'nah':
262
+			case 'nb':
263
+			case 'nb_NO':
264
+			case 'ne':
265
+			case 'ne_NP':
266
+			case 'nl':
267
+			case 'nl_AW':
268
+			case 'nl_BE':
269
+			case 'nl_NL':
270
+			case 'nn':
271
+			case 'nn_NO':
272
+			case 'no':
273
+			case 'om':
274
+			case 'om_ET':
275
+			case 'om_KE':
276
+			case 'or':
277
+			case 'or_IN':
278
+			case 'pa':
279
+			case 'pa_IN':
280
+			case 'pa_PK':
281
+			case 'pap':
282
+			case 'pap_AN':
283
+			case 'pap_AW':
284
+			case 'pap_CW':
285
+			case 'ps':
286
+			case 'ps_AF':
287
+			case 'pt':
288
+			case 'pt_BR':
289
+			case 'pt_PT':
290
+			case 'so':
291
+			case 'so_DJ':
292
+			case 'so_ET':
293
+			case 'so_KE':
294
+			case 'so_SO':
295
+			case 'sq':
296
+			case 'sq_AL':
297
+			case 'sq_MK':
298
+			case 'sv':
299
+			case 'sv_FI':
300
+			case 'sv_SE':
301
+			case 'sw':
302
+			case 'sw_KE':
303
+			case 'sw_TZ':
304
+			case 'ta':
305
+			case 'ta_IN':
306
+			case 'ta_LK':
307
+			case 'te':
308
+			case 'te_IN':
309
+			case 'tk':
310
+			case 'tk_TM':
311
+			case 'ur':
312
+			case 'ur_IN':
313
+			case 'ur_PK':
314
+			case 'zu':
315
+			case 'zu_ZA':
316
+				return ($number == 1) ? 0 : 1;
317
+			case 'am':
318
+			case 'am_ET':
319
+			case 'bh':
320
+			case 'fil':
321
+			case 'fil_PH':
322
+			case 'fr':
323
+			case 'fr_BE':
324
+			case 'fr_CA':
325
+			case 'fr_CH':
326
+			case 'fr_FR':
327
+			case 'fr_LU':
328
+			case 'gun':
329
+			case 'hi':
330
+			case 'hi_IN':
331
+			case 'hy':
332
+			case 'hy_AM':
333
+			case 'ln':
334
+			case 'ln_CD':
335
+			case 'mg':
336
+			case 'mg_MG':
337
+			case 'nso':
338
+			case 'nso_ZA':
339
+			case 'ti':
340
+			case 'ti_ER':
341
+			case 'ti_ET':
342
+			case 'wa':
343
+			case 'wa_BE':
344
+			case 'xbr':
345
+				return (($number == 0) || ($number == 1)) ? 0 : 1;
346
+			case 'be':
347
+			case 'be_BY':
348
+			case 'bs':
349
+			case 'bs_BA':
350
+			case 'hr':
351
+			case 'hr_HR':
352
+			case 'ru':
353
+			case 'ru_RU':
354
+			case 'ru_UA':
355
+			case 'sr':
356
+			case 'sr_ME':
357
+			case 'sr_RS':
358
+			case 'uk':
359
+			case 'uk_UA':
360
+				return (($number % 10 == 1) && ($number % 100 != 11)) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2);
361
+			case 'cs':
362
+			case 'cs_CZ':
363
+			case 'sk':
364
+			case 'sk_SK':
365
+				return ($number == 1) ? 0 : ((($number >= 2) && ($number <= 4)) ? 1 : 2);
366
+			case 'ga':
367
+			case 'ga_IE':
368
+				return ($number == 1) ? 0 : (($number == 2) ? 1 : 2);
369
+			case 'lt':
370
+			case 'lt_LT':
371
+				return (($number % 10 == 1) && ($number % 100 != 11)) ? 0 : ((($number % 10 >= 2) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2);
372
+			case 'sl':
373
+			case 'sl_SI':
374
+				return ($number % 100 == 1) ? 0 : (($number % 100 == 2) ? 1 : ((($number % 100 == 3) || ($number % 100 == 4)) ? 2 : 3));
375
+			case 'mk':
376
+			case 'mk_MK':
377
+				return ($number % 10 == 1) ? 0 : 1;
378
+			case 'mt':
379
+			case 'mt_MT':
380
+				return ($number == 1) ? 0 : ((($number == 0) || (($number % 100 > 1) && ($number % 100 < 11))) ? 1 : ((($number % 100 > 10) && ($number % 100 < 20)) ? 2 : 3));
381
+			case 'lv':
382
+			case 'lv_LV':
383
+				return ($number == 0) ? 0 : ((($number % 10 == 1) && ($number % 100 != 11)) ? 1 : 2);
384
+			case 'pl':
385
+			case 'pl_PL':
386
+				return ($number == 1) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 12) || ($number % 100 > 14))) ? 1 : 2);
387
+			case 'cy':
388
+			case 'cy_GB':
389
+				return ($number == 1) ? 0 : (($number == 2) ? 1 : ((($number == 8) || ($number == 11)) ? 2 : 3));
390
+			case 'ro':
391
+			case 'ro_RO':
392
+				return ($number == 1) ? 0 : ((($number == 0) || (($number % 100 > 0) && ($number % 100 < 20))) ? 1 : 2);
393
+			case 'ar':
394
+			case 'ar_AE':
395
+			case 'ar_BH':
396
+			case 'ar_DZ':
397
+			case 'ar_EG':
398
+			case 'ar_IN':
399
+			case 'ar_IQ':
400
+			case 'ar_JO':
401
+			case 'ar_KW':
402
+			case 'ar_LB':
403
+			case 'ar_LY':
404
+			case 'ar_MA':
405
+			case 'ar_OM':
406
+			case 'ar_QA':
407
+			case 'ar_SA':
408
+			case 'ar_SD':
409
+			case 'ar_SS':
410
+			case 'ar_SY':
411
+			case 'ar_TN':
412
+			case 'ar_YE':
413
+				return ($number == 0) ? 0 : (($number == 1) ? 1 : (($number == 2) ? 2 : ((($number % 100 >= 3) && ($number % 100 <= 10)) ? 3 : ((($number % 100 >= 11) && ($number % 100 <= 99)) ? 4 : 5))));
414
+			default:
415
+				return 0;
416
+		}
417
+	}
418 418
 }
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -20,23 +20,23 @@  discard block
 block discarded – undo
20 20
      * @param  string  $locale
21 21
      * @return mixed
22 22
      */
23
-    public function choose($line, $number, $locale)
23
+    public function choose( $line, $number, $locale )
24 24
     {
25
-        $segments = explode('|', $line);
25
+        $segments = explode( '|', $line );
26 26
 
27
-        if (($value = $this->extract($segments, $number)) !== null) {
28
-            return trim($value);
27
+        if ( ( $value = $this->extract( $segments, $number ) ) !== null ) {
28
+            return trim( $value );
29 29
         }
30 30
 
31
-        $segments = $this->stripConditions($segments);
31
+        $segments = $this->stripConditions( $segments );
32 32
 
33
-        $pluralIndex = $this->getPluralIndex($locale, $number);
33
+        $pluralIndex = $this->getPluralIndex( $locale, $number );
34 34
 
35
-        if (count($segments) == 1 || ! isset($segments[$pluralIndex])) {
36
-            return $segments[0];
35
+        if ( count( $segments ) == 1 || ! isset( $segments[ $pluralIndex ] ) ) {
36
+            return $segments[ 0 ];
37 37
         }
38 38
 
39
-        return $segments[$pluralIndex];
39
+        return $segments[ $pluralIndex ];
40 40
     }
41 41
 
42 42
     /**
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
      * @param  int  $number
47 47
      * @return mixed
48 48
      */
49
-    private function extract($segments, $number)
49
+    private function extract( $segments, $number )
50 50
     {
51
-        foreach ($segments as $part) {
52
-            if (! is_null($line = $this->extractFromString($part, $number))) {
51
+        foreach ( $segments as $part ) {
52
+            if ( ! is_null( $line = $this->extractFromString( $part, $number ) ) ) {
53 53
                 return $line;
54 54
             }
55 55
         }
@@ -62,26 +62,26 @@  discard block
 block discarded – undo
62 62
      * @param  int  $number
63 63
      * @return mixed
64 64
      */
65
-    private function extractFromString($part, $number)
65
+    private function extractFromString( $part, $number )
66 66
     {
67
-        preg_match('/^[\{\[]([^\[\]\{\}]*)[\}\]](.*)/s', $part, $matches);
67
+        preg_match( '/^[\{\[]([^\[\]\{\}]*)[\}\]](.*)/s', $part, $matches );
68 68
 
69
-        if (count($matches) != 3) {
69
+        if ( count( $matches ) != 3 ) {
70 70
             return;
71 71
         }
72 72
 
73
-        $condition = $matches[1];
73
+        $condition = $matches[ 1 ];
74 74
 
75
-        $value = $matches[2];
75
+        $value = $matches[ 2 ];
76 76
 
77
-        if (Str::contains($condition, ',')) {
78
-            list($from, $to) = explode(',', $condition, 2);
77
+        if ( Str::contains( $condition, ',' ) ) {
78
+            list( $from, $to ) = explode( ',', $condition, 2 );
79 79
 
80
-            if ($to == '*' && $number >= $from) {
80
+            if ( $to == '*' && $number >= $from ) {
81 81
                 return $value;
82
-            } elseif ($from == '*' && $number <= $to) {
82
+            } elseif ( $from == '*' && $number <= $to ) {
83 83
                 return $value;
84
-            } elseif ($number >= $from && $number <= $to) {
84
+            } elseif ( $number >= $from && $number <= $to ) {
85 85
                 return $value;
86 86
             }
87 87
         }
@@ -95,10 +95,10 @@  discard block
 block discarded – undo
95 95
      * @param  array  $segments
96 96
      * @return array
97 97
      */
98
-    private function stripConditions($segments)
98
+    private function stripConditions( $segments )
99 99
     {
100
-        return collect($segments)->map(function ($part) {
101
-            return preg_replace('/^[\{\[]([^\[\]\{\}]*)[\}\]]/', '', $part);
100
+        return collect( $segments )->map( function( $part ) {
101
+            return preg_replace( '/^[\{\[]([^\[\]\{\}]*)[\}\]]/', '', $part );
102 102
         })->all();
103 103
     }
104 104
 
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
      * @param  int  $number
114 114
      * @return int
115 115
      */
116
-    public function getPluralIndex($locale, $number)
116
+    public function getPluralIndex( $locale, $number )
117 117
     {
118
-        switch ($locale) {
118
+        switch ( $locale ) {
119 119
             case 'az':
120 120
             case 'az_AZ':
121 121
             case 'bo':
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
             case 'ur_PK':
314 314
             case 'zu':
315 315
             case 'zu_ZA':
316
-                return ($number == 1) ? 0 : 1;
316
+                return ( $number == 1 ) ? 0 : 1;
317 317
             case 'am':
318 318
             case 'am_ET':
319 319
             case 'bh':
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
             case 'wa':
343 343
             case 'wa_BE':
344 344
             case 'xbr':
345
-                return (($number == 0) || ($number == 1)) ? 0 : 1;
345
+                return ( ( $number == 0 ) || ( $number == 1 ) ) ? 0 : 1;
346 346
             case 'be':
347 347
             case 'be_BY':
348 348
             case 'bs':
@@ -357,39 +357,39 @@  discard block
 block discarded – undo
357 357
             case 'sr_RS':
358 358
             case 'uk':
359 359
             case 'uk_UA':
360
-                return (($number % 10 == 1) && ($number % 100 != 11)) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2);
360
+                return ( ( $number % 10 == 1 ) && ( $number % 100 != 11 ) ) ? 0 : ( ( ( $number % 10 >= 2 ) && ( $number % 10 <= 4 ) && ( ( $number % 100 < 10 ) || ( $number % 100 >= 20 ) ) ) ? 1 : 2 );
361 361
             case 'cs':
362 362
             case 'cs_CZ':
363 363
             case 'sk':
364 364
             case 'sk_SK':
365
-                return ($number == 1) ? 0 : ((($number >= 2) && ($number <= 4)) ? 1 : 2);
365
+                return ( $number == 1 ) ? 0 : ( ( ( $number >= 2 ) && ( $number <= 4 ) ) ? 1 : 2 );
366 366
             case 'ga':
367 367
             case 'ga_IE':
368
-                return ($number == 1) ? 0 : (($number == 2) ? 1 : 2);
368
+                return ( $number == 1 ) ? 0 : ( ( $number == 2 ) ? 1 : 2 );
369 369
             case 'lt':
370 370
             case 'lt_LT':
371
-                return (($number % 10 == 1) && ($number % 100 != 11)) ? 0 : ((($number % 10 >= 2) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2);
371
+                return ( ( $number % 10 == 1 ) && ( $number % 100 != 11 ) ) ? 0 : ( ( ( $number % 10 >= 2 ) && ( ( $number % 100 < 10 ) || ( $number % 100 >= 20 ) ) ) ? 1 : 2 );
372 372
             case 'sl':
373 373
             case 'sl_SI':
374
-                return ($number % 100 == 1) ? 0 : (($number % 100 == 2) ? 1 : ((($number % 100 == 3) || ($number % 100 == 4)) ? 2 : 3));
374
+                return ( $number % 100 == 1 ) ? 0 : ( ( $number % 100 == 2 ) ? 1 : ( ( ( $number % 100 == 3 ) || ( $number % 100 == 4 ) ) ? 2 : 3 ) );
375 375
             case 'mk':
376 376
             case 'mk_MK':
377
-                return ($number % 10 == 1) ? 0 : 1;
377
+                return ( $number % 10 == 1 ) ? 0 : 1;
378 378
             case 'mt':
379 379
             case 'mt_MT':
380
-                return ($number == 1) ? 0 : ((($number == 0) || (($number % 100 > 1) && ($number % 100 < 11))) ? 1 : ((($number % 100 > 10) && ($number % 100 < 20)) ? 2 : 3));
380
+                return ( $number == 1 ) ? 0 : ( ( ( $number == 0 ) || ( ( $number % 100 > 1 ) && ( $number % 100 < 11 ) ) ) ? 1 : ( ( ( $number % 100 > 10 ) && ( $number % 100 < 20 ) ) ? 2 : 3 ) );
381 381
             case 'lv':
382 382
             case 'lv_LV':
383
-                return ($number == 0) ? 0 : ((($number % 10 == 1) && ($number % 100 != 11)) ? 1 : 2);
383
+                return ( $number == 0 ) ? 0 : ( ( ( $number % 10 == 1 ) && ( $number % 100 != 11 ) ) ? 1 : 2 );
384 384
             case 'pl':
385 385
             case 'pl_PL':
386
-                return ($number == 1) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 12) || ($number % 100 > 14))) ? 1 : 2);
386
+                return ( $number == 1 ) ? 0 : ( ( ( $number % 10 >= 2 ) && ( $number % 10 <= 4 ) && ( ( $number % 100 < 12 ) || ( $number % 100 > 14 ) ) ) ? 1 : 2 );
387 387
             case 'cy':
388 388
             case 'cy_GB':
389
-                return ($number == 1) ? 0 : (($number == 2) ? 1 : ((($number == 8) || ($number == 11)) ? 2 : 3));
389
+                return ( $number == 1 ) ? 0 : ( ( $number == 2 ) ? 1 : ( ( ( $number == 8 ) || ( $number == 11 ) ) ? 2 : 3 ) );
390 390
             case 'ro':
391 391
             case 'ro_RO':
392
-                return ($number == 1) ? 0 : ((($number == 0) || (($number % 100 > 0) && ($number % 100 < 20))) ? 1 : 2);
392
+                return ( $number == 1 ) ? 0 : ( ( ( $number == 0 ) || ( ( $number % 100 > 0 ) && ( $number % 100 < 20 ) ) ) ? 1 : 2 );
393 393
             case 'ar':
394 394
             case 'ar_AE':
395 395
             case 'ar_BH':
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
             case 'ar_SY':
411 411
             case 'ar_TN':
412 412
             case 'ar_YE':
413
-                return ($number == 0) ? 0 : (($number == 1) ? 1 : (($number == 2) ? 2 : ((($number % 100 >= 3) && ($number % 100 <= 10)) ? 3 : ((($number % 100 >= 11) && ($number % 100 <= 99)) ? 4 : 5))));
413
+                return ( $number == 0 ) ? 0 : ( ( $number == 1 ) ? 1 : ( ( $number == 2 ) ? 2 : ( ( ( $number % 100 >= 3 ) && ( $number % 100 <= 10 ) ) ? 3 : ( ( ( $number % 100 >= 11 ) && ( $number % 100 <= 99 ) ) ? 4 : 5 ) ) ) );
414 414
             default:
415 415
                 return 0;
416 416
         }
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -10,8 +10,7 @@  discard block
 block discarded – undo
10 10
 
11 11
 use GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Support\Str;
12 12
 
13
-class MessageSelector
14
-{
13
+class MessageSelector {
15 14
     /**
16 15
      * Select a proper translation string based on the given number.
17 16
      *
@@ -20,8 +19,7 @@  discard block
 block discarded – undo
20 19
      * @param  string  $locale
21 20
      * @return mixed
22 21
      */
23
-    public function choose($line, $number, $locale)
24
-    {
22
+    public function choose($line, $number, $locale) {
25 23
         $segments = explode('|', $line);
26 24
 
27 25
         if (($value = $this->extract($segments, $number)) !== null) {
@@ -46,8 +44,7 @@  discard block
 block discarded – undo
46 44
      * @param  int  $number
47 45
      * @return mixed
48 46
      */
49
-    private function extract($segments, $number)
50
-    {
47
+    private function extract($segments, $number) {
51 48
         foreach ($segments as $part) {
52 49
             if (! is_null($line = $this->extractFromString($part, $number))) {
53 50
                 return $line;
@@ -62,8 +59,7 @@  discard block
 block discarded – undo
62 59
      * @param  int  $number
63 60
      * @return mixed
64 61
      */
65
-    private function extractFromString($part, $number)
66
-    {
62
+    private function extractFromString($part, $number) {
67 63
         preg_match('/^[\{\[]([^\[\]\{\}]*)[\}\]](.*)/s', $part, $matches);
68 64
 
69 65
         if (count($matches) != 3) {
@@ -95,8 +91,7 @@  discard block
 block discarded – undo
95 91
      * @param  array  $segments
96 92
      * @return array
97 93
      */
98
-    private function stripConditions($segments)
99
-    {
94
+    private function stripConditions($segments) {
100 95
         return collect($segments)->map(function ($part) {
101 96
             return preg_replace('/^[\{\[]([^\[\]\{\}]*)[\}\]]/', '', $part);
102 97
         })->all();
@@ -113,8 +108,7 @@  discard block
 block discarded – undo
113 108
      * @param  int  $number
114 109
      * @return int
115 110
      */
116
-    public function getPluralIndex($locale, $number)
117
-    {
111
+    public function getPluralIndex($locale, $number) {
118 112
         switch ($locale) {
119 113
             case 'az':
120 114
             case 'az_AZ':
Please login to merge, or discard this patch.
vendor_prefixed/illuminate/translation/LoaderInterface.php 3 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -10,29 +10,29 @@
 block discarded – undo
10 10
 
11 11
 interface LoaderInterface
12 12
 {
13
-    /**
14
-     * Load the messages for the given locale.
15
-     *
16
-     * @param  string  $locale
17
-     * @param  string  $group
18
-     * @param  string  $namespace
19
-     * @return array
20
-     */
21
-    public function load($locale, $group, $namespace = null);
13
+	/**
14
+	 * Load the messages for the given locale.
15
+	 *
16
+	 * @param  string  $locale
17
+	 * @param  string  $group
18
+	 * @param  string  $namespace
19
+	 * @return array
20
+	 */
21
+	public function load($locale, $group, $namespace = null);
22 22
 
23
-    /**
24
-     * Add a new namespace to the loader.
25
-     *
26
-     * @param  string  $namespace
27
-     * @param  string  $hint
28
-     * @return void
29
-     */
30
-    public function addNamespace($namespace, $hint);
23
+	/**
24
+	 * Add a new namespace to the loader.
25
+	 *
26
+	 * @param  string  $namespace
27
+	 * @param  string  $hint
28
+	 * @return void
29
+	 */
30
+	public function addNamespace($namespace, $hint);
31 31
 
32
-    /**
33
-     * Get an array of all the registered namespaces.
34
-     *
35
-     * @return array
36
-     */
37
-    public function namespaces();
32
+	/**
33
+	 * Get an array of all the registered namespaces.
34
+	 *
35
+	 * @return array
36
+	 */
37
+	public function namespaces();
38 38
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
      * @param  string  $namespace
19 19
      * @return array
20 20
      */
21
-    public function load($locale, $group, $namespace = null);
21
+    public function load( $locale, $group, $namespace = null );
22 22
 
23 23
     /**
24 24
      * Add a new namespace to the loader.
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
      * @param  string  $hint
28 28
      * @return void
29 29
      */
30
-    public function addNamespace($namespace, $hint);
30
+    public function addNamespace( $namespace, $hint );
31 31
 
32 32
     /**
33 33
      * Get an array of all the registered namespaces.
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,8 +8,7 @@
 block discarded – undo
8 8
 
9 9
 namespace GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Translation;
10 10
 
11
-interface LoaderInterface
12
-{
11
+interface LoaderInterface {
13 12
     /**
14 13
      * Load the messages for the given locale.
15 14
      *
Please login to merge, or discard this patch.
vendor_prefixed/illuminate/translation/ArrayLoader.php 3 patches
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -10,69 +10,69 @@
 block discarded – undo
10 10
 
11 11
 class ArrayLoader implements LoaderInterface
12 12
 {
13
-    /**
14
-     * All of the translation messages.
15
-     *
16
-     * @var array
17
-     */
18
-    protected $messages = [];
13
+	/**
14
+	 * All of the translation messages.
15
+	 *
16
+	 * @var array
17
+	 */
18
+	protected $messages = [];
19 19
 
20
-    /**
21
-     * Load the messages for the given locale.
22
-     *
23
-     * @param  string  $locale
24
-     * @param  string  $group
25
-     * @param  string  $namespace
26
-     * @return array
27
-     */
28
-    public function load($locale, $group, $namespace = null)
29
-    {
30
-        $namespace = $namespace ?: '*';
20
+	/**
21
+	 * Load the messages for the given locale.
22
+	 *
23
+	 * @param  string  $locale
24
+	 * @param  string  $group
25
+	 * @param  string  $namespace
26
+	 * @return array
27
+	 */
28
+	public function load($locale, $group, $namespace = null)
29
+	{
30
+		$namespace = $namespace ?: '*';
31 31
 
32
-        if (isset($this->messages[$namespace][$locale][$group])) {
33
-            return $this->messages[$namespace][$locale][$group];
34
-        }
32
+		if (isset($this->messages[$namespace][$locale][$group])) {
33
+			return $this->messages[$namespace][$locale][$group];
34
+		}
35 35
 
36
-        return [];
37
-    }
36
+		return [];
37
+	}
38 38
 
39
-    /**
40
-     * Add a new namespace to the loader.
41
-     *
42
-     * @param  string  $namespace
43
-     * @param  string  $hint
44
-     * @return void
45
-     */
46
-    public function addNamespace($namespace, $hint)
47
-    {
48
-        //
49
-    }
39
+	/**
40
+	 * Add a new namespace to the loader.
41
+	 *
42
+	 * @param  string  $namespace
43
+	 * @param  string  $hint
44
+	 * @return void
45
+	 */
46
+	public function addNamespace($namespace, $hint)
47
+	{
48
+		//
49
+	}
50 50
 
51
-    /**
52
-     * Add messages to the loader.
53
-     *
54
-     * @param  string  $locale
55
-     * @param  string  $group
56
-     * @param  array  $messages
57
-     * @param  string|null  $namespace
58
-     * @return $this
59
-     */
60
-    public function addMessages($locale, $group, array $messages, $namespace = null)
61
-    {
62
-        $namespace = $namespace ?: '*';
51
+	/**
52
+	 * Add messages to the loader.
53
+	 *
54
+	 * @param  string  $locale
55
+	 * @param  string  $group
56
+	 * @param  array  $messages
57
+	 * @param  string|null  $namespace
58
+	 * @return $this
59
+	 */
60
+	public function addMessages($locale, $group, array $messages, $namespace = null)
61
+	{
62
+		$namespace = $namespace ?: '*';
63 63
 
64
-        $this->messages[$namespace][$locale][$group] = $messages;
64
+		$this->messages[$namespace][$locale][$group] = $messages;
65 65
 
66
-        return $this;
67
-    }
66
+		return $this;
67
+	}
68 68
 
69
-    /**
70
-     * Get an array of all the registered namespaces.
71
-     *
72
-     * @return array
73
-     */
74
-    public function namespaces()
75
-    {
76
-        return [];
77
-    }
69
+	/**
70
+	 * Get an array of all the registered namespaces.
71
+	 *
72
+	 * @return array
73
+	 */
74
+	public function namespaces()
75
+	{
76
+		return [];
77
+	}
78 78
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
      *
16 16
      * @var array
17 17
      */
18
-    protected $messages = [];
18
+    protected $messages = [ ];
19 19
 
20 20
     /**
21 21
      * Load the messages for the given locale.
@@ -25,15 +25,15 @@  discard block
 block discarded – undo
25 25
      * @param  string  $namespace
26 26
      * @return array
27 27
      */
28
-    public function load($locale, $group, $namespace = null)
28
+    public function load( $locale, $group, $namespace = null )
29 29
     {
30 30
         $namespace = $namespace ?: '*';
31 31
 
32
-        if (isset($this->messages[$namespace][$locale][$group])) {
33
-            return $this->messages[$namespace][$locale][$group];
32
+        if ( isset( $this->messages[ $namespace ][ $locale ][ $group ] ) ) {
33
+            return $this->messages[ $namespace ][ $locale ][ $group ];
34 34
         }
35 35
 
36
-        return [];
36
+        return [ ];
37 37
     }
38 38
 
39 39
     /**
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      * @param  string  $hint
44 44
      * @return void
45 45
      */
46
-    public function addNamespace($namespace, $hint)
46
+    public function addNamespace( $namespace, $hint )
47 47
     {
48 48
         //
49 49
     }
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
      * @param  string|null  $namespace
58 58
      * @return $this
59 59
      */
60
-    public function addMessages($locale, $group, array $messages, $namespace = null)
60
+    public function addMessages( $locale, $group, array $messages, $namespace = null )
61 61
     {
62 62
         $namespace = $namespace ?: '*';
63 63
 
64
-        $this->messages[$namespace][$locale][$group] = $messages;
64
+        $this->messages[ $namespace ][ $locale ][ $group ] = $messages;
65 65
 
66 66
         return $this;
67 67
     }
@@ -73,6 +73,6 @@  discard block
 block discarded – undo
73 73
      */
74 74
     public function namespaces()
75 75
     {
76
-        return [];
76
+        return [ ];
77 77
     }
78 78
 }
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -8,8 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 namespace GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Translation;
10 10
 
11
-class ArrayLoader implements LoaderInterface
12
-{
11
+class ArrayLoader implements LoaderInterface {
13 12
     /**
14 13
      * All of the translation messages.
15 14
      *
@@ -25,8 +24,7 @@  discard block
 block discarded – undo
25 24
      * @param  string  $namespace
26 25
      * @return array
27 26
      */
28
-    public function load($locale, $group, $namespace = null)
29
-    {
27
+    public function load($locale, $group, $namespace = null) {
30 28
         $namespace = $namespace ?: '*';
31 29
 
32 30
         if (isset($this->messages[$namespace][$locale][$group])) {
@@ -43,8 +41,7 @@  discard block
 block discarded – undo
43 41
      * @param  string  $hint
44 42
      * @return void
45 43
      */
46
-    public function addNamespace($namespace, $hint)
47
-    {
44
+    public function addNamespace($namespace, $hint) {
48 45
         //
49 46
     }
50 47
 
@@ -57,8 +54,7 @@  discard block
 block discarded – undo
57 54
      * @param  string|null  $namespace
58 55
      * @return $this
59 56
      */
60
-    public function addMessages($locale, $group, array $messages, $namespace = null)
61
-    {
57
+    public function addMessages($locale, $group, array $messages, $namespace = null) {
62 58
         $namespace = $namespace ?: '*';
63 59
 
64 60
         $this->messages[$namespace][$locale][$group] = $messages;
@@ -71,8 +67,7 @@  discard block
 block discarded – undo
71 67
      *
72 68
      * @return array
73 69
      */
74
-    public function namespaces()
75
-    {
70
+    public function namespaces() {
76 71
         return [];
77 72
     }
78 73
 }
Please login to merge, or discard this patch.
vendor_prefixed/illuminate/filesystem/FilesystemServiceProvider.php 3 patches
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -12,77 +12,77 @@
 block discarded – undo
12 12
 
13 13
 class FilesystemServiceProvider extends ServiceProvider
14 14
 {
15
-    /**
16
-     * Register the service provider.
17
-     *
18
-     * @return void
19
-     */
20
-    public function register()
21
-    {
22
-        $this->registerNativeFilesystem();
15
+	/**
16
+	 * Register the service provider.
17
+	 *
18
+	 * @return void
19
+	 */
20
+	public function register()
21
+	{
22
+		$this->registerNativeFilesystem();
23 23
 
24
-        $this->registerFlysystem();
25
-    }
24
+		$this->registerFlysystem();
25
+	}
26 26
 
27
-    /**
28
-     * Register the native filesystem implementation.
29
-     *
30
-     * @return void
31
-     */
32
-    protected function registerNativeFilesystem()
33
-    {
34
-        $this->app->singleton('files', function () {
35
-            return new Filesystem;
36
-        });
37
-    }
27
+	/**
28
+	 * Register the native filesystem implementation.
29
+	 *
30
+	 * @return void
31
+	 */
32
+	protected function registerNativeFilesystem()
33
+	{
34
+		$this->app->singleton('files', function () {
35
+			return new Filesystem;
36
+		});
37
+	}
38 38
 
39
-    /**
40
-     * Register the driver based filesystem.
41
-     *
42
-     * @return void
43
-     */
44
-    protected function registerFlysystem()
45
-    {
46
-        $this->registerManager();
39
+	/**
40
+	 * Register the driver based filesystem.
41
+	 *
42
+	 * @return void
43
+	 */
44
+	protected function registerFlysystem()
45
+	{
46
+		$this->registerManager();
47 47
 
48
-        $this->app->singleton('filesystem.disk', function () {
49
-            return $this->app['filesystem']->disk($this->getDefaultDriver());
50
-        });
48
+		$this->app->singleton('filesystem.disk', function () {
49
+			return $this->app['filesystem']->disk($this->getDefaultDriver());
50
+		});
51 51
 
52
-        $this->app->singleton('filesystem.cloud', function () {
53
-            return $this->app['filesystem']->disk($this->getCloudDriver());
54
-        });
55
-    }
52
+		$this->app->singleton('filesystem.cloud', function () {
53
+			return $this->app['filesystem']->disk($this->getCloudDriver());
54
+		});
55
+	}
56 56
 
57
-    /**
58
-     * Register the filesystem manager.
59
-     *
60
-     * @return void
61
-     */
62
-    protected function registerManager()
63
-    {
64
-        $this->app->singleton('filesystem', function () {
65
-            return new FilesystemManager($this->app);
66
-        });
67
-    }
57
+	/**
58
+	 * Register the filesystem manager.
59
+	 *
60
+	 * @return void
61
+	 */
62
+	protected function registerManager()
63
+	{
64
+		$this->app->singleton('filesystem', function () {
65
+			return new FilesystemManager($this->app);
66
+		});
67
+	}
68 68
 
69
-    /**
70
-     * Get the default file driver.
71
-     *
72
-     * @return string
73
-     */
74
-    protected function getDefaultDriver()
75
-    {
76
-        return $this->app['config']['filesystems.default'];
77
-    }
69
+	/**
70
+	 * Get the default file driver.
71
+	 *
72
+	 * @return string
73
+	 */
74
+	protected function getDefaultDriver()
75
+	{
76
+		return $this->app['config']['filesystems.default'];
77
+	}
78 78
 
79
-    /**
80
-     * Get the default cloud based file driver.
81
-     *
82
-     * @return string
83
-     */
84
-    protected function getCloudDriver()
85
-    {
86
-        return $this->app['config']['filesystems.cloud'];
87
-    }
79
+	/**
80
+	 * Get the default cloud based file driver.
81
+	 *
82
+	 * @return string
83
+	 */
84
+	protected function getCloudDriver()
85
+	{
86
+		return $this->app['config']['filesystems.cloud'];
87
+	}
88 88
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      */
32 32
     protected function registerNativeFilesystem()
33 33
     {
34
-        $this->app->singleton('files', function () {
34
+        $this->app->singleton( 'files', function() {
35 35
             return new Filesystem;
36 36
         });
37 37
     }
@@ -45,12 +45,12 @@  discard block
 block discarded – undo
45 45
     {
46 46
         $this->registerManager();
47 47
 
48
-        $this->app->singleton('filesystem.disk', function () {
49
-            return $this->app['filesystem']->disk($this->getDefaultDriver());
48
+        $this->app->singleton( 'filesystem.disk', function() {
49
+            return $this->app[ 'filesystem' ]->disk( $this->getDefaultDriver() );
50 50
         });
51 51
 
52
-        $this->app->singleton('filesystem.cloud', function () {
53
-            return $this->app['filesystem']->disk($this->getCloudDriver());
52
+        $this->app->singleton( 'filesystem.cloud', function() {
53
+            return $this->app[ 'filesystem' ]->disk( $this->getCloudDriver() );
54 54
         });
55 55
     }
56 56
 
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
      */
62 62
     protected function registerManager()
63 63
     {
64
-        $this->app->singleton('filesystem', function () {
65
-            return new FilesystemManager($this->app);
64
+        $this->app->singleton( 'filesystem', function() {
65
+            return new FilesystemManager( $this->app );
66 66
         });
67 67
     }
68 68
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
      */
74 74
     protected function getDefaultDriver()
75 75
     {
76
-        return $this->app['config']['filesystems.default'];
76
+        return $this->app[ 'config' ][ 'filesystems.default' ];
77 77
     }
78 78
 
79 79
     /**
@@ -83,6 +83,6 @@  discard block
 block discarded – undo
83 83
      */
84 84
     protected function getCloudDriver()
85 85
     {
86
-        return $this->app['config']['filesystems.cloud'];
86
+        return $this->app[ 'config' ][ 'filesystems.cloud' ];
87 87
     }
88 88
 }
Please login to merge, or discard this patch.
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -10,15 +10,13 @@  discard block
 block discarded – undo
10 10
 
11 11
 use GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Support\ServiceProvider;
12 12
 
13
-class FilesystemServiceProvider extends ServiceProvider
14
-{
13
+class FilesystemServiceProvider extends ServiceProvider {
15 14
     /**
16 15
      * Register the service provider.
17 16
      *
18 17
      * @return void
19 18
      */
20
-    public function register()
21
-    {
19
+    public function register() {
22 20
         $this->registerNativeFilesystem();
23 21
 
24 22
         $this->registerFlysystem();
@@ -29,8 +27,7 @@  discard block
 block discarded – undo
29 27
      *
30 28
      * @return void
31 29
      */
32
-    protected function registerNativeFilesystem()
33
-    {
30
+    protected function registerNativeFilesystem() {
34 31
         $this->app->singleton('files', function () {
35 32
             return new Filesystem;
36 33
         });
@@ -41,8 +38,7 @@  discard block
 block discarded – undo
41 38
      *
42 39
      * @return void
43 40
      */
44
-    protected function registerFlysystem()
45
-    {
41
+    protected function registerFlysystem() {
46 42
         $this->registerManager();
47 43
 
48 44
         $this->app->singleton('filesystem.disk', function () {
@@ -59,8 +55,7 @@  discard block
 block discarded – undo
59 55
      *
60 56
      * @return void
61 57
      */
62
-    protected function registerManager()
63
-    {
58
+    protected function registerManager() {
64 59
         $this->app->singleton('filesystem', function () {
65 60
             return new FilesystemManager($this->app);
66 61
         });
@@ -71,8 +66,7 @@  discard block
 block discarded – undo
71 66
      *
72 67
      * @return string
73 68
      */
74
-    protected function getDefaultDriver()
75
-    {
69
+    protected function getDefaultDriver() {
76 70
         return $this->app['config']['filesystems.default'];
77 71
     }
78 72
 
@@ -81,8 +75,7 @@  discard block
 block discarded – undo
81 75
      *
82 76
      * @return string
83 77
      */
84
-    protected function getCloudDriver()
85
-    {
78
+    protected function getCloudDriver() {
86 79
         return $this->app['config']['filesystems.cloud'];
87 80
     }
88 81
 }
Please login to merge, or discard this patch.
vendor_prefixed/illuminate/filesystem/FilesystemAdapter.php 3 patches
Indentation   +522 added lines, -522 removed lines patch added patch discarded remove patch
@@ -29,526 +29,526 @@
 block discarded – undo
29 29
  */
30 30
 class FilesystemAdapter implements FilesystemContract, CloudFilesystemContract
31 31
 {
32
-    /**
33
-     * The Flysystem filesystem implementation.
34
-     *
35
-     * @var \League\Flysystem\FilesystemInterface
36
-     */
37
-    protected $driver;
38
-
39
-    /**
40
-     * Create a new filesystem adapter instance.
41
-     *
42
-     * @param  \League\Flysystem\FilesystemInterface  $driver
43
-     * @return void
44
-     */
45
-    public function __construct(FilesystemInterface $driver)
46
-    {
47
-        $this->driver = $driver;
48
-    }
49
-
50
-    /**
51
-     * Assert that the given file exists.
52
-     *
53
-     * @param  string  $path
54
-     * @return void
55
-     */
56
-    public function assertExists($path)
57
-    {
58
-        PHPUnit::assertTrue(
59
-            $this->exists($path), "Unable to find a file at path [{$path}]."
60
-        );
61
-    }
62
-
63
-    /**
64
-     * Assert that the given file does not exist.
65
-     *
66
-     * @param  string  $path
67
-     * @return void
68
-     */
69
-    public function assertMissing($path)
70
-    {
71
-        PHPUnit::assertFalse(
72
-            $this->exists($path), "Found unexpected file at path [{$path}]."
73
-        );
74
-    }
75
-
76
-    /**
77
-     * Determine if a file exists.
78
-     *
79
-     * @param  string  $path
80
-     * @return bool
81
-     */
82
-    public function exists($path)
83
-    {
84
-        return $this->driver->has($path);
85
-    }
86
-
87
-    /**
88
-     * Get the full path for the file at the given "short" path.
89
-     *
90
-     * @param  string  $path
91
-     * @return string
92
-     */
93
-    public function path($path)
94
-    {
95
-        return $this->driver->getAdapter()->getPathPrefix().$path;
96
-    }
97
-
98
-    /**
99
-     * Get the contents of a file.
100
-     *
101
-     * @param  string  $path
102
-     * @return string
103
-     *
104
-     * @throws \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Contracts\Filesystem\FileNotFoundException
105
-     */
106
-    public function get($path)
107
-    {
108
-        try {
109
-            return $this->driver->read($path);
110
-        } catch (FileNotFoundException $e) {
111
-            throw new ContractFileNotFoundException($path, $e->getCode(), $e);
112
-        }
113
-    }
114
-
115
-    /**
116
-     * Write the contents of a file.
117
-     *
118
-     * @param  string  $path
119
-     * @param  string|resource  $contents
120
-     * @param  array  $options
121
-     * @return bool
122
-     */
123
-    public function put($path, $contents, $options = [])
124
-    {
125
-        if (is_string($options)) {
126
-            $options = ['visibility' => $options];
127
-        }
128
-
129
-        // If the given contents is actually a file or uploaded file instance than we will
130
-        // automatically store the file using a stream. This provides a convenient path
131
-        // for the developer to store streams without managing them manually in code.
132
-        if ($contents instanceof File ||
133
-            $contents instanceof UploadedFile) {
134
-            return $this->putFile($path, $contents, $options);
135
-        }
136
-
137
-        return is_resource($contents)
138
-                ? $this->driver->putStream($path, $contents, $options)
139
-                : $this->driver->put($path, $contents, $options);
140
-    }
141
-
142
-    /**
143
-     * Store the uploaded file on the disk.
144
-     *
145
-     * @param  string  $path
146
-     * @param  \Illuminate\Http\File|\Illuminate\Http\UploadedFile  $file
147
-     * @param  array  $options
148
-     * @return string|false
149
-     */
150
-    public function putFile($path, $file, $options = [])
151
-    {
152
-        return $this->putFileAs($path, $file, $file->hashName(), $options);
153
-    }
154
-
155
-    /**
156
-     * Store the uploaded file on the disk with a given name.
157
-     *
158
-     * @param  string  $path
159
-     * @param  \Illuminate\Http\File|\Illuminate\Http\UploadedFile  $file
160
-     * @param  string  $name
161
-     * @param  array  $options
162
-     * @return string|false
163
-     */
164
-    public function putFileAs($path, $file, $name, $options = [])
165
-    {
166
-        $stream = fopen($file->getRealPath(), 'r+');
167
-
168
-        // Next, we will format the path of the file and store the file using a stream since
169
-        // they provide better performance than alternatives. Once we write the file this
170
-        // stream will get closed automatically by us so the developer doesn't have to.
171
-        $result = $this->put(
172
-            $path = trim($path.'/'.$name, '/'), $stream, $options
173
-        );
174
-
175
-        if (is_resource($stream)) {
176
-            fclose($stream);
177
-        }
178
-
179
-        return $result ? $path : false;
180
-    }
181
-
182
-    /**
183
-     * Get the visibility for the given path.
184
-     *
185
-     * @param  string  $path
186
-     * @return string
187
-     */
188
-    public function getVisibility($path)
189
-    {
190
-        if ($this->driver->getVisibility($path) == AdapterInterface::VISIBILITY_PUBLIC) {
191
-            return FilesystemContract::VISIBILITY_PUBLIC;
192
-        }
193
-
194
-        return FilesystemContract::VISIBILITY_PRIVATE;
195
-    }
196
-
197
-    /**
198
-     * Set the visibility for the given path.
199
-     *
200
-     * @param  string  $path
201
-     * @param  string  $visibility
202
-     * @return void
203
-     */
204
-    public function setVisibility($path, $visibility)
205
-    {
206
-        return $this->driver->setVisibility($path, $this->parseVisibility($visibility));
207
-    }
208
-
209
-    /**
210
-     * Prepend to a file.
211
-     *
212
-     * @param  string  $path
213
-     * @param  string  $data
214
-     * @param  string  $separator
215
-     * @return int
216
-     */
217
-    public function prepend($path, $data, $separator = PHP_EOL)
218
-    {
219
-        if ($this->exists($path)) {
220
-            return $this->put($path, $data.$separator.$this->get($path));
221
-        }
222
-
223
-        return $this->put($path, $data);
224
-    }
225
-
226
-    /**
227
-     * Append to a file.
228
-     *
229
-     * @param  string  $path
230
-     * @param  string  $data
231
-     * @param  string  $separator
232
-     * @return int
233
-     */
234
-    public function append($path, $data, $separator = PHP_EOL)
235
-    {
236
-        if ($this->exists($path)) {
237
-            return $this->put($path, $this->get($path).$separator.$data);
238
-        }
239
-
240
-        return $this->put($path, $data);
241
-    }
242
-
243
-    /**
244
-     * Delete the file at a given path.
245
-     *
246
-     * @param  string|array  $paths
247
-     * @return bool
248
-     */
249
-    public function delete($paths)
250
-    {
251
-        $paths = is_array($paths) ? $paths : func_get_args();
252
-
253
-        $success = true;
254
-
255
-        foreach ($paths as $path) {
256
-            try {
257
-                if (! $this->driver->delete($path)) {
258
-                    $success = false;
259
-                }
260
-            } catch (FileNotFoundException $e) {
261
-                $success = false;
262
-            }
263
-        }
264
-
265
-        return $success;
266
-    }
267
-
268
-    /**
269
-     * Copy a file to a new location.
270
-     *
271
-     * @param  string  $from
272
-     * @param  string  $to
273
-     * @return bool
274
-     */
275
-    public function copy($from, $to)
276
-    {
277
-        return $this->driver->copy($from, $to);
278
-    }
279
-
280
-    /**
281
-     * Move a file to a new location.
282
-     *
283
-     * @param  string  $from
284
-     * @param  string  $to
285
-     * @return bool
286
-     */
287
-    public function move($from, $to)
288
-    {
289
-        return $this->driver->rename($from, $to);
290
-    }
291
-
292
-    /**
293
-     * Get the file size of a given file.
294
-     *
295
-     * @param  string  $path
296
-     * @return int
297
-     */
298
-    public function size($path)
299
-    {
300
-        return $this->driver->getSize($path);
301
-    }
302
-
303
-    /**
304
-     * Get the mime-type of a given file.
305
-     *
306
-     * @param  string  $path
307
-     * @return string|false
308
-     */
309
-    public function mimeType($path)
310
-    {
311
-        return $this->driver->getMimetype($path);
312
-    }
313
-
314
-    /**
315
-     * Get the file's last modification time.
316
-     *
317
-     * @param  string  $path
318
-     * @return int
319
-     */
320
-    public function lastModified($path)
321
-    {
322
-        return $this->driver->getTimestamp($path);
323
-    }
324
-
325
-    /**
326
-     * Get the URL for the file at the given path.
327
-     *
328
-     * @param  string  $path
329
-     * @return string
330
-     */
331
-    public function url($path)
332
-    {
333
-        $adapter = $this->driver->getAdapter();
334
-
335
-        if (method_exists($adapter, 'getUrl')) {
336
-            return $adapter->getUrl($path);
337
-        } elseif ($adapter instanceof AwsS3Adapter) {
338
-            return $this->getAwsUrl($adapter, $path);
339
-        } elseif ($adapter instanceof LocalAdapter) {
340
-            return $this->getLocalUrl($path);
341
-        } else {
342
-            throw new RuntimeException('This driver does not support retrieving URLs.');
343
-        }
344
-    }
345
-
346
-    /**
347
-     * Get the URL for the file at the given path.
348
-     *
349
-     * @param  \League\Flysystem\AwsS3v3\AwsS3Adapter  $adapter
350
-     * @param  string  $path
351
-     * @return string
352
-     */
353
-    protected function getAwsUrl($adapter, $path)
354
-    {
355
-        return $adapter->getClient()->getObjectUrl(
356
-            $adapter->getBucket(), $adapter->getPathPrefix().$path
357
-        );
358
-    }
359
-
360
-    /**
361
-     * Get the URL for the file at the given path.
362
-     *
363
-     * @param  string  $path
364
-     * @return string
365
-     */
366
-    protected function getLocalUrl($path)
367
-    {
368
-        $config = $this->driver->getConfig();
369
-
370
-        // If an explicit base URL has been set on the disk configuration then we will use
371
-        // it as the base URL instead of the default path. This allows the developer to
372
-        // have full control over the base path for this filesystem's generated URLs.
373
-        if ($config->has('url')) {
374
-            return rtrim($config->get('url'), '/').'/'.ltrim($path, '/');
375
-        }
376
-
377
-        $path = '/storage/'.$path;
378
-
379
-        // If the path contains "storage/public", it probably means the developer is using
380
-        // the default disk to generate the path instead of the "public" disk like they
381
-        // are really supposed to use. We will remove the public from this path here.
382
-        if (Str::contains($path, '/storage/public/')) {
383
-            return Str::replaceFirst('/public/', '/', $path);
384
-        } else {
385
-            return $path;
386
-        }
387
-    }
388
-
389
-    /**
390
-     * Get a temporary URL for the file at the given path.
391
-     *
392
-     * @param  string  $path
393
-     * @param  \DateTimeInterface  $expiration
394
-     * @param  array  $options
395
-     * @return string
396
-     */
397
-    public function temporaryUrl($path, $expiration, array $options = [])
398
-    {
399
-        $adapter = $this->driver->getAdapter();
400
-
401
-        if (method_exists($adapter, 'getTemporaryUrl')) {
402
-            return $adapter->getTemporaryUrl($path, $expiration, $options);
403
-        } elseif (! $adapter instanceof AwsS3Adapter) {
404
-            throw new RuntimeException('This driver does not support creating temporary URLs.');
405
-        }
406
-
407
-        $client = $adapter->getClient();
408
-
409
-        $command = $client->getCommand('GetObject', array_merge([
410
-            'Bucket' => $adapter->getBucket(),
411
-            'Key' => $adapter->getPathPrefix().$path,
412
-        ], $options));
413
-
414
-        return (string) $client->createPresignedRequest(
415
-            $command, $expiration
416
-        )->getUri();
417
-    }
418
-
419
-    /**
420
-     * Get an array of all files in a directory.
421
-     *
422
-     * @param  string|null  $directory
423
-     * @param  bool  $recursive
424
-     * @return array
425
-     */
426
-    public function files($directory = null, $recursive = false)
427
-    {
428
-        $contents = $this->driver->listContents($directory, $recursive);
429
-
430
-        return $this->filterContentsByType($contents, 'file');
431
-    }
432
-
433
-    /**
434
-     * Get all of the files from the given directory (recursive).
435
-     *
436
-     * @param  string|null  $directory
437
-     * @return array
438
-     */
439
-    public function allFiles($directory = null)
440
-    {
441
-        return $this->files($directory, true);
442
-    }
443
-
444
-    /**
445
-     * Get all of the directories within a given directory.
446
-     *
447
-     * @param  string|null  $directory
448
-     * @param  bool  $recursive
449
-     * @return array
450
-     */
451
-    public function directories($directory = null, $recursive = false)
452
-    {
453
-        $contents = $this->driver->listContents($directory, $recursive);
454
-
455
-        return $this->filterContentsByType($contents, 'dir');
456
-    }
457
-
458
-    /**
459
-     * Get all (recursive) of the directories within a given directory.
460
-     *
461
-     * @param  string|null  $directory
462
-     * @return array
463
-     */
464
-    public function allDirectories($directory = null)
465
-    {
466
-        return $this->directories($directory, true);
467
-    }
468
-
469
-    /**
470
-     * Create a directory.
471
-     *
472
-     * @param  string  $path
473
-     * @return bool
474
-     */
475
-    public function makeDirectory($path)
476
-    {
477
-        return $this->driver->createDir($path);
478
-    }
479
-
480
-    /**
481
-     * Recursively delete a directory.
482
-     *
483
-     * @param  string  $directory
484
-     * @return bool
485
-     */
486
-    public function deleteDirectory($directory)
487
-    {
488
-        return $this->driver->deleteDir($directory);
489
-    }
490
-
491
-    /**
492
-     * Get the Flysystem driver.
493
-     *
494
-     * @return \League\Flysystem\FilesystemInterface
495
-     */
496
-    public function getDriver()
497
-    {
498
-        return $this->driver;
499
-    }
500
-
501
-    /**
502
-     * Filter directory contents by type.
503
-     *
504
-     * @param  array  $contents
505
-     * @param  string  $type
506
-     * @return array
507
-     */
508
-    protected function filterContentsByType($contents, $type)
509
-    {
510
-        return Collection::make($contents)
511
-            ->where('type', $type)
512
-            ->pluck('path')
513
-            ->values()
514
-            ->all();
515
-    }
516
-
517
-    /**
518
-     * Parse the given visibility value.
519
-     *
520
-     * @param  string|null  $visibility
521
-     * @return string|null
522
-     *
523
-     * @throws \InvalidArgumentException
524
-     */
525
-    protected function parseVisibility($visibility)
526
-    {
527
-        if (is_null($visibility)) {
528
-            return;
529
-        }
530
-
531
-        switch ($visibility) {
532
-            case FilesystemContract::VISIBILITY_PUBLIC:
533
-                return AdapterInterface::VISIBILITY_PUBLIC;
534
-            case FilesystemContract::VISIBILITY_PRIVATE:
535
-                return AdapterInterface::VISIBILITY_PRIVATE;
536
-        }
537
-
538
-        throw new InvalidArgumentException('Unknown visibility: '.$visibility);
539
-    }
540
-
541
-    /**
542
-     * Pass dynamic methods call onto Flysystem.
543
-     *
544
-     * @param  string  $method
545
-     * @param  array  $parameters
546
-     * @return mixed
547
-     *
548
-     * @throws \BadMethodCallException
549
-     */
550
-    public function __call($method, array $parameters)
551
-    {
552
-        return call_user_func_array([$this->driver, $method], $parameters);
553
-    }
32
+	/**
33
+	 * The Flysystem filesystem implementation.
34
+	 *
35
+	 * @var \League\Flysystem\FilesystemInterface
36
+	 */
37
+	protected $driver;
38
+
39
+	/**
40
+	 * Create a new filesystem adapter instance.
41
+	 *
42
+	 * @param  \League\Flysystem\FilesystemInterface  $driver
43
+	 * @return void
44
+	 */
45
+	public function __construct(FilesystemInterface $driver)
46
+	{
47
+		$this->driver = $driver;
48
+	}
49
+
50
+	/**
51
+	 * Assert that the given file exists.
52
+	 *
53
+	 * @param  string  $path
54
+	 * @return void
55
+	 */
56
+	public function assertExists($path)
57
+	{
58
+		PHPUnit::assertTrue(
59
+			$this->exists($path), "Unable to find a file at path [{$path}]."
60
+		);
61
+	}
62
+
63
+	/**
64
+	 * Assert that the given file does not exist.
65
+	 *
66
+	 * @param  string  $path
67
+	 * @return void
68
+	 */
69
+	public function assertMissing($path)
70
+	{
71
+		PHPUnit::assertFalse(
72
+			$this->exists($path), "Found unexpected file at path [{$path}]."
73
+		);
74
+	}
75
+
76
+	/**
77
+	 * Determine if a file exists.
78
+	 *
79
+	 * @param  string  $path
80
+	 * @return bool
81
+	 */
82
+	public function exists($path)
83
+	{
84
+		return $this->driver->has($path);
85
+	}
86
+
87
+	/**
88
+	 * Get the full path for the file at the given "short" path.
89
+	 *
90
+	 * @param  string  $path
91
+	 * @return string
92
+	 */
93
+	public function path($path)
94
+	{
95
+		return $this->driver->getAdapter()->getPathPrefix().$path;
96
+	}
97
+
98
+	/**
99
+	 * Get the contents of a file.
100
+	 *
101
+	 * @param  string  $path
102
+	 * @return string
103
+	 *
104
+	 * @throws \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Contracts\Filesystem\FileNotFoundException
105
+	 */
106
+	public function get($path)
107
+	{
108
+		try {
109
+			return $this->driver->read($path);
110
+		} catch (FileNotFoundException $e) {
111
+			throw new ContractFileNotFoundException($path, $e->getCode(), $e);
112
+		}
113
+	}
114
+
115
+	/**
116
+	 * Write the contents of a file.
117
+	 *
118
+	 * @param  string  $path
119
+	 * @param  string|resource  $contents
120
+	 * @param  array  $options
121
+	 * @return bool
122
+	 */
123
+	public function put($path, $contents, $options = [])
124
+	{
125
+		if (is_string($options)) {
126
+			$options = ['visibility' => $options];
127
+		}
128
+
129
+		// If the given contents is actually a file or uploaded file instance than we will
130
+		// automatically store the file using a stream. This provides a convenient path
131
+		// for the developer to store streams without managing them manually in code.
132
+		if ($contents instanceof File ||
133
+			$contents instanceof UploadedFile) {
134
+			return $this->putFile($path, $contents, $options);
135
+		}
136
+
137
+		return is_resource($contents)
138
+				? $this->driver->putStream($path, $contents, $options)
139
+				: $this->driver->put($path, $contents, $options);
140
+	}
141
+
142
+	/**
143
+	 * Store the uploaded file on the disk.
144
+	 *
145
+	 * @param  string  $path
146
+	 * @param  \Illuminate\Http\File|\Illuminate\Http\UploadedFile  $file
147
+	 * @param  array  $options
148
+	 * @return string|false
149
+	 */
150
+	public function putFile($path, $file, $options = [])
151
+	{
152
+		return $this->putFileAs($path, $file, $file->hashName(), $options);
153
+	}
154
+
155
+	/**
156
+	 * Store the uploaded file on the disk with a given name.
157
+	 *
158
+	 * @param  string  $path
159
+	 * @param  \Illuminate\Http\File|\Illuminate\Http\UploadedFile  $file
160
+	 * @param  string  $name
161
+	 * @param  array  $options
162
+	 * @return string|false
163
+	 */
164
+	public function putFileAs($path, $file, $name, $options = [])
165
+	{
166
+		$stream = fopen($file->getRealPath(), 'r+');
167
+
168
+		// Next, we will format the path of the file and store the file using a stream since
169
+		// they provide better performance than alternatives. Once we write the file this
170
+		// stream will get closed automatically by us so the developer doesn't have to.
171
+		$result = $this->put(
172
+			$path = trim($path.'/'.$name, '/'), $stream, $options
173
+		);
174
+
175
+		if (is_resource($stream)) {
176
+			fclose($stream);
177
+		}
178
+
179
+		return $result ? $path : false;
180
+	}
181
+
182
+	/**
183
+	 * Get the visibility for the given path.
184
+	 *
185
+	 * @param  string  $path
186
+	 * @return string
187
+	 */
188
+	public function getVisibility($path)
189
+	{
190
+		if ($this->driver->getVisibility($path) == AdapterInterface::VISIBILITY_PUBLIC) {
191
+			return FilesystemContract::VISIBILITY_PUBLIC;
192
+		}
193
+
194
+		return FilesystemContract::VISIBILITY_PRIVATE;
195
+	}
196
+
197
+	/**
198
+	 * Set the visibility for the given path.
199
+	 *
200
+	 * @param  string  $path
201
+	 * @param  string  $visibility
202
+	 * @return void
203
+	 */
204
+	public function setVisibility($path, $visibility)
205
+	{
206
+		return $this->driver->setVisibility($path, $this->parseVisibility($visibility));
207
+	}
208
+
209
+	/**
210
+	 * Prepend to a file.
211
+	 *
212
+	 * @param  string  $path
213
+	 * @param  string  $data
214
+	 * @param  string  $separator
215
+	 * @return int
216
+	 */
217
+	public function prepend($path, $data, $separator = PHP_EOL)
218
+	{
219
+		if ($this->exists($path)) {
220
+			return $this->put($path, $data.$separator.$this->get($path));
221
+		}
222
+
223
+		return $this->put($path, $data);
224
+	}
225
+
226
+	/**
227
+	 * Append to a file.
228
+	 *
229
+	 * @param  string  $path
230
+	 * @param  string  $data
231
+	 * @param  string  $separator
232
+	 * @return int
233
+	 */
234
+	public function append($path, $data, $separator = PHP_EOL)
235
+	{
236
+		if ($this->exists($path)) {
237
+			return $this->put($path, $this->get($path).$separator.$data);
238
+		}
239
+
240
+		return $this->put($path, $data);
241
+	}
242
+
243
+	/**
244
+	 * Delete the file at a given path.
245
+	 *
246
+	 * @param  string|array  $paths
247
+	 * @return bool
248
+	 */
249
+	public function delete($paths)
250
+	{
251
+		$paths = is_array($paths) ? $paths : func_get_args();
252
+
253
+		$success = true;
254
+
255
+		foreach ($paths as $path) {
256
+			try {
257
+				if (! $this->driver->delete($path)) {
258
+					$success = false;
259
+				}
260
+			} catch (FileNotFoundException $e) {
261
+				$success = false;
262
+			}
263
+		}
264
+
265
+		return $success;
266
+	}
267
+
268
+	/**
269
+	 * Copy a file to a new location.
270
+	 *
271
+	 * @param  string  $from
272
+	 * @param  string  $to
273
+	 * @return bool
274
+	 */
275
+	public function copy($from, $to)
276
+	{
277
+		return $this->driver->copy($from, $to);
278
+	}
279
+
280
+	/**
281
+	 * Move a file to a new location.
282
+	 *
283
+	 * @param  string  $from
284
+	 * @param  string  $to
285
+	 * @return bool
286
+	 */
287
+	public function move($from, $to)
288
+	{
289
+		return $this->driver->rename($from, $to);
290
+	}
291
+
292
+	/**
293
+	 * Get the file size of a given file.
294
+	 *
295
+	 * @param  string  $path
296
+	 * @return int
297
+	 */
298
+	public function size($path)
299
+	{
300
+		return $this->driver->getSize($path);
301
+	}
302
+
303
+	/**
304
+	 * Get the mime-type of a given file.
305
+	 *
306
+	 * @param  string  $path
307
+	 * @return string|false
308
+	 */
309
+	public function mimeType($path)
310
+	{
311
+		return $this->driver->getMimetype($path);
312
+	}
313
+
314
+	/**
315
+	 * Get the file's last modification time.
316
+	 *
317
+	 * @param  string  $path
318
+	 * @return int
319
+	 */
320
+	public function lastModified($path)
321
+	{
322
+		return $this->driver->getTimestamp($path);
323
+	}
324
+
325
+	/**
326
+	 * Get the URL for the file at the given path.
327
+	 *
328
+	 * @param  string  $path
329
+	 * @return string
330
+	 */
331
+	public function url($path)
332
+	{
333
+		$adapter = $this->driver->getAdapter();
334
+
335
+		if (method_exists($adapter, 'getUrl')) {
336
+			return $adapter->getUrl($path);
337
+		} elseif ($adapter instanceof AwsS3Adapter) {
338
+			return $this->getAwsUrl($adapter, $path);
339
+		} elseif ($adapter instanceof LocalAdapter) {
340
+			return $this->getLocalUrl($path);
341
+		} else {
342
+			throw new RuntimeException('This driver does not support retrieving URLs.');
343
+		}
344
+	}
345
+
346
+	/**
347
+	 * Get the URL for the file at the given path.
348
+	 *
349
+	 * @param  \League\Flysystem\AwsS3v3\AwsS3Adapter  $adapter
350
+	 * @param  string  $path
351
+	 * @return string
352
+	 */
353
+	protected function getAwsUrl($adapter, $path)
354
+	{
355
+		return $adapter->getClient()->getObjectUrl(
356
+			$adapter->getBucket(), $adapter->getPathPrefix().$path
357
+		);
358
+	}
359
+
360
+	/**
361
+	 * Get the URL for the file at the given path.
362
+	 *
363
+	 * @param  string  $path
364
+	 * @return string
365
+	 */
366
+	protected function getLocalUrl($path)
367
+	{
368
+		$config = $this->driver->getConfig();
369
+
370
+		// If an explicit base URL has been set on the disk configuration then we will use
371
+		// it as the base URL instead of the default path. This allows the developer to
372
+		// have full control over the base path for this filesystem's generated URLs.
373
+		if ($config->has('url')) {
374
+			return rtrim($config->get('url'), '/').'/'.ltrim($path, '/');
375
+		}
376
+
377
+		$path = '/storage/'.$path;
378
+
379
+		// If the path contains "storage/public", it probably means the developer is using
380
+		// the default disk to generate the path instead of the "public" disk like they
381
+		// are really supposed to use. We will remove the public from this path here.
382
+		if (Str::contains($path, '/storage/public/')) {
383
+			return Str::replaceFirst('/public/', '/', $path);
384
+		} else {
385
+			return $path;
386
+		}
387
+	}
388
+
389
+	/**
390
+	 * Get a temporary URL for the file at the given path.
391
+	 *
392
+	 * @param  string  $path
393
+	 * @param  \DateTimeInterface  $expiration
394
+	 * @param  array  $options
395
+	 * @return string
396
+	 */
397
+	public function temporaryUrl($path, $expiration, array $options = [])
398
+	{
399
+		$adapter = $this->driver->getAdapter();
400
+
401
+		if (method_exists($adapter, 'getTemporaryUrl')) {
402
+			return $adapter->getTemporaryUrl($path, $expiration, $options);
403
+		} elseif (! $adapter instanceof AwsS3Adapter) {
404
+			throw new RuntimeException('This driver does not support creating temporary URLs.');
405
+		}
406
+
407
+		$client = $adapter->getClient();
408
+
409
+		$command = $client->getCommand('GetObject', array_merge([
410
+			'Bucket' => $adapter->getBucket(),
411
+			'Key' => $adapter->getPathPrefix().$path,
412
+		], $options));
413
+
414
+		return (string) $client->createPresignedRequest(
415
+			$command, $expiration
416
+		)->getUri();
417
+	}
418
+
419
+	/**
420
+	 * Get an array of all files in a directory.
421
+	 *
422
+	 * @param  string|null  $directory
423
+	 * @param  bool  $recursive
424
+	 * @return array
425
+	 */
426
+	public function files($directory = null, $recursive = false)
427
+	{
428
+		$contents = $this->driver->listContents($directory, $recursive);
429
+
430
+		return $this->filterContentsByType($contents, 'file');
431
+	}
432
+
433
+	/**
434
+	 * Get all of the files from the given directory (recursive).
435
+	 *
436
+	 * @param  string|null  $directory
437
+	 * @return array
438
+	 */
439
+	public function allFiles($directory = null)
440
+	{
441
+		return $this->files($directory, true);
442
+	}
443
+
444
+	/**
445
+	 * Get all of the directories within a given directory.
446
+	 *
447
+	 * @param  string|null  $directory
448
+	 * @param  bool  $recursive
449
+	 * @return array
450
+	 */
451
+	public function directories($directory = null, $recursive = false)
452
+	{
453
+		$contents = $this->driver->listContents($directory, $recursive);
454
+
455
+		return $this->filterContentsByType($contents, 'dir');
456
+	}
457
+
458
+	/**
459
+	 * Get all (recursive) of the directories within a given directory.
460
+	 *
461
+	 * @param  string|null  $directory
462
+	 * @return array
463
+	 */
464
+	public function allDirectories($directory = null)
465
+	{
466
+		return $this->directories($directory, true);
467
+	}
468
+
469
+	/**
470
+	 * Create a directory.
471
+	 *
472
+	 * @param  string  $path
473
+	 * @return bool
474
+	 */
475
+	public function makeDirectory($path)
476
+	{
477
+		return $this->driver->createDir($path);
478
+	}
479
+
480
+	/**
481
+	 * Recursively delete a directory.
482
+	 *
483
+	 * @param  string  $directory
484
+	 * @return bool
485
+	 */
486
+	public function deleteDirectory($directory)
487
+	{
488
+		return $this->driver->deleteDir($directory);
489
+	}
490
+
491
+	/**
492
+	 * Get the Flysystem driver.
493
+	 *
494
+	 * @return \League\Flysystem\FilesystemInterface
495
+	 */
496
+	public function getDriver()
497
+	{
498
+		return $this->driver;
499
+	}
500
+
501
+	/**
502
+	 * Filter directory contents by type.
503
+	 *
504
+	 * @param  array  $contents
505
+	 * @param  string  $type
506
+	 * @return array
507
+	 */
508
+	protected function filterContentsByType($contents, $type)
509
+	{
510
+		return Collection::make($contents)
511
+			->where('type', $type)
512
+			->pluck('path')
513
+			->values()
514
+			->all();
515
+	}
516
+
517
+	/**
518
+	 * Parse the given visibility value.
519
+	 *
520
+	 * @param  string|null  $visibility
521
+	 * @return string|null
522
+	 *
523
+	 * @throws \InvalidArgumentException
524
+	 */
525
+	protected function parseVisibility($visibility)
526
+	{
527
+		if (is_null($visibility)) {
528
+			return;
529
+		}
530
+
531
+		switch ($visibility) {
532
+			case FilesystemContract::VISIBILITY_PUBLIC:
533
+				return AdapterInterface::VISIBILITY_PUBLIC;
534
+			case FilesystemContract::VISIBILITY_PRIVATE:
535
+				return AdapterInterface::VISIBILITY_PRIVATE;
536
+		}
537
+
538
+		throw new InvalidArgumentException('Unknown visibility: '.$visibility);
539
+	}
540
+
541
+	/**
542
+	 * Pass dynamic methods call onto Flysystem.
543
+	 *
544
+	 * @param  string  $method
545
+	 * @param  array  $parameters
546
+	 * @return mixed
547
+	 *
548
+	 * @throws \BadMethodCallException
549
+	 */
550
+	public function __call($method, array $parameters)
551
+	{
552
+		return call_user_func_array([$this->driver, $method], $parameters);
553
+	}
554 554
 }
Please login to merge, or discard this patch.
Spacing   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      * @param  \League\Flysystem\FilesystemInterface  $driver
43 43
      * @return void
44 44
      */
45
-    public function __construct(FilesystemInterface $driver)
45
+    public function __construct( FilesystemInterface $driver )
46 46
     {
47 47
         $this->driver = $driver;
48 48
     }
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
      * @param  string  $path
54 54
      * @return void
55 55
      */
56
-    public function assertExists($path)
56
+    public function assertExists( $path )
57 57
     {
58 58
         PHPUnit::assertTrue(
59
-            $this->exists($path), "Unable to find a file at path [{$path}]."
59
+            $this->exists( $path ), "Unable to find a file at path [{$path}]."
60 60
         );
61 61
     }
62 62
 
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
      * @param  string  $path
67 67
      * @return void
68 68
      */
69
-    public function assertMissing($path)
69
+    public function assertMissing( $path )
70 70
     {
71 71
         PHPUnit::assertFalse(
72
-            $this->exists($path), "Found unexpected file at path [{$path}]."
72
+            $this->exists( $path ), "Found unexpected file at path [{$path}]."
73 73
         );
74 74
     }
75 75
 
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
      * @param  string  $path
80 80
      * @return bool
81 81
      */
82
-    public function exists($path)
82
+    public function exists( $path )
83 83
     {
84
-        return $this->driver->has($path);
84
+        return $this->driver->has( $path );
85 85
     }
86 86
 
87 87
     /**
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
      * @param  string  $path
91 91
      * @return string
92 92
      */
93
-    public function path($path)
93
+    public function path( $path )
94 94
     {
95
-        return $this->driver->getAdapter()->getPathPrefix().$path;
95
+        return $this->driver->getAdapter()->getPathPrefix() . $path;
96 96
     }
97 97
 
98 98
     /**
@@ -103,12 +103,12 @@  discard block
 block discarded – undo
103 103
      *
104 104
      * @throws \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Contracts\Filesystem\FileNotFoundException
105 105
      */
106
-    public function get($path)
106
+    public function get( $path )
107 107
     {
108 108
         try {
109
-            return $this->driver->read($path);
110
-        } catch (FileNotFoundException $e) {
111
-            throw new ContractFileNotFoundException($path, $e->getCode(), $e);
109
+            return $this->driver->read( $path );
110
+        } catch ( FileNotFoundException $e ) {
111
+            throw new ContractFileNotFoundException( $path, $e->getCode(), $e );
112 112
         }
113 113
     }
114 114
 
@@ -120,23 +120,23 @@  discard block
 block discarded – undo
120 120
      * @param  array  $options
121 121
      * @return bool
122 122
      */
123
-    public function put($path, $contents, $options = [])
123
+    public function put( $path, $contents, $options = [ ] )
124 124
     {
125
-        if (is_string($options)) {
126
-            $options = ['visibility' => $options];
125
+        if ( is_string( $options ) ) {
126
+            $options = [ 'visibility' => $options ];
127 127
         }
128 128
 
129 129
         // If the given contents is actually a file or uploaded file instance than we will
130 130
         // automatically store the file using a stream. This provides a convenient path
131 131
         // for the developer to store streams without managing them manually in code.
132
-        if ($contents instanceof File ||
133
-            $contents instanceof UploadedFile) {
134
-            return $this->putFile($path, $contents, $options);
132
+        if ( $contents instanceof File ||
133
+            $contents instanceof UploadedFile ) {
134
+            return $this->putFile( $path, $contents, $options );
135 135
         }
136 136
 
137
-        return is_resource($contents)
138
-                ? $this->driver->putStream($path, $contents, $options)
139
-                : $this->driver->put($path, $contents, $options);
137
+        return is_resource( $contents )
138
+                ? $this->driver->putStream( $path, $contents, $options )
139
+                : $this->driver->put( $path, $contents, $options );
140 140
     }
141 141
 
142 142
     /**
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
      * @param  array  $options
148 148
      * @return string|false
149 149
      */
150
-    public function putFile($path, $file, $options = [])
150
+    public function putFile( $path, $file, $options = [ ] )
151 151
     {
152
-        return $this->putFileAs($path, $file, $file->hashName(), $options);
152
+        return $this->putFileAs( $path, $file, $file->hashName(), $options );
153 153
     }
154 154
 
155 155
     /**
@@ -161,19 +161,19 @@  discard block
 block discarded – undo
161 161
      * @param  array  $options
162 162
      * @return string|false
163 163
      */
164
-    public function putFileAs($path, $file, $name, $options = [])
164
+    public function putFileAs( $path, $file, $name, $options = [ ] )
165 165
     {
166
-        $stream = fopen($file->getRealPath(), 'r+');
166
+        $stream = fopen( $file->getRealPath(), 'r+' );
167 167
 
168 168
         // Next, we will format the path of the file and store the file using a stream since
169 169
         // they provide better performance than alternatives. Once we write the file this
170 170
         // stream will get closed automatically by us so the developer doesn't have to.
171 171
         $result = $this->put(
172
-            $path = trim($path.'/'.$name, '/'), $stream, $options
172
+            $path = trim( $path . '/' . $name, '/' ), $stream, $options
173 173
         );
174 174
 
175
-        if (is_resource($stream)) {
176
-            fclose($stream);
175
+        if ( is_resource( $stream ) ) {
176
+            fclose( $stream );
177 177
         }
178 178
 
179 179
         return $result ? $path : false;
@@ -185,9 +185,9 @@  discard block
 block discarded – undo
185 185
      * @param  string  $path
186 186
      * @return string
187 187
      */
188
-    public function getVisibility($path)
188
+    public function getVisibility( $path )
189 189
     {
190
-        if ($this->driver->getVisibility($path) == AdapterInterface::VISIBILITY_PUBLIC) {
190
+        if ( $this->driver->getVisibility( $path ) == AdapterInterface::VISIBILITY_PUBLIC ) {
191 191
             return FilesystemContract::VISIBILITY_PUBLIC;
192 192
         }
193 193
 
@@ -201,9 +201,9 @@  discard block
 block discarded – undo
201 201
      * @param  string  $visibility
202 202
      * @return void
203 203
      */
204
-    public function setVisibility($path, $visibility)
204
+    public function setVisibility( $path, $visibility )
205 205
     {
206
-        return $this->driver->setVisibility($path, $this->parseVisibility($visibility));
206
+        return $this->driver->setVisibility( $path, $this->parseVisibility( $visibility ) );
207 207
     }
208 208
 
209 209
     /**
@@ -214,13 +214,13 @@  discard block
 block discarded – undo
214 214
      * @param  string  $separator
215 215
      * @return int
216 216
      */
217
-    public function prepend($path, $data, $separator = PHP_EOL)
217
+    public function prepend( $path, $data, $separator = PHP_EOL )
218 218
     {
219
-        if ($this->exists($path)) {
220
-            return $this->put($path, $data.$separator.$this->get($path));
219
+        if ( $this->exists( $path ) ) {
220
+            return $this->put( $path, $data . $separator . $this->get( $path ) );
221 221
         }
222 222
 
223
-        return $this->put($path, $data);
223
+        return $this->put( $path, $data );
224 224
     }
225 225
 
226 226
     /**
@@ -231,13 +231,13 @@  discard block
 block discarded – undo
231 231
      * @param  string  $separator
232 232
      * @return int
233 233
      */
234
-    public function append($path, $data, $separator = PHP_EOL)
234
+    public function append( $path, $data, $separator = PHP_EOL )
235 235
     {
236
-        if ($this->exists($path)) {
237
-            return $this->put($path, $this->get($path).$separator.$data);
236
+        if ( $this->exists( $path ) ) {
237
+            return $this->put( $path, $this->get( $path ) . $separator . $data );
238 238
         }
239 239
 
240
-        return $this->put($path, $data);
240
+        return $this->put( $path, $data );
241 241
     }
242 242
 
243 243
     /**
@@ -246,18 +246,18 @@  discard block
 block discarded – undo
246 246
      * @param  string|array  $paths
247 247
      * @return bool
248 248
      */
249
-    public function delete($paths)
249
+    public function delete( $paths )
250 250
     {
251
-        $paths = is_array($paths) ? $paths : func_get_args();
251
+        $paths = is_array( $paths ) ? $paths : func_get_args();
252 252
 
253 253
         $success = true;
254 254
 
255
-        foreach ($paths as $path) {
255
+        foreach ( $paths as $path ) {
256 256
             try {
257
-                if (! $this->driver->delete($path)) {
257
+                if ( ! $this->driver->delete( $path ) ) {
258 258
                     $success = false;
259 259
                 }
260
-            } catch (FileNotFoundException $e) {
260
+            } catch ( FileNotFoundException $e ) {
261 261
                 $success = false;
262 262
             }
263 263
         }
@@ -272,9 +272,9 @@  discard block
 block discarded – undo
272 272
      * @param  string  $to
273 273
      * @return bool
274 274
      */
275
-    public function copy($from, $to)
275
+    public function copy( $from, $to )
276 276
     {
277
-        return $this->driver->copy($from, $to);
277
+        return $this->driver->copy( $from, $to );
278 278
     }
279 279
 
280 280
     /**
@@ -284,9 +284,9 @@  discard block
 block discarded – undo
284 284
      * @param  string  $to
285 285
      * @return bool
286 286
      */
287
-    public function move($from, $to)
287
+    public function move( $from, $to )
288 288
     {
289
-        return $this->driver->rename($from, $to);
289
+        return $this->driver->rename( $from, $to );
290 290
     }
291 291
 
292 292
     /**
@@ -295,9 +295,9 @@  discard block
 block discarded – undo
295 295
      * @param  string  $path
296 296
      * @return int
297 297
      */
298
-    public function size($path)
298
+    public function size( $path )
299 299
     {
300
-        return $this->driver->getSize($path);
300
+        return $this->driver->getSize( $path );
301 301
     }
302 302
 
303 303
     /**
@@ -306,9 +306,9 @@  discard block
 block discarded – undo
306 306
      * @param  string  $path
307 307
      * @return string|false
308 308
      */
309
-    public function mimeType($path)
309
+    public function mimeType( $path )
310 310
     {
311
-        return $this->driver->getMimetype($path);
311
+        return $this->driver->getMimetype( $path );
312 312
     }
313 313
 
314 314
     /**
@@ -317,9 +317,9 @@  discard block
 block discarded – undo
317 317
      * @param  string  $path
318 318
      * @return int
319 319
      */
320
-    public function lastModified($path)
320
+    public function lastModified( $path )
321 321
     {
322
-        return $this->driver->getTimestamp($path);
322
+        return $this->driver->getTimestamp( $path );
323 323
     }
324 324
 
325 325
     /**
@@ -328,18 +328,18 @@  discard block
 block discarded – undo
328 328
      * @param  string  $path
329 329
      * @return string
330 330
      */
331
-    public function url($path)
331
+    public function url( $path )
332 332
     {
333 333
         $adapter = $this->driver->getAdapter();
334 334
 
335
-        if (method_exists($adapter, 'getUrl')) {
336
-            return $adapter->getUrl($path);
337
-        } elseif ($adapter instanceof AwsS3Adapter) {
338
-            return $this->getAwsUrl($adapter, $path);
339
-        } elseif ($adapter instanceof LocalAdapter) {
340
-            return $this->getLocalUrl($path);
335
+        if ( method_exists( $adapter, 'getUrl' ) ) {
336
+            return $adapter->getUrl( $path );
337
+        } elseif ( $adapter instanceof AwsS3Adapter ) {
338
+            return $this->getAwsUrl( $adapter, $path );
339
+        } elseif ( $adapter instanceof LocalAdapter ) {
340
+            return $this->getLocalUrl( $path );
341 341
         } else {
342
-            throw new RuntimeException('This driver does not support retrieving URLs.');
342
+            throw new RuntimeException( 'This driver does not support retrieving URLs.' );
343 343
         }
344 344
     }
345 345
 
@@ -350,10 +350,10 @@  discard block
 block discarded – undo
350 350
      * @param  string  $path
351 351
      * @return string
352 352
      */
353
-    protected function getAwsUrl($adapter, $path)
353
+    protected function getAwsUrl( $adapter, $path )
354 354
     {
355 355
         return $adapter->getClient()->getObjectUrl(
356
-            $adapter->getBucket(), $adapter->getPathPrefix().$path
356
+            $adapter->getBucket(), $adapter->getPathPrefix() . $path
357 357
         );
358 358
     }
359 359
 
@@ -363,24 +363,24 @@  discard block
 block discarded – undo
363 363
      * @param  string  $path
364 364
      * @return string
365 365
      */
366
-    protected function getLocalUrl($path)
366
+    protected function getLocalUrl( $path )
367 367
     {
368 368
         $config = $this->driver->getConfig();
369 369
 
370 370
         // If an explicit base URL has been set on the disk configuration then we will use
371 371
         // it as the base URL instead of the default path. This allows the developer to
372 372
         // have full control over the base path for this filesystem's generated URLs.
373
-        if ($config->has('url')) {
374
-            return rtrim($config->get('url'), '/').'/'.ltrim($path, '/');
373
+        if ( $config->has( 'url' ) ) {
374
+            return rtrim( $config->get( 'url' ), '/' ) . '/' . ltrim( $path, '/' );
375 375
         }
376 376
 
377
-        $path = '/storage/'.$path;
377
+        $path = '/storage/' . $path;
378 378
 
379 379
         // If the path contains "storage/public", it probably means the developer is using
380 380
         // the default disk to generate the path instead of the "public" disk like they
381 381
         // are really supposed to use. We will remove the public from this path here.
382
-        if (Str::contains($path, '/storage/public/')) {
383
-            return Str::replaceFirst('/public/', '/', $path);
382
+        if ( Str::contains( $path, '/storage/public/' ) ) {
383
+            return Str::replaceFirst( '/public/', '/', $path );
384 384
         } else {
385 385
             return $path;
386 386
         }
@@ -394,24 +394,24 @@  discard block
 block discarded – undo
394 394
      * @param  array  $options
395 395
      * @return string
396 396
      */
397
-    public function temporaryUrl($path, $expiration, array $options = [])
397
+    public function temporaryUrl( $path, $expiration, array $options = [ ] )
398 398
     {
399 399
         $adapter = $this->driver->getAdapter();
400 400
 
401
-        if (method_exists($adapter, 'getTemporaryUrl')) {
402
-            return $adapter->getTemporaryUrl($path, $expiration, $options);
403
-        } elseif (! $adapter instanceof AwsS3Adapter) {
404
-            throw new RuntimeException('This driver does not support creating temporary URLs.');
401
+        if ( method_exists( $adapter, 'getTemporaryUrl' ) ) {
402
+            return $adapter->getTemporaryUrl( $path, $expiration, $options );
403
+        } elseif ( ! $adapter instanceof AwsS3Adapter ) {
404
+            throw new RuntimeException( 'This driver does not support creating temporary URLs.' );
405 405
         }
406 406
 
407 407
         $client = $adapter->getClient();
408 408
 
409
-        $command = $client->getCommand('GetObject', array_merge([
409
+        $command = $client->getCommand( 'GetObject', array_merge( [
410 410
             'Bucket' => $adapter->getBucket(),
411
-            'Key' => $adapter->getPathPrefix().$path,
412
-        ], $options));
411
+            'Key' => $adapter->getPathPrefix() . $path,
412
+        ], $options ) );
413 413
 
414
-        return (string) $client->createPresignedRequest(
414
+        return (string)$client->createPresignedRequest(
415 415
             $command, $expiration
416 416
         )->getUri();
417 417
     }
@@ -423,11 +423,11 @@  discard block
 block discarded – undo
423 423
      * @param  bool  $recursive
424 424
      * @return array
425 425
      */
426
-    public function files($directory = null, $recursive = false)
426
+    public function files( $directory = null, $recursive = false )
427 427
     {
428
-        $contents = $this->driver->listContents($directory, $recursive);
428
+        $contents = $this->driver->listContents( $directory, $recursive );
429 429
 
430
-        return $this->filterContentsByType($contents, 'file');
430
+        return $this->filterContentsByType( $contents, 'file' );
431 431
     }
432 432
 
433 433
     /**
@@ -436,9 +436,9 @@  discard block
 block discarded – undo
436 436
      * @param  string|null  $directory
437 437
      * @return array
438 438
      */
439
-    public function allFiles($directory = null)
439
+    public function allFiles( $directory = null )
440 440
     {
441
-        return $this->files($directory, true);
441
+        return $this->files( $directory, true );
442 442
     }
443 443
 
444 444
     /**
@@ -448,11 +448,11 @@  discard block
 block discarded – undo
448 448
      * @param  bool  $recursive
449 449
      * @return array
450 450
      */
451
-    public function directories($directory = null, $recursive = false)
451
+    public function directories( $directory = null, $recursive = false )
452 452
     {
453
-        $contents = $this->driver->listContents($directory, $recursive);
453
+        $contents = $this->driver->listContents( $directory, $recursive );
454 454
 
455
-        return $this->filterContentsByType($contents, 'dir');
455
+        return $this->filterContentsByType( $contents, 'dir' );
456 456
     }
457 457
 
458 458
     /**
@@ -461,9 +461,9 @@  discard block
 block discarded – undo
461 461
      * @param  string|null  $directory
462 462
      * @return array
463 463
      */
464
-    public function allDirectories($directory = null)
464
+    public function allDirectories( $directory = null )
465 465
     {
466
-        return $this->directories($directory, true);
466
+        return $this->directories( $directory, true );
467 467
     }
468 468
 
469 469
     /**
@@ -472,9 +472,9 @@  discard block
 block discarded – undo
472 472
      * @param  string  $path
473 473
      * @return bool
474 474
      */
475
-    public function makeDirectory($path)
475
+    public function makeDirectory( $path )
476 476
     {
477
-        return $this->driver->createDir($path);
477
+        return $this->driver->createDir( $path );
478 478
     }
479 479
 
480 480
     /**
@@ -483,9 +483,9 @@  discard block
 block discarded – undo
483 483
      * @param  string  $directory
484 484
      * @return bool
485 485
      */
486
-    public function deleteDirectory($directory)
486
+    public function deleteDirectory( $directory )
487 487
     {
488
-        return $this->driver->deleteDir($directory);
488
+        return $this->driver->deleteDir( $directory );
489 489
     }
490 490
 
491 491
     /**
@@ -505,11 +505,11 @@  discard block
 block discarded – undo
505 505
      * @param  string  $type
506 506
      * @return array
507 507
      */
508
-    protected function filterContentsByType($contents, $type)
508
+    protected function filterContentsByType( $contents, $type )
509 509
     {
510
-        return Collection::make($contents)
511
-            ->where('type', $type)
512
-            ->pluck('path')
510
+        return Collection::make( $contents )
511
+            ->where( 'type', $type )
512
+            ->pluck( 'path' )
513 513
             ->values()
514 514
             ->all();
515 515
     }
@@ -522,20 +522,20 @@  discard block
 block discarded – undo
522 522
      *
523 523
      * @throws \InvalidArgumentException
524 524
      */
525
-    protected function parseVisibility($visibility)
525
+    protected function parseVisibility( $visibility )
526 526
     {
527
-        if (is_null($visibility)) {
527
+        if ( is_null( $visibility ) ) {
528 528
             return;
529 529
         }
530 530
 
531
-        switch ($visibility) {
531
+        switch ( $visibility ) {
532 532
             case FilesystemContract::VISIBILITY_PUBLIC:
533 533
                 return AdapterInterface::VISIBILITY_PUBLIC;
534 534
             case FilesystemContract::VISIBILITY_PRIVATE:
535 535
                 return AdapterInterface::VISIBILITY_PRIVATE;
536 536
         }
537 537
 
538
-        throw new InvalidArgumentException('Unknown visibility: '.$visibility);
538
+        throw new InvalidArgumentException( 'Unknown visibility: ' . $visibility );
539 539
     }
540 540
 
541 541
     /**
@@ -547,8 +547,8 @@  discard block
 block discarded – undo
547 547
      *
548 548
      * @throws \BadMethodCallException
549 549
      */
550
-    public function __call($method, array $parameters)
550
+    public function __call( $method, array $parameters )
551 551
     {
552
-        return call_user_func_array([$this->driver, $method], $parameters);
552
+        return call_user_func_array( [ $this->driver, $method ], $parameters );
553 553
     }
554 554
 }
Please login to merge, or discard this patch.
Braces   +33 added lines, -66 removed lines patch added patch discarded remove patch
@@ -42,8 +42,7 @@  discard block
 block discarded – undo
42 42
      * @param  \League\Flysystem\FilesystemInterface  $driver
43 43
      * @return void
44 44
      */
45
-    public function __construct(FilesystemInterface $driver)
46
-    {
45
+    public function __construct(FilesystemInterface $driver) {
47 46
         $this->driver = $driver;
48 47
     }
49 48
 
@@ -53,8 +52,7 @@  discard block
 block discarded – undo
53 52
      * @param  string  $path
54 53
      * @return void
55 54
      */
56
-    public function assertExists($path)
57
-    {
55
+    public function assertExists($path) {
58 56
         PHPUnit::assertTrue(
59 57
             $this->exists($path), "Unable to find a file at path [{$path}]."
60 58
         );
@@ -66,8 +64,7 @@  discard block
 block discarded – undo
66 64
      * @param  string  $path
67 65
      * @return void
68 66
      */
69
-    public function assertMissing($path)
70
-    {
67
+    public function assertMissing($path) {
71 68
         PHPUnit::assertFalse(
72 69
             $this->exists($path), "Found unexpected file at path [{$path}]."
73 70
         );
@@ -79,8 +76,7 @@  discard block
 block discarded – undo
79 76
      * @param  string  $path
80 77
      * @return bool
81 78
      */
82
-    public function exists($path)
83
-    {
79
+    public function exists($path) {
84 80
         return $this->driver->has($path);
85 81
     }
86 82
 
@@ -90,8 +86,7 @@  discard block
 block discarded – undo
90 86
      * @param  string  $path
91 87
      * @return string
92 88
      */
93
-    public function path($path)
94
-    {
89
+    public function path($path) {
95 90
         return $this->driver->getAdapter()->getPathPrefix().$path;
96 91
     }
97 92
 
@@ -103,8 +98,7 @@  discard block
 block discarded – undo
103 98
      *
104 99
      * @throws \GravityKit\GravityView\Foundation\ThirdParty\Illuminate\Contracts\Filesystem\FileNotFoundException
105 100
      */
106
-    public function get($path)
107
-    {
101
+    public function get($path) {
108 102
         try {
109 103
             return $this->driver->read($path);
110 104
         } catch (FileNotFoundException $e) {
@@ -120,8 +114,7 @@  discard block
 block discarded – undo
120 114
      * @param  array  $options
121 115
      * @return bool
122 116
      */
123
-    public function put($path, $contents, $options = [])
124
-    {
117
+    public function put($path, $contents, $options = []) {
125 118
         if (is_string($options)) {
126 119
             $options = ['visibility' => $options];
127 120
         }
@@ -147,8 +140,7 @@  discard block
 block discarded – undo
147 140
      * @param  array  $options
148 141
      * @return string|false
149 142
      */
150
-    public function putFile($path, $file, $options = [])
151
-    {
143
+    public function putFile($path, $file, $options = []) {
152 144
         return $this->putFileAs($path, $file, $file->hashName(), $options);
153 145
     }
154 146
 
@@ -161,8 +153,7 @@  discard block
 block discarded – undo
161 153
      * @param  array  $options
162 154
      * @return string|false
163 155
      */
164
-    public function putFileAs($path, $file, $name, $options = [])
165
-    {
156
+    public function putFileAs($path, $file, $name, $options = []) {
166 157
         $stream = fopen($file->getRealPath(), 'r+');
167 158
 
168 159
         // Next, we will format the path of the file and store the file using a stream since
@@ -185,8 +176,7 @@  discard block
 block discarded – undo
185 176
      * @param  string  $path
186 177
      * @return string
187 178
      */
188
-    public function getVisibility($path)
189
-    {
179
+    public function getVisibility($path) {
190 180
         if ($this->driver->getVisibility($path) == AdapterInterface::VISIBILITY_PUBLIC) {
191 181
             return FilesystemContract::VISIBILITY_PUBLIC;
192 182
         }
@@ -201,8 +191,7 @@  discard block
 block discarded – undo
201 191
      * @param  string  $visibility
202 192
      * @return void
203 193
      */
204
-    public function setVisibility($path, $visibility)
205
-    {
194
+    public function setVisibility($path, $visibility) {
206 195
         return $this->driver->setVisibility($path, $this->parseVisibility($visibility));
207 196
     }
208 197
 
@@ -214,8 +203,7 @@  discard block
 block discarded – undo
214 203
      * @param  string  $separator
215 204
      * @return int
216 205
      */
217
-    public function prepend($path, $data, $separator = PHP_EOL)
218
-    {
206
+    public function prepend($path, $data, $separator = PHP_EOL) {
219 207
         if ($this->exists($path)) {
220 208
             return $this->put($path, $data.$separator.$this->get($path));
221 209
         }
@@ -231,8 +219,7 @@  discard block
 block discarded – undo
231 219
      * @param  string  $separator
232 220
      * @return int
233 221
      */
234
-    public function append($path, $data, $separator = PHP_EOL)
235
-    {
222
+    public function append($path, $data, $separator = PHP_EOL) {
236 223
         if ($this->exists($path)) {
237 224
             return $this->put($path, $this->get($path).$separator.$data);
238 225
         }
@@ -246,8 +233,7 @@  discard block
 block discarded – undo
246 233
      * @param  string|array  $paths
247 234
      * @return bool
248 235
      */
249
-    public function delete($paths)
250
-    {
236
+    public function delete($paths) {
251 237
         $paths = is_array($paths) ? $paths : func_get_args();
252 238
 
253 239
         $success = true;
@@ -272,8 +258,7 @@  discard block
 block discarded – undo
272 258
      * @param  string  $to
273 259
      * @return bool
274 260
      */
275
-    public function copy($from, $to)
276
-    {
261
+    public function copy($from, $to) {
277 262
         return $this->driver->copy($from, $to);
278 263
     }
279 264
 
@@ -284,8 +269,7 @@  discard block
 block discarded – undo
284 269
      * @param  string  $to
285 270
      * @return bool
286 271
      */
287
-    public function move($from, $to)
288
-    {
272
+    public function move($from, $to) {
289 273
         return $this->driver->rename($from, $to);
290 274
     }
291 275
 
@@ -295,8 +279,7 @@  discard block
 block discarded – undo
295 279
      * @param  string  $path
296 280
      * @return int
297 281
      */
298
-    public function size($path)
299
-    {
282
+    public function size($path) {
300 283
         return $this->driver->getSize($path);
301 284
     }
302 285
 
@@ -306,8 +289,7 @@  discard block
 block discarded – undo
306 289
      * @param  string  $path
307 290
      * @return string|false
308 291
      */
309
-    public function mimeType($path)
310
-    {
292
+    public function mimeType($path) {
311 293
         return $this->driver->getMimetype($path);
312 294
     }
313 295
 
@@ -317,8 +299,7 @@  discard block
 block discarded – undo
317 299
      * @param  string  $path
318 300
      * @return int
319 301
      */
320
-    public function lastModified($path)
321
-    {
302
+    public function lastModified($path) {
322 303
         return $this->driver->getTimestamp($path);
323 304
     }
324 305
 
@@ -328,8 +309,7 @@  discard block
 block discarded – undo
328 309
      * @param  string  $path
329 310
      * @return string
330 311
      */
331
-    public function url($path)
332
-    {
312
+    public function url($path) {
333 313
         $adapter = $this->driver->getAdapter();
334 314
 
335 315
         if (method_exists($adapter, 'getUrl')) {
@@ -350,8 +330,7 @@  discard block
 block discarded – undo
350 330
      * @param  string  $path
351 331
      * @return string
352 332
      */
353
-    protected function getAwsUrl($adapter, $path)
354
-    {
333
+    protected function getAwsUrl($adapter, $path) {
355 334
         return $adapter->getClient()->getObjectUrl(
356 335
             $adapter->getBucket(), $adapter->getPathPrefix().$path
357 336
         );
@@ -363,8 +342,7 @@  discard block
 block discarded – undo
363 342
      * @param  string  $path
364 343
      * @return string
365 344
      */
366
-    protected function getLocalUrl($path)
367
-    {
345
+    protected function getLocalUrl($path) {
368 346
         $config = $this->driver->getConfig();
369 347
 
370 348
         // If an explicit base URL has been set on the disk configuration then we will use
@@ -394,8 +372,7 @@  discard block
 block discarded – undo
394 372
      * @param  array  $options
395 373
      * @return string
396 374
      */
397
-    public function temporaryUrl($path, $expiration, array $options = [])
398
-    {
375
+    public function temporaryUrl($path, $expiration, array $options = []) {
399 376
         $adapter = $this->driver->getAdapter();
400 377
 
401 378
         if (method_exists($adapter, 'getTemporaryUrl')) {
@@ -423,8 +400,7 @@  discard block
 block discarded – undo
423 400
      * @param  bool  $recursive
424 401
      * @return array
425 402
      */
426
-    public function files($directory = null, $recursive = false)
427
-    {
403
+    public function files($directory = null, $recursive = false) {
428 404
         $contents = $this->driver->listContents($directory, $recursive);
429 405
 
430 406
         return $this->filterContentsByType($contents, 'file');
@@ -436,8 +412,7 @@  discard block
 block discarded – undo
436 412
      * @param  string|null  $directory
437 413
      * @return array
438 414
      */
439
-    public function allFiles($directory = null)
440
-    {
415
+    public function allFiles($directory = null) {
441 416
         return $this->files($directory, true);
442 417
     }
443 418
 
@@ -448,8 +423,7 @@  discard block
 block discarded – undo
448 423
      * @param  bool  $recursive
449 424
      * @return array
450 425
      */
451
-    public function directories($directory = null, $recursive = false)
452
-    {
426
+    public function directories($directory = null, $recursive = false) {
453 427
         $contents = $this->driver->listContents($directory, $recursive);
454 428
 
455 429
         return $this->filterContentsByType($contents, 'dir');
@@ -461,8 +435,7 @@  discard block
 block discarded – undo
461 435
      * @param  string|null  $directory
462 436
      * @return array
463 437
      */
464
-    public function allDirectories($directory = null)
465
-    {
438
+    public function allDirectories($directory = null) {
466 439
         return $this->directories($directory, true);
467 440
     }
468 441
 
@@ -472,8 +445,7 @@  discard block
 block discarded – undo
472 445
      * @param  string  $path
473 446
      * @return bool
474 447
      */
475
-    public function makeDirectory($path)
476
-    {
448
+    public function makeDirectory($path) {
477 449
         return $this->driver->createDir($path);
478 450
     }
479 451
 
@@ -483,8 +455,7 @@  discard block
 block discarded – undo
483 455
      * @param  string  $directory
484 456
      * @return bool
485 457
      */
486
-    public function deleteDirectory($directory)
487
-    {
458
+    public function deleteDirectory($directory) {
488 459
         return $this->driver->deleteDir($directory);
489 460
     }
490 461
 
@@ -493,8 +464,7 @@  discard block
 block discarded – undo
493 464
      *
494 465
      * @return \League\Flysystem\FilesystemInterface
495 466
      */
496
-    public function getDriver()
497
-    {
467
+    public function getDriver() {
498 468
         return $this->driver;
499 469
     }
500 470
 
@@ -505,8 +475,7 @@  discard block
 block discarded – undo
505 475
      * @param  string  $type
506 476
      * @return array
507 477
      */
508
-    protected function filterContentsByType($contents, $type)
509
-    {
478
+    protected function filterContentsByType($contents, $type) {
510 479
         return Collection::make($contents)
511 480
             ->where('type', $type)
512 481
             ->pluck('path')
@@ -522,8 +491,7 @@  discard block
 block discarded – undo
522 491
      *
523 492
      * @throws \InvalidArgumentException
524 493
      */
525
-    protected function parseVisibility($visibility)
526
-    {
494
+    protected function parseVisibility($visibility) {
527 495
         if (is_null($visibility)) {
528 496
             return;
529 497
         }
@@ -547,8 +515,7 @@  discard block
 block discarded – undo
547 515
      *
548 516
      * @throws \BadMethodCallException
549 517
      */
550
-    public function __call($method, array $parameters)
551
-    {
518
+    public function __call($method, array $parameters) {
552 519
         return call_user_func_array([$this->driver, $method], $parameters);
553 520
     }
554 521
 }
Please login to merge, or discard this patch.