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
abstract class AbstractPlaceRecord extends AbstractNamedRecord
8
{
9
    /**
10
     * @var int|null A value from 0-100 indicating MaxMind's
11
     *               confidence that the location level is correct. This attribute is only available
12
     *               from the Insights service and the GeoIP2 Enterprise database.
13
     */
14
    public readonly ?int $confidence;
15
 
16
    /**
17
     * @var int|null The GeoName ID for the location level. This attribute
18
     *               is returned by all location services and databases.
19
     */
20
    public readonly ?int $geonameId;
21
 
22
    /**
23
     * @ignore
24
     *
25
     * @param array<string, mixed> $record
26
     * @param list<string>         $locales
27
     */
28
    public function __construct(array $record, array $locales = ['en'])
29
    {
30
        parent::__construct($record, $locales);
31
 
32
        $this->confidence = $record['confidence'] ?? null;
33
        $this->geonameId = $record['geoname_id'] ?? null;
34
    }
35
 
36
    /**
37
     * @return array<string, mixed>
38
     */
39
    public function jsonSerialize(): array
40
    {
41
        $js = parent::jsonSerialize();
42
        if ($this->confidence !== null) {
43
            $js['confidence'] = $this->confidence;
44
        }
45
 
46
        if ($this->geonameId !== null) {
47
            $js['geoname_id'] = $this->geonameId;
48
        }
49
 
50
        return $js;
51
    }
52
}