Neos\Flow\Http\Response::getAge PHP Method

getAge() public method

The age is determined either by an explicitly set Age header or by the difference between Date and "now". Note that, according to RFC 2616 / 13.2.3, the presence of an Age header implies that the response is not first-hand. You should therefore only explicitly set an Age header if this is the case.
public getAge ( ) : integer
return integer The age in seconds
    public function getAge()
    {
        if ($this->headers->has('Age')) {
            return $this->headers->get('Age');
        } else {
            $dateTimestamp = $this->headers->get('Date')->getTimestamp();
            $nowTimestamp = $this->now->getTimestamp();
            return $nowTimestamp > $dateTimestamp ? $nowTimestamp - $dateTimestamp : 0;
        }
    }

Usage Example

 /**
  * @test
  */
 public function getAgeReturnsTimeSpecifiedInAgeHeaderIfExists()
 {
     $now = \DateTime::createFromFormat(DATE_RFC2822, 'Tue, 22 May 2012 12:00:00 GMT');
     $response = new Response();
     $response->setNow($now);
     $response->setHeader('Age', 123);
     $this->assertSame(123, $response->getAge());
 }