Imbo\Storage\GridFS::getLastModified PHP Method

getLastModified() public method

public getLastModified ( $user, $imageIdentifier )
    public function getLastModified($user, $imageIdentifier)
    {
        if (($file = $this->getImageObject($user, $imageIdentifier)) === false) {
            throw new StorageException('File not found', 404);
        }
        $timestamp = $file->file['updated'];
        return new DateTime('@' . $timestamp, new DateTimeZone('UTC'));
    }

Usage Example

Example #1
0
 /**
  * @covers Imbo\Storage\GridFS::getLastModified
  * @covers Imbo\Storage\GridFS::imageExists
  */
 public function testGetLastModified()
 {
     $file = new TestFile();
     $cursor = $this->getMockBuilder('MongoGridFSCursor')->disableOriginalConstructor()->getMock();
     $cursor->expects($this->once())->method('count')->will($this->returnValue(1));
     $cursor->expects($this->once())->method('getNext')->will($this->returnValue($file));
     $this->grid->expects($this->once())->method('find')->will($this->returnValue($cursor));
     $this->assertInstanceOf('DateTime', $date = $this->driver->getLastModified($this->publicKey, $this->imageIdentifier));
     $this->assertSame(1334579830, $date->getTimestamp());
 }