Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace GeoIp2\Record;
6
 
7
/**
8
 * Contains data for the postal record associated with an IP address.
9
 *
10
 * This record is returned by all location databases and services besides
11
 * Country.
12
 */
13
class Postal implements \JsonSerializable
14
{
15
    /**
16
     * @var string|null The postal code of the location. Postal codes
17
     *                  are not available for all countries. In some countries, this will only
18
     *                  contain part of the postal code. This attribute is returned by all location
19
     *                  databases and services besides Country.
20
     */
21
    public readonly ?string $code;
22
 
23
    /**
24
     * @var int|null A value from 0-100 indicating MaxMind's
25
     *               confidence that the postal code is correct. This attribute is only
26
     *               available from the Insights service and the GeoIP2 Enterprise
27
     *               database.
28
     */
29
    public readonly ?int $confidence;
30
 
31
    /**
32
     * @ignore
33
     *
34
     * @param array<string, mixed> $record
35
     */
36
    public function __construct(array $record)
37
    {
38
        $this->code = $record['code'] ?? null;
39
        $this->confidence = $record['confidence'] ?? null;
40
    }
41
 
42
    /**
43
     * @return array<string, mixed>
44
     */
45
    public function jsonSerialize(): array
46
    {
47
        $js = [];
48
        if ($this->code !== null) {
49
            $js['code'] = $this->code;
50
        }
51
        if ($this->confidence !== null) {
52
            $js['confidence'] = $this->confidence;
53
        }
54
 
55
        return $js;
56
    }
57
}