Skip to content

Commit

Permalink
Fix to a Bug in Setting Property Value
Browse files Browse the repository at this point in the history
  • Loading branch information
usernane committed May 10, 2023
1 parent 36f6759 commit 23da8a4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions webfiori/json/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public function setAsObject(bool $bool) {
* @since 1.0
*/
public function setName(string $name) : bool {
$keyValidity = self::_isValidKey($name, $this->getStyle());
$keyValidity = self::isValidKey($name, $this->getStyle());

if ($keyValidity === false) {
return false;
Expand Down Expand Up @@ -293,12 +293,14 @@ public function setStyle(string $style) {
* @since 1.0
*/
public function setValue($val) {
if (is_subclass_of($val, 'webfiori\\json\\JsonI')) {
$this->datatype = gettype($val);

if ($this->getType() == 'object' && is_subclass_of($val, 'webfiori\\json\\JsonI')) {
$this->value = $val->toJSON();
} else {
$this->value = $val;
}
$this->datatype = gettype($val);

}
/**
* Checks if the key is a valid key string.
Expand All @@ -312,7 +314,7 @@ public function setValue($val) {
*
* @since 1.0
*/
private static function _isValidKey($key, $style = 'kebab') {
private static function isValidKey($key, $style = 'kebab') {
$trimmedKey = trim($key);

if (strlen($trimmedKey) != 0) {
Expand Down

0 comments on commit 23da8a4

Please sign in to comment.