Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add a simple toArray() helper to complement the other helpers on the Point class. #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
kevinruscoe wants to merge 2 commits into grimzy:master
base: master
Choose a base branch
Loading
from kevinruscoe:patch-1

Conversation

Copy link

@kevinruscoe kevinruscoe commented Aug 21, 2019

Add toArray() helper

Kevin Ruscoe added 2 commits August 21, 2019 11:55
@kevinruscoe kevinruscoe changed the title (削除) Add a simple toArray() to complement the other helpers on the Point class. (削除ここまで) (追記) Add a simple toArray() helper to complement the other helpers on the Point class. (追記ここまで) Aug 21, 2019
Copy link
Owner

@grimzy grimzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea 💯

Would you mind adding the implements Arrayable on Point class? (Illuminate\Contracts\Support\Arrayable)

Copy link
Owner

grimzy commented Mar 5, 2020
edited
Loading

Also -and I'm just thinking out loud here- it might be useful to implement ArrayAccess on the Point class (similarly to the GeometryCollection). We should then be able to get and set the latitude and longitude on $point just like an associative array:

$point = new Point(1, 2);
echo $point['lat']; // 1
echo $point['lng'] // 2
$point['lat'] = 3;
echo $point['lat']; // 3

Although if we implement ArrayAccess, then we should throw an exception when:

  • adding a 3rd value to the $point (ex: $point[] = <some float>)
  • adding an array key different than lat or lng (ex: $point['hello'] = <some float>)

And to be complete, there's also IteratorAggregate which will allow us to loop. Not super useful, is it? I'm not sure. But if we implement it, then we should invert the order of lat and lng in Point::toArray() to match the order in the rest of the class (__toString(), toPair()).

What do you think?
I know I'm the one suggesting, but I'm also skeptical about these implementations 🤣

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

@grimzy grimzy grimzy requested changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /