Movatterモバイル変換


[0]ホーム

URL:


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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
kevinruscoe wants to merge2 commits intogrimzy:master
base:master
Choose a base branch
Loading
fromkevinruscoe:patch-1

Conversation

kevinruscoe
Copy link

Add toArray() helper

@kevinruscoekevinruscoe changed the titleAdd 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

@grimzygrimzy 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 theimplements Arrayable onPoint class? (Illuminate\Contracts\Support\Arrayable)

@grimzy
Copy link
Owner

grimzy commentedMar 5, 2020
edited
Loading

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

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

Although if we implementArrayAccess, then we should throw an exception when:

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

And to be complete, there's alsoIteratorAggregate 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 oflat andlng inPoint::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 freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@grimzygrimzygrimzy 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.

2 participants
@kevinruscoe@grimzy

[8]ページ先頭

©2009-2025 Movatter.jp