Skip to content

Commit d237c97

Browse files
authored
Merge pull request #10 from mikehaertl/fix-codingstyle
Fix coding style
2 parents fb91ddb + 9d18d2c commit d237c97

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

src/File.php

+21-14
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77
* A convenience class for temporary files.
88
*
99
* @author Michael Härtl <[email protected]>
10-
* @version 1.1.0
1110
* @license http://www.opensource.org/licenses/MIT
1211
*/
1312
class File
1413
{
1514
/**
16-
* @var bool whether to delete the tmp file when it's no longer referenced or when the request ends.
17-
* Default is `true`.
15+
* @var bool whether to delete the tmp file when it's no longer referenced
16+
* or when the request ends. Default is `true`.
1817
*/
1918
public $delete = true;
2019

@@ -28,22 +27,24 @@ class File
2827
*
2928
* @param string $content the tmp file content
3029
* @param string|null $suffix the optional suffix for the tmp file
31-
* @param string|null $prefix the optional prefix for the tmp file. If null 'php_tmpfile_' is used.
32-
* @param string|null $directory directory where the file should be created. Autodetected if not provided.
30+
* @param string|null $prefix the optional prefix for the tmp file. If null
31+
* 'php_tmpfile_' is used.
32+
* @param string|null $directory directory where the file should be
33+
* created. Autodetected if not provided.
3334
*/
3435
public function __construct($content, $suffix = null, $prefix = null, $directory = null)
3536
{
36-
if ($directory===null) {
37+
if ($directory === null) {
3738
$directory = self::getTempDir();
3839
}
3940

40-
if ($prefix===null) {
41+
if ($prefix === null) {
4142
$prefix = 'php_tmpfile_';
4243
}
4344

4445
$this->_fileName = tempnam($directory,$prefix);
45-
if ($suffix!==null) {
46-
$newName = $this->_fileName.$suffix;
46+
if ($suffix !== null) {
47+
$newName = $this->_fileName . $suffix;
4748
rename($this->_fileName, $newName);
4849
$this->_fileName = $newName;
4950
}
@@ -63,9 +64,11 @@ public function __destruct()
6364
/**
6465
* Send tmp file to client, either inline or as download
6566
*
66-
* @param string|null $filename the filename to send. If empty, the file is streamed inline.
67+
* @param string|null $filename the filename to send. If empty, the file is
68+
* streamed inline.
6769
* @param string $contentType the Content-Type header
68-
* @param bool $inline whether to force inline display of the file, even if filename is present.
70+
* @param bool $inline whether to force inline display of the file, even if
71+
* filename is present.
6972
*/
7073
public function send($filename = null, $contentType, $inline = false)
7174
{
@@ -78,10 +81,10 @@ public function send($filename = null, $contentType, $inline = false)
7881
// #84: Content-Length leads to "network connection was lost" on iOS
7982
$isIOS = preg_match('/i(phone|pad|pod)/i', $_SERVER['HTTP_USER_AGENT']);
8083
if (!$isIOS) {
81-
header('Content-Length: '.filesize($this->_fileName));
84+
header('Content-Length: ' . filesize($this->_fileName));
8285
}
8386

84-
if ($filename!==null || $inline) {
87+
if ($filename !== null || $inline) {
8588
$disposition = $inline ? 'inline' : 'attachment';
8689
header(
8790
'Content-Disposition: ' . $disposition .
@@ -117,7 +120,11 @@ public static function getTempDir()
117120
{
118121
if (function_exists('sys_get_temp_dir')) {
119122
return sys_get_temp_dir();
120-
} elseif ( ($tmp = getenv('TMP')) || ($tmp = getenv('TEMP')) || ($tmp = getenv('TMPDIR')) ) {
123+
} elseif (
124+
($tmp = getenv('TMP')) ||
125+
($tmp = getenv('TEMP')) ||
126+
($tmp = getenv('TMPDIR'))
127+
) {
121128
return realpath($tmp);
122129
} else {
123130
return '/tmp';

0 commit comments

Comments
 (0)