C:\xampp\htdocs\landing\wp-content\plugins\amp\src\RemoteRequest\CachedResponse.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
/**
 * Class CachedResponse.
 *
 * @package AmpProject\AmpWP
 */

namespace AmpProject\AmpWP\RemoteRequest;

use 
DateTimeImmutable;
use 
DateTimeInterface;

/**
 * Serializable object that represents a cached response together with its expiry time.
 *
 * @package AmpProject\AmpWP
 * @since 2.0
 * @internal
 */
final class CachedResponse {

    
/**
     * Cached body.
     *
     * @var string
     */
    
private $body;

    
/**
     * Cached headers.
     *
     * @var array
     */
    
private $headers;

    
/**
     * Cached status code.
     *
     * @var int
     */
    
private $status_code;

    
/**
     * Expiry time of the cached value.
     *
     * @var DateTimeInterface
     */
    
private $expiry;

    
/**
     * Instantiate a CachedResponse object.
     *
     * @param string            $body         Cached body.
     * @param string[]          $headers      Associative array of cached headers.
     * @param int               $status_code  Cached status code.
     * @param DateTimeInterface $expiry       Expiry of the cached value.
     */
    
public function __construct$body$headers$status_codeDateTimeInterface $expiry ) {
        
$this->body        = (string) $body;
        
$this->headers     = (array) $headers;
        
$this->status_code = (int) $status_code;
        
$this->expiry      $expiry;
    }

    
/**
     * Get the cached body.
     *
     * @return string Cached body.
     */
    
public function get_body() {
        return 
$this->body;
    }

    
/**
     * Get the cached headers.
     *
     * @return string[] Cached headers.
     */
    
public function get_headers() {
        return 
$this->headers;
    }

    
/**
     * Get the cached status code.
     *
     * @return int Cached status code.
     */
    
public function get_status_code() {
        return 
$this->status_code;
    }

    
/**
     * Determine the validity of the cached response.
     *
     * @return bool Whether the cached response is valid.
     */
    
public function is_valid() {
        
// Values are already typed, so we just control the status code for validity.
        
return $this->status_code 100 && $this->status_code <= 599;
    }

    
/**
     * Get the expiry of the cached value.
     *
     * @return DateTimeInterface Expiry of the cached value.
     */
    
public function get_expiry() {
        return 
$this->expiry;
    }

    
/**
     * Check whether the cached value is expired.
     *
     * @return bool Whether the cached value is expired.
     */
    
public function is_expired() {
        return new 
DateTimeImmutable'now' ) > $this->expiry;
    }
}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586