예제 #1
0
 /**
  * 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;
 }
예제 #2
0
 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.
 }