Skip to content
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

Implementing unset. #7

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Implementing unset. #7

wants to merge 3 commits into from

Conversation

fmizzell
Copy link
Contributor

@fmizzell fmizzell commented Dec 2, 2020

No description provided.

@dafeder dafeder self-assigned this Dec 2, 2020
@dafeder dafeder self-requested a review December 2, 2020 04:07
@@ -146,9 +146,17 @@ public function __set($path, $value)
public function __isset($name)
{
$notSmart = new JsonObject("{$this->data}");
return $notSmart->get($name) ? true : false;
$thing = $notSmart->get($name);
Copy link
Member

Choose a reason for hiding this comment

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

Let's avoid variable names this unnecessarily vague - can we call this $value or $result? Aside from that though, I'm not sure why this is an improvement? When not using smartget, we should always get either an array or false, so I'm not clear on what edge case we're addressing here.

@@ -146,9 +146,17 @@ public function __set($path, $value)
public function __isset($name)
Copy link
Member

Choose a reason for hiding this comment

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

Add documentation

Copy link
Member

Choose a reason for hiding this comment

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

Oh my bad, that's from my pull request! I guess I should add that in a separate PR

public function __unset($name)
{
$field = str_replace('$.', '', $name);
$this->data->remove('$', $field);
Copy link
Member

Choose a reason for hiding this comment

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

Would this work one or more levels down?

}

public function __unset($name)
Copy link
Member

Choose a reason for hiding this comment

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

Seems like both here and in my __isset() method $path would be a more appropriate name than $name, doesn't it?

Copy link
Member

Choose a reason for hiding this comment

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

Add documentation

@dafeder dafeder assigned fmizzell and unassigned dafeder Dec 2, 2020
@dafeder dafeder marked this pull request as draft December 3, 2020 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants