Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace GeoIp2\Record;
6
 
7
use GeoIp2\Util;
8
 
9
/**
10
 * Contains data for the traits record associated with an IP address.
11
 *
12
 * This record is returned by all location services and databases.
13
 *
14
 * @property-read int|null $autonomousSystemNumber The autonomous system number
15
 * associated with the IP address. See
16
 * https://en.wikipedia.org/wiki/Autonomous_system_(Internet%29. This attribute
17
 * is only available from the City Plus and Insights web services and the
18
 * GeoIP2 Enterprise database.
19
 * @property-read string|null $autonomousSystemOrganization The organization
20
 * associated with the registered autonomous system number for the IP address.
21
 * See https://en.wikipedia.org/wiki/Autonomous_system_(Internet%29. This
22
 * attribute is only available from the City Plus and Insights web services and
23
 * the GeoIP2 Enterprise database.
24
 * @property-read string|null $connectionType The connection type may take the
25
 * following  values: "Dialup", "Cable/DSL", "Corporate", "Cellular".
26
 * Additional values may be added in the future. This attribute is only
27
 * available in the GeoIP2 Enterprise database.
28
 * @property-read string|null $domain The second level domain associated with the
29
 * IP address. This will be something like "example.com" or "example.co.uk",
30
 * not "foo.example.com". This attribute is only available from the
31
 * City Plus and Insights web services and the GeoIP2 Enterprise
32
 * database.
33
 * @property-read string $ipAddress The IP address that the data in the model
34
 * is for. If you performed a "me" lookup against the web service, this
35
 * will be the externally routable IP address for the system the code is
36
 * running on. If the system is behind a NAT, this may differ from the IP
37
 * address locally assigned to it. This attribute is returned by all end
38
 * points.
39
 * @property-read bool $isAnonymous This is true if the IP address belongs to
40
 * any sort of anonymous network. This property is only available from GeoIP2
41
 * Insights.
42
 * @property-read bool $isAnonymousProxy *Deprecated.* Please see our GeoIP2
43
 * Anonymous IP database
44
 * (https://www.maxmind.com/en/geoip2-anonymous-ip-database) to determine
45
 * whether the IP address is used by an anonymizing service.
46
 * @property-read bool $isAnonymousVpn This is true if the IP address is
47
 * registered to an anonymous VPN provider. If a VPN provider does not register
48
 * subnets under names associated with them, we will likely only flag their IP
49
 * ranges using the isHostingProvider property. This property is only available
50
 * from GeoIP2 Insights.
51
 * @property-read bool $isHostingProvider This is true if the IP address belongs
52
 * to a hosting or VPN provider (see description of isAnonymousVpn property).
53
 * This property is only available from GeoIP2 Insights.
54
 * @property-read bool $isLegitimateProxy This attribute is true if MaxMind
55
 * believes this IP address to be a legitimate proxy, such as an internal
56
 * VPN used by a corporation. This attribute is only available in the GeoIP2
57
 * Enterprise database.
58
 * @property-read bool $isPublicProxy This is true if the IP address belongs to
59
 * a public proxy. This property is only available from GeoIP2 Insights.
60
 * @property-read bool $isResidentialProxy This is true if the IP address is
61
 * on a suspected anonymizing network and belongs to a residential ISP. This
62
 * property is only available from GeoIP2 Insights.
63
 * @property-read bool $isSatelliteProvider *Deprecated.* Due to the
64
 * increased coverage by mobile carriers, very few satellite providers now
65
 * serve multiple countries. As a result, the output does not provide
66
 * sufficiently relevant data for us to maintain it.
67
 * @property-read bool $isTorExitNode This is true if the IP address is a Tor
68
 * exit node. This property is only available from GeoIP2 Insights.
69
 * @property-read string|null $isp The name of the ISP associated with the IP
70
 * address. This attribute is only available from the City Plus and Insights
71
 * web services and the GeoIP2 Enterprise database.
72
 * @property-read string $network The network in CIDR notation associated with
73
 * the record. In particular, this is the largest network where all of the
74
 * fields besides $ipAddress have the same value.
75
 * @property-read string|null $organization The name of the organization
76
 * associated with the IP address. This attribute is only available from the
77
 * City Plus and Insights web services and the GeoIP2 Enterprise database.
78
 * @property-read string|null $mobileCountryCode The [mobile country code
79
 * (MCC)](https://en.wikipedia.org/wiki/Mobile_country_code) associated with
80
 * the IP address and ISP. This property is available from the City Plus and
81
 * Insights web services and the GeoIP2 Enterprise database.
82
 * @property-read string|null $mobileNetworkCode The [mobile network code
83
 * (MNC)](https://en.wikipedia.org/wiki/Mobile_country_code) associated with
84
 * the IP address and ISP. This property is available from the City Plus and
85
 * Insights web services and the GeoIP2 Enterprise database.
86
 * @property-read float|null $staticIpScore An indicator of how static or
87
 * dynamic an IP address is. This property is only available from GeoIP2
88
 * Insights.
89
 * @property-read int|null $userCount The estimated number of users sharing
90
 * the IP/network during the past 24 hours. For IPv4, the count is for the
91
 * individual IP. For IPv6, the count is for the /64 network. This property is
92
 * only available from GeoIP2 Insights.
93
 * @property-read string|null $userType <p>The user type associated with the IP
94
 *  address. This can be one of the following values:</p>
95
 *  <ul>
96
 *    <li>business
97
 *    <li>cafe
98
 *    <li>cellular
99
 *    <li>college
100
 *    <li>consumer_privacy_network
101
 *    <li>content_delivery_network
102
 *    <li>dialup
103
 *    <li>government
104
 *    <li>hosting
105
 *    <li>library
106
 *    <li>military
107
 *    <li>residential
108
 *    <li>router
109
 *    <li>school
110
 *    <li>search_engine_spider
111
 *    <li>traveler
112
 * </ul>
113
 * <p>
114
 *   This attribute is only available from the Insights web service and the
115
 *   GeoIP2 Enterprise database.
116
 * </p>
117
 */
118
class Traits extends AbstractRecord
119
{
120
    /**
121
     * @ignore
122
     *
123
     * @var array<string>
124
     */
125
    protected $validAttributes = [
126
        'autonomousSystemNumber',
127
        'autonomousSystemOrganization',
128
        'connectionType',
129
        'domain',
130
        'ipAddress',
131
        'isAnonymous',
132
        'isAnonymousProxy',
133
        'isAnonymousVpn',
134
        'isHostingProvider',
135
        'isLegitimateProxy',
136
        'isp',
137
        'isPublicProxy',
138
        'isResidentialProxy',
139
        'isSatelliteProvider',
140
        'isTorExitNode',
141
        'mobileCountryCode',
142
        'mobileNetworkCode',
143
        'network',
144
        'organization',
145
        'staticIpScore',
146
        'userCount',
147
        'userType',
148
    ];
149
 
150
    public function __construct(?array $record)
151
    {
152
        if (!isset($record['network']) && isset($record['ip_address'], $record['prefix_len'])) {
153
            $record['network'] = Util::cidr($record['ip_address'], $record['prefix_len']);
154
        }
155
 
156
        parent::__construct($record);
157
    }
158
}