/** * Constructor * * @param int $maxSize Maximum acceptable file size in bytes (inclusive) * @param int $minSize Minimum acceptable file size in bytes (inclusive) */ public function __construct($maxSize, $minSize = 0) { if (is_string($maxSize)) { $maxSize = \Upload\File::humanReadableToBytes($maxSize); } $this->maxSize = $maxSize; if (is_string($minSize)) { $minSize = \Upload\File::humanReadableToBytes($minSize); } $this->minSize = $minSize; }
public function testParsesHumanFriendlyFileSizes() { $this->assertEquals(100, \Upload\File::humanReadableToBytes('100')); $this->assertEquals(102400, \Upload\File::humanReadableToBytes('100K')); $this->assertEquals(104857600, \Upload\File::humanReadableToBytes('100M')); $this->assertEquals(107374182400.0, \Upload\File::humanReadableToBytes('100G')); $this->assertEquals(100, \Upload\File::humanReadableToBytes('100F')); // <-- Unrecognized. Assume bytes. }