Skip to content

Commit

Permalink
Merge pull request #39 from WebFiori/dev
Browse files Browse the repository at this point in the history
Fix to a Bug in Setting Property Value
  • Loading branch information
usernane authored May 10, 2023
2 parents 36f6759 + 23da8a4 commit 79e400b
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 79e400b

Please sign in to comment.