src/Judopay/Model/Inner/TransmittedField.php
public static function factory($value)
    {
        // if user passes same object
        if ($value instanceof static) {
            return $value;
        }

        // if user passes json string
        if (is_string($value) && (($value = json_decode($value, true)) == false)) {
            throw new ValidationError(
                sprintf(static::ERROR_MESSAGE_INVALID_JSON, get_called_class())
            );
        }

        //if user passes StdClass
        if (is_object($value)) {
            $value = (array)$value;
        }

        // check if we have array at last
        if (!is_array($value)) {
            throw new ValidationError(
                sprintf(static::ERROR_MESSAGE_CORRUPTED_OBJECT, get_called_class())
            );
        }

        //Check if we have wrapper above object
        if (isset($value[static::$fieldName])) {
            $value = $value[static::$fieldName];
        }

        return new static($value);
    }
public static function factory($value)
    {
        // if user passes same object
        if ($value instanceof static) {
            return $value;
        }

        // if user passes json string
        if (is_string($value) && (($value = json_decode($value, true)) == false)) {
            throw new ValidationError(
                sprintf(static::ERROR_MESSAGE_INVALID_JSON, get_called_class())
            );
        }

        //if user passes StdClass
        if (is_object($value)) {
            $value = (array)$value;
        }

        // check if we have array at last
        if (!is_array($value)) {
            throw new ValidationError(
                sprintf(static::ERROR_MESSAGE_CORRUPTED_OBJECT, get_called_class())
            );
        }

        //Check if we have wrapper above object
        if (isset($value[static::$fieldName])) {
            $value = $value[static::$fieldName];
        }

        return new static($value);
    }
Factory method
@param array|string|static|\StdClass $value field data
@return static