Use camel case for all trait attribute names

This commit is contained in:
Gregory Oschwald 2013-05-08 08:12:09 -07:00
parent fc3e67969d
commit 5bebdce6e8
10 changed files with 27 additions and 27 deletions

View File

@ -34,6 +34,6 @@ class Country
{ {
if ($var != "instance" && isset($this->$var)) return $this->$var; if ($var != "instance" && isset($this->$var)) return $this->$var;
throw new RuntimeException("Unknown attribute: $attr"); throw new \RuntimeException("Unknown attribute: $attr");
} }
} }

View File

@ -5,7 +5,4 @@ namespace GeoIP2\Model;
class Omni extends CityISPOrg class Omni extends CityISPOrg
{ {
public function __construct($raw, $language) {
}
} }

View File

@ -12,8 +12,11 @@ abstract class AbstractRecord
public function __get($attr) { public function __get($attr) {
$valid = in_array($attr, $this->validAttributes); $valid = in_array($attr, $this->validAttributes);
if ($valid && isset($this->record[$attr])){ // XXX - kind of ugly but greatly reduces boilerplate code
return $this->record[$attr]; $key = strtolower(preg_replace('/([A-Z])/', '_\1', $attr));
if ($valid && isset($this->record[$key])){
return $this->record[$key];
} elseif ($valid) { } elseif ($valid) {
return null; return null;
} else { } else {

View File

@ -4,5 +4,5 @@ namespace GeoIP2\Record;
class City extends AbstractPlaceRecord class City extends AbstractPlaceRecord
{ {
protected $validAttribute = Array('confidence', 'geoname_id', 'names'); protected $validAttribute = Array('confidence', 'geonameId', 'names');
} }

View File

@ -4,7 +4,7 @@ namespace GeoIP2\Record;
class Continent extends AbstractPlaceRecord class Continent extends AbstractPlaceRecord
{ {
protected $validAttributes = Array('continent_code', protected $validAttributes = Array('continentCode',
'geoname_id', 'geonameId',
'names'); 'names');
} }

View File

@ -6,7 +6,7 @@ class Country extends AbstractPlaceRecord
{ {
protected $validAttributes = Array('confidence', protected $validAttributes = Array('confidence',
'geoname_id', 'geonameId',
'iso_code', 'isoCode',
'names'); 'names');
} }

View File

@ -4,11 +4,11 @@ namespace GeoIP2\Record;
class Location extends AbstractRecord class Location extends AbstractRecord
{ {
protected $validAttributes = Array('accuracy_radius', protected $validAttributes = Array('accuracyRadius',
'latitude', 'latitude',
'longitude', 'longitude',
'metro_code', 'metroCode',
'postal_code', 'postalCode',
'postal_confidence', 'postalConfidence',
'time_zone'); 'timeZone');
} }

View File

@ -5,8 +5,8 @@ namespace GeoIP2\Record;
class RepresentedCountry extends Country class RepresentedCountry extends Country
{ {
protected $validAttributes = Array('confidence', protected $validAttributes = Array('confidence',
'geoname_id', 'geonameId',
'iso_code', 'isoCode',
'names', 'names',
'type'); 'type');
} }

View File

@ -5,7 +5,7 @@ namespace GeoIP2\Record;
class Subdivision extends AbstractPlaceRecord class Subdivision extends AbstractPlaceRecord
{ {
protected $validAttributes = Array('confidence', protected $validAttributes = Array('confidence',
'geoname_id', 'geonameId',
'iso_code', 'isoCode',
'names'); 'names');
} }

View File

@ -4,14 +4,14 @@ namespace GeoIP2\Record;
class Traits extends AbstractRecord class Traits extends AbstractRecord
{ {
protected $validAttributes = Array('autonomous_system_number', protected $validAttributes = Array('autonomousSystemNumber',
'autonomous_system_organization', 'autonomousSystemOrganization',
'domain', 'domain',
'is_anonymous_proxy', 'isAnonymousProxy',
'is_satellite_provider', 'isSatelliteProvider',
'isp', 'isp',
'ip_address', 'ipAddress',
'organization', 'organization',
'user_type'); 'userType');
} }