Oihana PHP Enums

Boolean uses ConstantsTrait

A simple enumeration of string representations for boolean values: `"true"` and `"false"`.

This class is useful when working with systems that expect boolean values in string format (e.g. JSON, configuration files, XML, CLI flags, or external APIs).

By providing symbolic constants instead of hardcoded strings, it improves code clarity, consistency, and reduces the risk of typos.

Example:

use oihana\enums\Boolean;

$enabled = Boolean::TRUE;
$disabled = Boolean::FALSE;

echo $enabled;  // Outputs: true

Features:

  • Uses ConstantsTrait to support reflection and dynamic access to constants.
  • Promotes semantic clarity in systems that serialize booleans as strings.
Tags
author

Marc Alcaraz (ekameleon)

since
1.0.0

Table of Contents

Constants

FALSE  : string = 'false'
TRUE  : string = 'true'

Constants

On this page

Search results