-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,7 +87,7 @@ public function __toString() | |
*/ | ||
public function get(string $path) | ||
{ | ||
if ($this->__isset($path) === false) { | ||
if (!isset($this->{$path})) { | ||
return null; | ||
} | ||
return $this->data->get($path); | ||
|
@@ -103,7 +103,7 @@ public function get(string $path) | |
*/ | ||
public function __get(string $path) | ||
{ | ||
return $this->data->get($path); | ||
return $this->get($path); | ||
} | ||
|
||
/** | ||
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's avoid variable names this unnecessarily vague - can we call this |
||
return ($thing === false) ? false : true; | ||
} | ||
|
||
public function __unset($name) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like both here and in my There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add documentation |
||
{ | ||
$field = str_replace('$.', '', $name); | ||
$this->data->remove('$', $field); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would this work one or more levels down? |
||
} | ||
|
||
|
||
public function getSchema() | ||
{ | ||
return $this->schema; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add documentation
There was a problem hiding this comment.
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