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 represented country associated with an IP address.
9
 *
10
 * This class contains the country-level data associated with an IP address
11
 * for the IP's represented country. The represented country is the country
12
 * represented by something like a military base.
13
 */
14
class RepresentedCountry extends Country
15
{
16
    /**
17
     * @var string|null A string indicating the type of entity that is
18
     *                  representing the country. Currently we only return <code>military</code>
19
     *                  but this could expand to include other types in the future.
20
     */
21
    public readonly ?string $type;
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->type = $record['type'] ?? null;
34
    }
35
 
36
    /**
37
     * @return array<string, mixed>
38
     */
39
    public function jsonSerialize(): array
40
    {
41
        $js = parent::jsonSerialize();
42
        if ($this->type !== null) {
43
            $js['type'] = $this->type;
44
        }
45
 
46
        return $js;
47
    }
48
}