bandwidthThrottle\tokenBucket\storage\FileStorage::getMicrotime PHP Метод

getMicrotime() публичный Метод

public getMicrotime ( )
    public function getMicrotime()
    {
        if (fseek($this->fileHandle, 0) !== 0) {
            throw new StorageException("Could not move to beginning of the file.");
        }
        $data = fread($this->fileHandle, 8);
        if ($data === false) {
            throw new StorageException("Could not read from storage.");
        }
        return DoublePacker::unpack($data);
    }

Usage Example

 /**
  * Tests readinging too little in getMicrotime().
  *
  * @expectedException bandwidthThrottle\tokenBucket\storage\StorageException
  */
 public function testGetMicrotimeReadsToLittle()
 {
     $data = new vfsStreamFile("data");
     $data->setContent("1234567");
     vfsStream::setup('test')->addChild($data);
     $storage = new FileStorage(vfsStream::url("test/data"));
     $storage->getMicrotime();
 }