@@ -41,6 +41,9 @@ discard block |
||
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
44 | + /** |
|
45 | + * @param string $path |
|
46 | + */ |
|
44 | 47 | private function getFileSizeWindows($path) |
45 | 48 | { |
46 | 49 | $escapedPath = escapeshellarg($path); |
@@ -52,6 +55,9 @@ discard block |
||
52 | 55 | } |
53 | 56 | } |
54 | 57 | |
58 | + /** |
|
59 | + * @param string $path |
|
60 | + */ |
|
55 | 61 | private function getFileSizeLinux($path) |
56 | 62 | { |
57 | 63 | $escapedPath = escapeshellarg($path); |
@@ -63,6 +69,9 @@ discard block |
||
63 | 69 | } |
64 | 70 | } |
65 | 71 | |
72 | + /** |
|
73 | + * @param string $path |
|
74 | + */ |
|
66 | 75 | private function getFileSizeMac($path) |
67 | 76 | { |
68 | 77 | $escapedPath = escapeshellarg($path); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | throw new PrerequisiteException("Exec function is disabled"); |
17 | 17 | } |
18 | 18 | |
19 | - if(strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { |
|
19 | + if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { |
|
20 | 20 | $this->os = self::OS_WINDOWS; |
21 | 21 | } elseif (strtoupper(PHP_OS) == "DARWIN") { |
22 | 22 | $this->os = self::OS_MAC; |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function getFileSize($path) |
35 | 35 | { |
36 | - switch($this->os) { |
|
36 | + switch ($this->os) { |
|
37 | 37 | case self::OS_WINDOWS: return $this->getFileSizeWindows($path); break; |
38 | 38 | case self::OS_LINUX: return $this->getFileSizeLinux($path); break; |
39 | 39 | case self::OS_MAC: return $this->getFileSizeMac($path); break; |
@@ -76,7 +76,7 @@ |
||
76 | 76 | /** |
77 | 77 | * Moves file to new location / rename |
78 | 78 | * @param string $destination path |
79 | - * @return bool |
|
79 | + * @return boolean|null |
|
80 | 80 | * @throws Exception |
81 | 81 | */ |
82 | 82 | function move($destination) |
@@ -66,7 +66,7 @@ |
||
66 | 66 | // $readable = is_readable($file); // does not always return correct value for directories |
67 | 67 | |
68 | 68 | $fp = @fopen($this->path, "r"); // must be file and must be readable |
69 | - if($fp) { |
|
69 | + if ($fp) { |
|
70 | 70 | fclose($fp); |
71 | 71 | return true; |
72 | 72 | } |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | require '../vendor/autoload.php'; |
4 | -echo $f = BigFileTools::fromPath(__FILE__)->getSize()." bytes"; |
|
5 | 4 | \ No newline at end of file |
5 | +echo $f = BigFileTools::fromPath(__FILE__)->getSize() . " bytes"; |
|
6 | 6 | \ No newline at end of file |
@@ -22,8 +22,9 @@ |
||
22 | 22 | { |
23 | 23 | // Use the Windows COM interface |
24 | 24 | $fsobj = new \COM('Scripting.FileSystemObject'); |
25 | - if (dirname($path) == '.') |
|
26 | - $this->path = ((substr(getcwd(), -1) == DIRECTORY_SEPARATOR) ? getcwd() . basename($path) : getcwd() . DIRECTORY_SEPARATOR . basename($path)); |
|
25 | + if (dirname($path) == '.') { |
|
26 | + $this->path = ((substr(getcwd(), -1) == DIRECTORY_SEPARATOR) ? getcwd() . basename($path) : getcwd() . DIRECTORY_SEPARATOR . basename($path)); |
|
27 | + } |
|
27 | 28 | $f = $fsobj->GetFile($path); |
28 | 29 | return BigInteger::of($f->Size); |
29 | 30 | } |
@@ -32,15 +32,15 @@ |
||
32 | 32 | // TODO: There is *hope* that ftell() or fseek() fails when file is over 4GB |
33 | 33 | // TODO: This really needs tests, any ideas how to test this in CI? (please let me know) |
34 | 34 | |
35 | - if($flockResult === false) { |
|
35 | + if ($flockResult === false) { |
|
36 | 36 | throw new Exception("Couldn't get file lock. Operation abandoned."); |
37 | 37 | } |
38 | 38 | |
39 | - if($seekResult !== 0) { |
|
39 | + if ($seekResult !== 0) { |
|
40 | 40 | throw new Exception("Seeking to end of file failed"); |
41 | 41 | } |
42 | 42 | |
43 | - if($position === false) { |
|
43 | + if ($position === false) { |
|
44 | 44 | throw new Exception("Cannot determine position in file. ftell() failed."); |
45 | 45 | } |
46 | 46 |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Created by PhpStorm. |
|
4 | - * User: jkuchar1 |
|
5 | - * Date: 31.1.2016 |
|
6 | - * Time: 16:49 |
|
7 | - */ |
|
3 | + * Created by PhpStorm. |
|
4 | + * User: jkuchar1 |
|
5 | + * Date: 31.1.2016 |
|
6 | + * Time: 16:49 |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | namespace BigFileTools; |
10 | 10 |
@@ -26,7 +26,7 @@ |
||
26 | 26 | { |
27 | 27 | |
28 | 28 | $path = realpath($path); |
29 | - if(!$path) { |
|
29 | + if (!$path) { |
|
30 | 30 | // TODO: use hack like http://stackoverflow.com/questions/4049856/replace-phps-realpath or http://www.php.net/manual/en/function.realpath.php#84012 |
31 | 31 | // probably as optional feature that can be turned on when you know, what are you doing |
32 | 32 |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function __construct(array $drivers) |
33 | 33 | { |
34 | - foreach($drivers as $driver) { |
|
34 | + foreach ($drivers as $driver) { |
|
35 | 35 | $this->addDriver($driver); |
36 | 36 | } |
37 | 37 | } |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | public function getFileSize($path) |
61 | 61 | { |
62 | 62 | $this->lastExceptions = []; |
63 | - foreach($this->drivers as $driver) { |
|
64 | - try{ |
|
63 | + foreach ($this->drivers as $driver) { |
|
64 | + try { |
|
65 | 65 | $result = $driver->getFileSize($path); |
66 | 66 | $this->lastUsedDriver = $driver; |
67 | 67 | return $result; |
@@ -19,12 +19,12 @@ |
||
19 | 19 | */ |
20 | 20 | public function __construct(array $drivers) |
21 | 21 | { |
22 | - foreach($drivers as $driver) { |
|
23 | - try{ |
|
24 | - if(is_callable($driver)) { |
|
22 | + foreach ($drivers as $driver) { |
|
23 | + try { |
|
24 | + if (is_callable($driver)) { |
|
25 | 25 | $this->addDriver($driver()); |
26 | 26 | |
27 | - } else if(class_exists($driver)) { |
|
27 | + } else if (class_exists($driver)) { |
|
28 | 28 | $this->addDriver(new $driver()); |
29 | 29 | |
30 | 30 | } else { |