1 | <?php |
||
14 | class CerStrategy |
||
15 | { |
||
16 | /** |
||
17 | * File to decode. |
||
18 | * |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $file; |
||
22 | |||
23 | /** |
||
24 | * Chunk length. |
||
25 | * |
||
26 | * @var integer |
||
27 | */ |
||
28 | protected $chunkLength = 64; |
||
29 | |||
30 | /** |
||
31 | * Create a new cer strategy instance. |
||
32 | * |
||
33 | * @param string $file |
||
34 | */ |
||
35 | public function __construct(string $file) |
||
39 | |||
40 | /** |
||
41 | * Convert .cer to .pem |
||
42 | * |
||
43 | * @return string |
||
44 | */ |
||
45 | public function convertToPem(): string |
||
56 | |||
57 | public function getCertificateNumber(): string |
||
58 | { |
||
59 | $data = $this->parseCertificate(); |
||
60 | $data = str_split($data['serialNumberHex'], 2); |
||
61 | |||
62 | $serialNumber = null; |
||
63 | |||
64 | for ($i = 0; $i < sizeof($data); $i++) { |
||
|
|||
65 | $serialNumber .= substr($data[$i], 1); |
||
66 | } |
||
67 | |||
68 | return $serialNumber; |
||
69 | } |
||
70 | |||
71 | public function getExpirationDate(): string |
||
77 | |||
78 | public function getInitialDate(): string |
||
84 | |||
85 | protected function parseCertificate(): array |
||
89 | |||
90 | protected function dateFormat(string $date): string |
||
94 | } |
||
95 |
If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration: