<?php
/**
 * Boolean Helper Class
 *
 * @package     EasyInvoice
 * @author      Your Name
 * @copyright   Copyright (c) 2023, Your Company
 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
 * @since       1.0.0
 */

namespace EasyInvoice\Helpers;

/**
 * Boolean Helper
 *
 * Handles boolean value conversions and checks.
 *
 * @since 1.0.0
 */
class BooleanHelper {
    
    /**
     * Convert various boolean values to a consistent boolean
     *
     * @since 1.0.0
     * @param mixed $value The value to convert to boolean
     * @return bool
     */
    public static function toBoolean($value): bool {
        if (is_bool($value)) {
            return $value;
        }
        
        if (is_string($value)) {
            return in_array(strtolower($value), ['true', '1', 'yes', 'on'], true);
        }
        
        if (is_numeric($value)) {
            return (bool) $value;
        }
        
        return false;
    }
    
    /**
     * Check if a value represents a true boolean
     *
     * @since 1.0.0
     * @param mixed $value The value to check
     * @return bool
     */
    public static function isTrue($value): bool {
        return self::toBoolean($value);
    }
    
    /**
     * Check if a value represents a false boolean
     *
     * @since 1.0.0
     * @param mixed $value The value to check
     * @return bool
     */
    public static function isFalse($value): bool {
        return !self::toBoolean($value);
    }
} 