By utilizing __toString(), all classes using t_base_return can now be directly used as a string.
This saves the effort of writing $my_class->get_value() or $my_class->get_value_exact().
This directly returns the private value as a string, which is probably faster than returning an object and then calling a function to convert.
Complex types, such as array, object, or resource, or converted to an empty string and must still be handled via function calls.
return self::p_s_value_exact($return, __CLASS__, []);
}
+ /**
+ * Provide to string object override.
+ *
+ * @return string
+ * An empty string.
+ *
+ * @see: http://php.net/manual/en/language.oop5.magic.php@object.tostring
+ */
+ public function __toString() {
+ return "";
+ }
+
/**
* Assign the value.
*
return self::p_s_value($return, __CLASS__);
}
+ /**
+ * Provide to string object override.
+ *
+ * @return string
+ * An empty string.
+ *
+ * @see: http://php.net/manual/en/language.oop5.magic.php@object.tostring
+ */
+ public function __toString() {
+ return "";
+ }
+
/**
* Assign the value.
*
return self::p_s_value($return, __CLASS__);
}
+ /**
+ * Provide to string object override.
+ *
+ * @return string
+ * An empty string.
+ *
+ * @see: http://php.net/manual/en/language.oop5.magic.php@object.tostring
+ */
+ public function __toString() {
+ return "";
+ }
+
/**
* Assign the value.
*
trait t_base_return_value {
protected $value;
+ /**
+ * Provide to string object override.
+ *
+ * @return string
+ * The string representation of the value contained in this object.
+ *
+ * @see: http://php.net/manual/en/language.oop5.magic.php@object.tostring
+ */
+ public function __toString() {
+ return strval($this->value);
+ }
+
/**
* Assign the value.
*