MiniAsset\Output\AssetWriter::getTimestamp PHP Method

getTimestamp() public method

Will either read the cached version, or the on disk version. If no timestamp is found for a file, a new time will be generated and saved. If timestamps are disabled, false will be returned.
public getTimestamp ( AssetTarget $build ) : mixed
$build MiniAsset\AssetTarget The build to get a timestamp for.
return mixed The last build time, or false.
    public function getTimestamp(AssetTarget $build)
    {
        $ext = $build->ext();
        if (empty($this->timestamp[$ext])) {
            return false;
        }
        $data = $this->_readTimestamp();
        $name = $this->buildCacheName($build);
        if (!empty($data[$name])) {
            return $data[$name];
        }
        $time = time();
        $this->setTimestamp($build, $time);
        return $time;
    }

Usage Example

 public function testInvalidateAndFinalizeBuildTimestamp()
 {
     $writer = new AssetWriter(['js' => true, 'css' => false], TMP);
     $cacheName = $writer->buildCacheName($this->target);
     $writer->invalidate($this->target);
     $invalidatedCacheName = $writer->buildCacheName($this->target);
     $this->assertNotEquals($cacheName, $invalidatedCacheName);
     $time = $writer->getTimestamp($this->target);
     $writer->finalize($this->target);
     $finalizedCacheName = $writer->buildCacheName($this->target);
     $this->assertEquals($cacheName, $finalizedCacheName);
     $finalizedTime = $writer->getTimestamp($this->target);
     $this->assertEquals($time, $finalizedTime);
 }