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 subdivisions associated with an IP address.
9
 *
10
 * This record is returned by all location databases and services besides
11
 * Country.
12
 */
13
class Subdivision extends AbstractPlaceRecord
14
{
15
    /**
16
     * @var string|null This is a string up to three characters long
17
     *                  contain the subdivision portion of the ISO 3166-2 code. See
18
     *                  https://en.wikipedia.org/wiki/ISO_3166-2. This attribute is returned by all
19
     *                  location databases and services except Country.
20
     */
21
    public readonly ?string $isoCode;
22
 
23
    /**
24
     * @ignore
25
     *
26
     * @param array<string, mixed> $record
27
     * @param list<string>         $locales
28
     */
29
    public function __construct(array $record, array $locales = ['en'])
30
    {
31
        parent::__construct($record, $locales);
32
 
33
        $this->isoCode = $record['iso_code'] ?? null;
34
    }
35
 
36
    /**
37
     * @return array<string, mixed>
38
     */
39
    public function jsonSerialize(): array
40
    {
41
        $js = parent::jsonSerialize();
42
        if ($this->isoCode !== null) {
43
            $js['iso_code'] = $this->isoCode;
44
        }
45
 
46
        return $js;
47
    }
48
}