Skip to content

Address valid attributes #539

Closed
Closed

Description

@bingalls

As a user of Geocoder/Model/Address, I expect calls to getCountryCode() to return null or empty string, rather than an error. In particular,
return $this->country->getCode();
might have country defined as null which is the constructor's default.
This is also a problem in toArray().
Further, there is no getCountryName(), so you should likely create that, else mark this method as @deprecated.

To recap, the legitimate code fragment
$address = new Address(); var_export( $address->toArray() );
throws an error, rather than print out
['latitude' => null, 'adminlevels' => [], ...]

Activity

  1. Nyholm commented on Oct 12, 2016

    @Nyholm
    Member

    Thank you for this issue. Have a look at the new Position interface in #529. That relates to your issue. I even added a test for that.

  2. bingalls commented on Oct 14, 2016

    @bingalls
    Author

    Hmm. I like what I'm reading in the discussion. I can review your code, when it arrives, if this is what you mean.

  3. Nyholm commented on Oct 14, 2016

    @Nyholm
    Member

    You may review the code now if you like. See if it would solve your issue and give it a 👍 or 👎 .

  4. bingalls commented on Nov 7, 2016

    @bingalls
    Author

    Sorry, I could not find the code, outside of the discussion.

  5. Nyholm commented on Dec 22, 2016

    @Nyholm
    Member

    The script:

    <?php
    
    include "vendor/autoload.php";
    
    $address = new \Geocoder\Model\Address(); 
    var_export( $address->toArray() );

    Will produce:

    % php test.php
    array (
      'latitude' => NULL,
      'longitude' => NULL,
      'bounds' => 
      array (
        'south' => NULL,
        'west' => NULL,
        'north' => NULL,
        'east' => NULL,
      ),
      'streetNumber' => NULL,
      'streetName' => NULL,
      'postalCode' => NULL,
      'locality' => NULL,
      'subLocality' => NULL,
      'adminLevels' => 
      array (
      ),
      'country' => NULL,
      'countryCode' => NULL,
      'timezone' => NULL,
    ) 
    

    Which is as you expect. This issue is solved by #529

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions