Framework Support Utilities
The documentation is constantly evolving and updated alongside the project's progress. Since it is developed in parallel with the code, some sections may temporarily refer to earlier versions of the system-these are gradually adapted to the current state of the application. If you notice any outdated information, please report it or open an Issue / Pull Request.
Documentation
# Framework Support Utilities
The Dbm\Support source area contains small reusable helpers. Use a utility for its narrow purpose; it does not replace domain validation, authorization, parameterized database queries, or output escaping.
# ValueSanitizer and Sanitizer
ValueSanitizer offers static normalizers for text, email, slug, locale, country, currency, VAT number, postcode, phone, IP, URL, filename, path, number, and boolean values. For example:
$email = ValueSanitizer::email($input); // valid normalized email or null
$slug = ValueSanitizer::slug($input);
$enabled = ValueSanitizer::bool($input);
Sanitizer offers instance methods such as sanitizeView(), sanitizeToken(), sanitizeTags(), sanitizePath(), sanitizeInsert(), and sanitizeHTML(). The sanitizeView() method escapes HTML; even with its tag mode, it still applies HTML escaping. Sanitization is context-specific and is not a replacement for validation, HTML policy review, or SQL parameter binding.
# EnumHelper
EnumHelper caches enum cases and returns enum name/value pairs through getEnum(), or a single value through getEnumValue(). Invalid enum classes return an empty result and are logged.
# LazyLoaderTrait
LazyLoaderTrait memoizes a value created by a factory the first time a key is requested:
use Dbm\Support\Traits\LazyLoaderTrait;
final class ReportService
{
use LazyLoaderTrait;
protected function exporter(): Exporter
{
return $this->lazy('exporter', fn() => new Exporter());
}
}
The key is cached per object instance. Prefer normal constructor injection for required dependencies; lazy loading is useful only when construction is genuinely optional or deferred.