These make more sense when implemented as traits.
Classes that extended this and had no expectation of a return value are now extended c_base_return.
All others are set to their most appropriate return type, such as c_base_return_string.
require_once('common/base/classes/base_error.php');
require_once('common/base/classes/base_return.php');
-require_once('common/base/classes/base_rfc_string.php');
+
+require_once('common/base/traits/base_rfc_string.php');
/**
* A generic class for providing classes that support a single array value.
*
* This does not use the traits t_base_return_value_exact or t_base_return_value because this is non-confirming to those traits.
*
- * @require class c_base_rfc_string
+ * @require class c_base_return_array
*/
-class c_base_array extends c_base_rfc_string {
+class c_base_array extends c_base_return {
+ use t_base_rfc_string;
+
protected $items;
/**
}
/**
- * @see: t_base_return_value::p_s_new()
- */
- public static function s_new($value) {
- return self::p_s_new($value, __CLASS__);
- }
-
- /**
- * @see: t_base_return_value::p_s_value()
- */
- public static function s_value($return) {
- return self::p_s_value($return, __CLASS__);
- }
-
- /**
- * @see: t_base_return_value_exact::p_s_value_exact()
- */
- public static function s_value_exact($return) {
- return self::p_s_value_exact($return, __CLASS__, '');
- }
-
- /**
* Assign the array.
*
* @param array $array
require_once('common/base/classes/base_error.php');
require_once('common/base/classes/base_return.php');
require_once('common/base/classes/base_ascii.php');
-require_once('common/base/classes/base_rfc_string.php');
+
+require_once('common/base/traits/base_rfc_string.php');
/**
* A generic class for managing the e-mail related functionality.
* @see: https://tools.ietf.org/html/rfc6854
* @see: https://tools.ietf.org/html/rfc7231#section-5.5.1
*
- * @require class c_base_rfc_string
* @require class c_base_ascii
* @require class c_base_utf8
*/
-class c_base_email extends c_base_rfc_string {
- use t_base_return_value_exact;
+class c_base_email extends c_base_return_string {
+ use t_base_rfc_string;
const LINE_LENGTH_LIMIT_SOFT = 78;
const LINE_LENGTH_LIMIT_HARD = 998;
}
/**
- * Assign the value.
- *
- * @param DOMNode $value
- * Any value so long as it is a DOMNode.
- * NULL is not allowed.
- *
- * @return bool
- * TRUE on success.
- * FALSE with error bit set is returned on error.
- */
- public function set_value($value) {
- if (!is_string($value)) {
- return FALSE;
- }
-
- $this->value = $value;
- return TRUE;
- }
-
- /**
- * Return the value.
- *
- * @return string|null $value
- * The value array stored within this class.
- */
- public function get_value() {
- if (!is_string($this->value)) {
- return NULL;
- }
-
- return $this->value;
- }
-
- /**
- * Return the value of the expected type.
- *
- * @return DOMNode $value
- * The value DOMNode stored within this class.
- */
- public function get_value_exact() {
- if (!is_string($this->value)) {
- return '';
- }
-
- return $this->value;
- }
-
- /**
* Decode and check that the given e-mail address is valid.
*
* Validation is done according to rfc5322, rfc6854, and rfc7231.
require_once('common/base/classes/base_error.php');
require_once('common/base/classes/base_return.php');
require_once('common/base/classes/base_charset.php');
-require_once('common/base/classes/base_rfc_string.php');
require_once('common/base/classes/base_utf8.php');
require_once('common/base/classes/base_languages.php');
require_once('common/base/classes/base_http_status.php');
require_once('common/base/classes/base_cookie.php');
require_once('common/base/classes/base_mime.php');
+require_once('common/base/traits/base_rfc_string.php');
+
/**
* A generic class for managing the HTTP protocol.
*
* @require class base_rfc_string
* @require class base_utf8
*/
-class c_base_http extends c_base_rfc_string {
+class c_base_http extends c_base_return {
+ use t_base_rfc_string;
+
// standard request headers
const REQUEST_NONE = 0;
const REQUEST_ACCEPT = 1;
}
/**
- * @see: t_base_return_value::p_s_new()
- */
- public static function s_new($value) {
- return self::p_s_new($value, __CLASS__);
- }
-
- /**
- * @see: t_base_return_value::p_s_value()
- */
- public static function s_value($return) {
- return self::p_s_value($return, __CLASS__);
- }
-
- /**
- * @see: t_base_return_value_exact::p_s_value_exact()
- */
- public static function s_value_exact($return) {
- return self::p_s_value_exact($return, __CLASS__, '');
- }
-
- /**
* Returns a list of HTTP headers that can be used as an HTML meta tag.
*
* The HTML language supports HTTP headers as HTML tags.
require_once('common/base/classes/base_return.php');
require_once('common/base/classes/base_mime.php');
require_once('common/base/classes/base_charset.php');
-require_once('common/base/classes/base_rfc_string.php');
+
+require_once('common/base/traits/base_rfc_string.php');
/**
* A generic class for html attribute types.
*
* @todo: add support for non-standard tag attributes, which will just be a string or NULL.
*/
-class c_base_markup_tag extends c_base_rfc_string {
+class c_base_markup_tag extends c_base_return {
+ use t_base_rfc_string;
+
const TYPE_NONE = 0;
const TYPE_A = 1;
const TYPE_ABBR = 2;
}
/**
- * @see: t_base_return_value::p_s_new()
- */
- public static function s_new($value) {
- return self::p_s_new($value, __CLASS__);
- }
-
- /**
- * @see: t_base_return_value::p_s_value()
- */
- public static function s_value($return) {
- return self::p_s_value($return, __CLASS__);
- }
-
- /**
- * @see: t_base_return_value_exact::p_s_value_exact()
- */
- public static function s_value_exact($return) {
- return self::p_s_value_exact($return, __CLASS__, '');
- }
-
- /**
* Assign the specified tag.
*
* @param int $attribute
require_once('common/base/classes/base_error.php');
require_once('common/base/classes/base_return.php');
-require_once('common/base/classes/base_rfc_string.php');
require_once('common/base/classes/base_http.php');
require_once('common/base/classes/base_database.php');
require_once('common/base/classes/base_session.php');
require_once('common/base/classes/base_array.php');
+require_once('common/base/traits/base_rfc_string.php');
+
/**
* A generic class for managing a menu.
*
* This can be converted to HTML <nav>, <menu>, or even breadcrumbs.
*/
-class c_base_menu extends c_base_rfc_string {
-
- /**
- * @see: t_base_return_value::p_s_new()
- */
- public static function s_new($value) {
- return self::p_s_new($value, __CLASS__);
- }
-
- /**
- * @see: t_base_return_value::p_s_value()
- */
- public static function s_value($return) {
- return self::p_s_value($return, __CLASS__);
- }
-
- /**
- * @see: t_base_return_value_exact::p_s_value_exact()
- */
- public static function s_value_exact($return) {
- return self::p_s_value_exact($return, __CLASS__, '');
- }
+class c_base_menu extends c_base_return {
+ use t_base_rfc_string;
/**
* Build the menu structure.
require_once('common/base/classes/base_cookie.php');
require_once('common/base/classes/base_array.php');
+require_once('common/base/traits/base_rfc_string.php');
+
/**
* A generic class for managing paths information.
*
*
* // c_base_utf8::s_substring($path_string, 0, 1);
*/
-class c_base_path extends c_base_rfc_string {
- use t_base_return_value_exact;
+class c_base_path extends c_base_return_string {
+ use t_base_rfc_string;
private const p_DEFAULT_ALLOWED_METHODS = [
c_base_http::HTTP_METHOD_GET => c_base_http::HTTP_METHOD_GET,
<?php
/**
* @file
- * Provides a class for managing common rfc character testing cases.
+ * Provides a trait for managing common rfc character testing cases.
*/
namespace n_koopa;
/**
- * A class for managing common rfc character testing cases.
+ * A trait for managing common rfc character testing cases.
*
* This currently utilizes some of the rules defined in the following rfcs:
* - rfc 4234
* @require class c_base_ascii
* @require class c_base_utf8
*/
-abstract class c_base_rfc_char extends c_base_return {
-
- /**
- * @see: t_base_return_value::p_s_new()
- */
- public static function s_new($value) {
- return self::p_s_new($value, __CLASS__);
- }
-
- /**
- * @see: t_base_return_value::p_s_value()
- */
- public static function s_value($return) {
- return self::p_s_value($return, __CLASS__);
- }
-
- /**
- * @see: t_base_return_value_exact::p_s_value_exact()
- */
- public static function s_value_exact($return) {
- return self::p_s_value_exact($return, __CLASS__, NULL);
- }
+trait t_base_rfc_char {
/**
* Check to see if character is: text.
<?php
/**
* @file
- * Provides a class for managing common rfc string testing cases.
+ * Provides a trait for managing common rfc string testing cases.
*/
namespace n_koopa;
require_once('common/base/classes/base_return.php');
require_once('common/base/classes/base_ascii.php');
require_once('common/base/classes/base_utf8.php');
-require_once('common/base/classes/base_rfc_char.php');
+
+require_once('common/base/traits/base_rfc_char.php');
/**
- * A class for managing common rfc string testing cases.
+ * A trait for managing common rfc string testing cases.
*
* This checks a a string of characters.
* The c_base_rf_string_is_* functions that require specific characters to start, such as DQUOTE, assume that the start position is after the initial special character, such as DQUOTE.
*
* @require class c_base_ascii
* @require class c_base_utf8
- * @require class c_base_rfc_char
*/
-abstract class c_base_rfc_string extends c_base_rfc_char {
- const STOP_AT_CLOSING_CHARACTER = -1;
-
- /**
- * @see: t_base_return_value::p_s_new()
- */
- public static function s_new($value) {
- return self::p_s_new($value, __CLASS__);
- }
-
- /**
- * @see: t_base_return_value::p_s_value()
- */
- public static function s_value($return) {
- return self::p_s_value($return, __CLASS__);
- }
-
- /**
- * @see: t_base_return_value_exact::p_s_value_exact()
- */
- public static function s_value_exact($return) {
- return self::p_s_value_exact($return, __CLASS__, NULL);
- }
+trait t_base_rfc_string {
+ use t_base_rfc_char;
/**
* Converts a string into a ordinals array and a characters array.
* @param int|null $stop
* (optional) The position in the arrays to stop checking.
* If NULL, then the entire string is processed.
- * If self::STOP_AT_CLOSING_CHARACTER, then stop at the end of a double quote and do no further processing.
+ * If -1, then stop at the end of a double quote and do no further processing.
*
* @return array
* The processed information, with comments separated:
$stop_at_closing_quote = FALSE;
if ($stop < 0) {
- if ($stop == static::STOP_AT_CLOSING_CHARACTER) {
+ if ($stop == -1) {
$stop_at_closing_quote = TRUE;
}
break;
}
- $parsed = $this->pr_rfc_string_is_quoted_string($ordinals, $characters, $result['current'], static::STOP_AT_CLOSING_CHARACTER);
+ $parsed = $this->pr_rfc_string_is_quoted_string($ordinals, $characters, $result['current'], -1);
$result['current'] = $parsed['current'];
if ($parsed['invalid']) {
return $result;
}
- $parsed = $this->pr_rfc_string_is_quoted_string($ordinals, $characters, $result['current'], static::STOP_AT_CLOSING_CHARACTER);
+ $parsed = $this->pr_rfc_string_is_quoted_string($ordinals, $characters, $result['current'], -1);
$result['current'] = $parsed['current'];
if ($parsed['invalid']) {
break;
}
- $parsed = $this->pr_rfc_string_is_quoted_string($ordinals, $characters, $result['current'], static::STOP_AT_CLOSING_CHARACTER);
+ $parsed = $this->pr_rfc_string_is_quoted_string($ordinals, $characters, $result['current'], -1);
$result['current'] = $parsed['current'];
if ($parsed['invalid']) {
break;
}
- $parsed = $this->pr_rfc_string_is_quoted_string($ordinals, $characters, $result['current'], static::STOP_AT_CLOSING_CHARACTER);
+ $parsed = $this->pr_rfc_string_is_quoted_string($ordinals, $characters, $result['current'], -1);
$result['current'] = $parsed['current'];
if ($parsed['invalid']) {
break;
}
- $parsed = $this->pr_rfc_string_is_quoted_string($ordinals, $characters, $result['current'], static::STOP_AT_CLOSING_CHARACTER);
+ $parsed = $this->pr_rfc_string_is_quoted_string($ordinals, $characters, $result['current'], -1);
$result['current'] = $parsed['current'];
if ($parsed['invalid']) {
/**
* A specific class for processing view results: v_log_users_self.
- *
- * @require class c_base_rfc_string
*/
class c_view_log_users_self extends c_base_view {