• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mlocati / ocsp / 6187621836

14 Sep 2023 03:26PM UTC coverage: 67.155% (+0.4%) from 66.765%
6187621836

push

github

web-flow
Merge pull request #14 from mlocati/pr13

11 of 11 new or added lines in 2 files covered. (100.0%)

458 of 682 relevant lines covered (67.16%)

1.61 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

68.42
/src/Response.php
1
<?php
2

3
namespace Ocsp;
4

5
use DateTimeImmutable;
6

7
/**
8
 * Contains the response about the revocation of a certificate.
9
 */
10
class Response
11
{
12
    /**
13
     * Certificate revocation reason: unspecified.
14
     *
15
     * @var int
16
     */
17
    const REVOCATIONREASON_UNSPECIFIED = 0;
18

19
    /**
20
     * Certificate revocation reason: key compromise.
21
     *
22
     * @var int
23
     */
24
    const REVOCATIONREASON_KEYCOMPROMISE = 1;
25

26
    /**
27
     * Certificate revocation reason: CA Compromise.
28
     *
29
     * @var int
30
     */
31
    const REVOCATIONREASON_CACOMPROMISE = 2;
32

33
    /**
34
     * Certificate revocation reason: affiliation changed.
35
     *
36
     * @var int
37
     */
38
    const REVOCATIONREASON_AFFILIATIONCHANGED = 3;
39

40
    /**
41
     * Certificate revocation reason: superseded.
42
     *
43
     * @var int
44
     */
45
    const REVOCATIONREASON_SUPERSEDED = 4;
46

47
    /**
48
     * Certificate revocation reason: cessation of operation.
49
     *
50
     * @var int
51
     */
52
    const REVOCATIONREASON_CESSATIONOFOPERATION = 5;
53

54
    /**
55
     * Certificate revocation reason: certificate hold.
56
     *
57
     * @var int
58
     */
59
    const REVOCATIONREASON_CERTIFICATEHOLD = 6;
60

61
    /**
62
     * Certificate revocation reason: remove from CRL.
63
     *
64
     * @var int
65
     */
66
    const REVOCATIONREASON_REMOVEFROMCRL = 8;
67

68
    /**
69
     * Certificate revocation reason: privilege withdrawn.
70
     *
71
     * @var int
72
     */
73
    const REVOCATIONREASON_PRIVILEGEWITHDRAWN = 9;
74

75
    /**
76
     * Certificate revocation reason: AA compromise.
77
     *
78
     * @var int
79
     */
80
    const REVOCATIONREASON_AACOMPROMISE = 10;
81

82
    /**
83
     * The most recent time at which the status being indicated is known by the responder to have been correct.
84
     *
85
     * @var \DateTimeImmutable
86
     */
87
    private $thisUpdate;
88

89
    /**
90
     * The time at which one should next check for a status change.
91
     *
92
     * @var \DateTimeImmutable|null
93
     */
94
    private $nextUpdate;
95

96
    /**
97
     * The serial number of the certificate.
98
     *
99
     * @var string
100
     */
101
    private $certificateSerialNumber;
102

103
    /**
104
     * Is the certificate revoked (NULL: unknown)?
105
     *
106
     * @var bool|null
107
     */
108
    private $revoked;
109

110
    /**
111
     * The date/time when the revocation occurred.
112
     *
113
     * @var \DateTimeImmutable|null
114
     */
115
    private $revokedOn;
116

117
    /**
118
     * The revocation reason (if revoked).
119
     *
120
     * @var int|null
121
     */
122
    private $revocationReason;
123

124
    /**
125
     * @param \DateTimeImmutable $thisUpdate
126
     * @param string $certificateSerialNumber
127
     * @param \DateTimeImmutable|null $nextUpdate
128
     */
129
    protected function __construct(DateTimeImmutable $thisUpdate, $certificateSerialNumber, DateTimeImmutable $nextUpdate = null)
130
    {
131
        $this->thisUpdate = $thisUpdate;
2✔
132
        $this->certificateSerialNumber = $certificateSerialNumber;
2✔
133
        $this->nextUpdate = $nextUpdate;
2✔
134
    }
135

136
    /**
137
     * Create a new instance when the certificate is good.
138
     *
139
     * @param \DateTimeImmutable $thisUpdate
140
     * @param string $certificateSerialNumber
141
     * @param \DateTimeImmutable|null $nextUpdate
142
     *
143
     * @return static
144
     */
145
    public static function good(DateTimeImmutable $thisUpdate, $certificateSerialNumber, DateTimeImmutable $nextUpdate = null)
146
    {
147
        $result = new static($thisUpdate, $certificateSerialNumber, $nextUpdate);
1✔
148
        $result->revoked = false;
1✔
149

150
        return $result;
1✔
151
    }
152

153
    /**
154
     * Create a new instance when the certificate is revoked.
155
     *
156
     * @param \DateTimeImmutable $thisUpdate
157
     * @param string $certificateSerialNumber
158
     * @param \DateTimeImmutable $revokedOn
159
     * @param \DateTimeImmutable|null $nextUpdate
160
     *
161
     * @return static
162
     */
163
    public static function revoked(DateTimeImmutable $thisUpdate, $certificateSerialNumber, DateTimeImmutable $revokedOn, $revocationReason = self::REVOCATIONREASON_UNSPECIFIED, DateTimeImmutable $nextUpdate = null)
164
    {
165
        $result = new static($thisUpdate, $certificateSerialNumber, $nextUpdate);
1✔
166
        $result->revoked = true;
1✔
167
        $result->revokedOn = $revokedOn;
1✔
168
        $result->revocationReason = (int) $revocationReason;
1✔
169

170
        return $result;
1✔
171
    }
172

173
    /**
174
     * Create a new instance when the certificate revocation is unknown.
175
     *
176
     * @param \DateTimeImmutable $thisUpdate
177
     * @param string $certificateSerialNumber
178
     *
179
     * @return static
180
     */
181
    public static function unknown(DateTimeImmutable $thisUpdate, $certificateSerialNumber, DateTimeImmutable $nextUpdate = null)
182
    {
183
        $result = new static($thisUpdate, $certificateSerialNumber, $nextUpdate);
×
184

185
        return $result;
×
186
    }
187

188
    /**
189
     * Get the most recent time at which the status being indicated is known by the responder to have been correct.
190
     *
191
     * @return \DateTimeImmutable
192
     */
193
    public function getThisUpdate()
194
    {
195
        return $this->thisUpdate;
×
196
    }
197

198
    /**
199
     * Get the serial number of the certificate.
200
     *
201
     * @return string
202
     */
203
    public function getCertificateSerialNumber()
204
    {
205
        return $this->certificateSerialNumber;
×
206
    }
207

208
    /**
209
     * Is the certificate revoked (NULL: unknown)?
210
     *
211
     * @return bool|null
212
     */
213
    public function isRevoked()
214
    {
215
        return $this->revoked;
2✔
216
    }
217

218
    /**
219
     * Get the revocation date/time (not null only if the certificate is revoked).
220
     *
221
     * @return \DateTimeImmutable|null
222
     */
223
    public function getRevokedOn()
224
    {
225
        return $this->revokedOn;
×
226
    }
227

228
    /**
229
     * Get the revocation reason (if revoked).
230
     *
231
     * @return int|null
232
     */
233
    public function getRevocationReason()
234
    {
235
        return $this->revocationReason;
×
236
    }
237

238
    /**
239
     * The time at which one should next check for a status change.
240
     *
241
     * @var \DateTimeImmutable|null
242
     */
243
    public function getNextUpdate()
244
    {
245
        return $this->nextUpdate;
1✔
246
    }
247
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc