for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace BigFileTools\Driver;
use Brick\Math\BigInteger;
class ComDriver implements ISizeDriver
{
public function __construct()
if (!class_exists("COM")) {
throw new PrerequisiteException("ComDriver requires COM extension to be loaded in PHP");
}
/**
* Returns file size by using Windows COM interface
* @inheritdoc
* @link http://stackoverflow.com/questions/5501451/php-x86-how-to-get-filesize-of-2gb-file-without-external-program/5502328#5502328
*/
public function getFileSize($path)
// Use the Windows COM interface
$fsobj = new \COM('Scripting.FileSystemObject');
if (dirname($path) == '.')
$this->path = ((substr(getcwd(), -1) == DIRECTORY_SEPARATOR) ? getcwd() . basename($path) : getcwd() . DIRECTORY_SEPARATOR . basename($path));
path
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
$f = $fsobj->GetFile($path);
return BigInteger::of($f->Size);
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: