Use camel case for all trait attribute names
This commit is contained in:
		
							parent
							
								
									fc3e67969d
								
							
						
					
					
						commit
						5bebdce6e8
					
				@ -34,6 +34,6 @@ class Country
 | 
			
		||||
  {
 | 
			
		||||
	if ($var != "instance" && isset($this->$var)) return $this->$var;
 | 
			
		||||
 | 
			
		||||
    throw new RuntimeException("Unknown attribute: $attr");
 | 
			
		||||
    throw new \RuntimeException("Unknown attribute: $attr");
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -5,7 +5,4 @@ namespace GeoIP2\Model;
 | 
			
		||||
class Omni extends CityISPOrg
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  public function __construct($raw, $language) {
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -12,8 +12,11 @@ abstract class AbstractRecord
 | 
			
		||||
 | 
			
		||||
  public function __get($attr) {
 | 
			
		||||
    $valid = in_array($attr, $this->validAttributes);
 | 
			
		||||
    if ($valid && isset($this->record[$attr])){
 | 
			
		||||
      return $this->record[$attr];
 | 
			
		||||
    // XXX - kind of ugly but greatly reduces boilerplate code
 | 
			
		||||
    $key = strtolower(preg_replace('/([A-Z])/', '_\1', $attr));
 | 
			
		||||
 | 
			
		||||
    if ($valid && isset($this->record[$key])){
 | 
			
		||||
      return $this->record[$key];
 | 
			
		||||
    } elseif ($valid) {
 | 
			
		||||
      return null;
 | 
			
		||||
    } else {
 | 
			
		||||
 | 
			
		||||
@ -4,5 +4,5 @@ namespace GeoIP2\Record;
 | 
			
		||||
 | 
			
		||||
class City extends AbstractPlaceRecord
 | 
			
		||||
{
 | 
			
		||||
  protected $validAttribute = Array('confidence', 'geoname_id', 'names');
 | 
			
		||||
  protected $validAttribute = Array('confidence', 'geonameId', 'names');
 | 
			
		||||
}
 | 
			
		||||
@ -4,7 +4,7 @@ namespace GeoIP2\Record;
 | 
			
		||||
 | 
			
		||||
class Continent extends AbstractPlaceRecord
 | 
			
		||||
{
 | 
			
		||||
  protected $validAttributes = Array('continent_code',
 | 
			
		||||
                                     'geoname_id',
 | 
			
		||||
  protected $validAttributes = Array('continentCode',
 | 
			
		||||
                                     'geonameId',
 | 
			
		||||
                                     'names');
 | 
			
		||||
}
 | 
			
		||||
@ -6,7 +6,7 @@ class Country extends AbstractPlaceRecord
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  protected $validAttributes = Array('confidence',
 | 
			
		||||
                                   'geoname_id',
 | 
			
		||||
                                   'iso_code',
 | 
			
		||||
                                   'names');
 | 
			
		||||
                                     'geonameId',
 | 
			
		||||
                                     'isoCode',
 | 
			
		||||
                                     'names');
 | 
			
		||||
}
 | 
			
		||||
@ -4,11 +4,11 @@ namespace GeoIP2\Record;
 | 
			
		||||
 | 
			
		||||
class Location extends AbstractRecord
 | 
			
		||||
{
 | 
			
		||||
  protected $validAttributes = Array('accuracy_radius',
 | 
			
		||||
  protected $validAttributes = Array('accuracyRadius',
 | 
			
		||||
                                     'latitude',
 | 
			
		||||
                                     'longitude',
 | 
			
		||||
                                     'metro_code',
 | 
			
		||||
                                     'postal_code',
 | 
			
		||||
                                     'postal_confidence',
 | 
			
		||||
                                     'time_zone');
 | 
			
		||||
                                     'metroCode',
 | 
			
		||||
                                     'postalCode',
 | 
			
		||||
                                     'postalConfidence',
 | 
			
		||||
                                     'timeZone');
 | 
			
		||||
}
 | 
			
		||||
@ -5,8 +5,8 @@ namespace GeoIP2\Record;
 | 
			
		||||
class RepresentedCountry extends Country
 | 
			
		||||
{
 | 
			
		||||
  protected $validAttributes = Array('confidence',
 | 
			
		||||
                                   'geoname_id',
 | 
			
		||||
                                   'iso_code',
 | 
			
		||||
                                   'geonameId',
 | 
			
		||||
                                   'isoCode',
 | 
			
		||||
                                   'names',
 | 
			
		||||
                                   'type');
 | 
			
		||||
}
 | 
			
		||||
@ -5,7 +5,7 @@ namespace GeoIP2\Record;
 | 
			
		||||
class Subdivision extends AbstractPlaceRecord
 | 
			
		||||
{
 | 
			
		||||
  protected $validAttributes = Array('confidence',
 | 
			
		||||
                                     'geoname_id',
 | 
			
		||||
                                     'iso_code',
 | 
			
		||||
                                     'geonameId',
 | 
			
		||||
                                     'isoCode',
 | 
			
		||||
                                     'names');
 | 
			
		||||
}
 | 
			
		||||
@ -4,14 +4,14 @@ namespace GeoIP2\Record;
 | 
			
		||||
 | 
			
		||||
class Traits extends AbstractRecord
 | 
			
		||||
{
 | 
			
		||||
  protected $validAttributes = Array('autonomous_system_number',
 | 
			
		||||
                                     'autonomous_system_organization',
 | 
			
		||||
  protected $validAttributes = Array('autonomousSystemNumber',
 | 
			
		||||
                                     'autonomousSystemOrganization',
 | 
			
		||||
                                     'domain',
 | 
			
		||||
                                     'is_anonymous_proxy',
 | 
			
		||||
                                     'is_satellite_provider',
 | 
			
		||||
                                     'isAnonymousProxy',
 | 
			
		||||
                                     'isSatelliteProvider',
 | 
			
		||||
                                     'isp',
 | 
			
		||||
                                     'ip_address',
 | 
			
		||||
                                     'ipAddress',
 | 
			
		||||
                                     'organization',
 | 
			
		||||
                                     'user_type');
 | 
			
		||||
                                     'userType');
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user