public function toJson(array $options = null)
    {
        static $defaultOptions = null;

        if (null === $options) {
            if (null === $defaultOptions) {
                $defaultOptions = Utils::calculateBitmask(['JSON_PRETTY_PRINT', 'JSON_NUMERIC_CHECK']);
            }

            $options = $defaultOptions;
        } else {
            $options = Utils::calculateBitmask($options);
        }

        return json_encode($this->toArray(), $options);
    }
public function toJson(array $options = null)
    {
        static $defaultOptions = null;

        if (null === $options) {
            if (null === $defaultOptions) {
                $defaultOptions = Utils::calculateBitmask(['JSON_PRETTY_PRINT', 'JSON_NUMERIC_CHECK']);
            }

            $options = $defaultOptions;
        } else {
            $options = Utils::calculateBitmask($options);
        }

        return json_encode($this->toArray(), $options);
    }
@param null|string[] $options JSON encode option

@return string