---
title: Cpanel::Plugins::Components::Rules Class Heirarchy Diagram
generateBy: augment
displayMode: compact
config:
  layout: elk
  elk:
    mergeEdges: true
    nodePlacementStrategy: LINEAR_SEGMENTS
classDiagram:
  displayMode: compact
---
classDiagram
    direction LR

    %% Top level - Main entry point
    class Rules {
        +config: HashRef|ArrayRef
        +campaign_id: Str
        +new(config_file?: Str, config?: HashRef|ArrayRef, campaign_id?: Str)
        +is_allowed(): Bool
        +load_config(args: HashRef): HashRef
    }

    %% Base class - Second level
    class Base {
        +config: Any
        +campaign_id: Str
        +new(config: Any, campaign_id?: Str)
        +normalize(config: Any): Any
        +get_module_name(rule: Str): Str
        +process_rule(rule_name: Str, rule_arg: Any): Bool
        +load_module(module: Str, rule: Str): Bool
    }

    %% Third level - Logical operators
    class And {
        +is_allowed(): Bool
    }

    class Or {
        +is_allowed(): Bool
    }

    class Not {
        +is_allowed(): Bool
    }

    %% Fourth level - Boolean rules
    class True {
        +is_allowed(): Bool
    }

    class False {
        +is_allowed(): Bool
    }

    %% Fifth level - System rules (left column)
    class CompanyId {
        +is_allowed(): Bool
    }

    class CpanelVersion {
        +is_allowed(): Bool
    }

    class CompareVersion {
        +is_allowed(): Bool
    }

    class Distributions {
        +is_allowed(): Bool
    }

    class DnsOnly {
        +is_allowed(): Bool
    }

    class Tiers {
        +is_allowed(): Bool
    }

    %% Fifth level - Feature rules (middle column)
    class FeatureEnabled {
        +is_allowed(): Bool
    }

    class FeatureFlag {
        +is_allowed(): Bool
    }

    class PluginEnabled {
        +is_allowed(): Bool
    }

    class IsBeta {
        +is_allowed(): Bool
        -_get_config_file(plugin: Str): Str
        -_read_config(config_file: Str): HashRef
    }

    %% Fifth level - Specialized rules (right column)
    class DateRange {
        +is_allowed(): Bool
        -_convert_date_to_epoch(date_mmddyyyy: Str): Int
    }

    class Personalization {
        +is_allowed(): Bool
        +to_boolean(value: Any): Bool
    }

    class Filter {
        <<abstract>>
        +is_allowed(): Bool
        +apply_filter(rule_result: Bool, config: HashRef): Bool
    }

    class Operator {
        +new(config: Any)
    }

    %% Sixth level - Filter implementations
    class Random {
        +is_allowed(): Bool
        +apply_filter(rule_result: Bool, config: HashRef): Bool
        -_get_cache_file(config: HashRef): Str
        -_load_cache(cache_file: Str): HashRef
        -_save_cache(cache_file: Str, data: HashRef): Void
        -_generate_server_hash(): Str
        -_is_server_selected(server_hash: Str, sample_size: Int, fleet_size: Int): Bool
    }

    %% Utility classes - Bottom level
    class Normalize {
        <<utility>>
        +normalize(config: Any): Any
        +normalize_children(config: ArrayRef): Void
    }

    class NVData {
        <<utility>>
        +set_nv_data(store: Str, key: Str, value: Str): Bool
        +get_nv_data(store: Str, name: Str): Str
    }

    class FilterUtil {
        <<utility>>
        +find_date_range(processed_rule: HashRef, operator: Str): HashRef
    }

    class FindStartDate {
        <<utility>>
        +get_start_date(campaign_id: Str): Str
        +process_start_date(campaign_id: Str, processed_rule: HashRef): Void
        +compare_start_date(nv_date: Str, rule_date: Str): Bool
        -_get_start_date(date_range: ArrayRef): Str
    }

    %% External APIs - Far bottom
    class PersonalizationAPI {
        <<external>>
        +personalization_get()
        +personalization_set()
    }

    class CompanyIDAPI {
        <<external>>
        +get_company_id()
    }

    class VersionAPI {
        <<external>>
        +getversionnumber()
    }

    class OSAPI {
        <<external>>
        +distro()
        +major()
        +minor()
    }

    class ServerTypeAPI {
        <<external>>
        +is_dnsonly()
    }

    class UpdateConfigAPI {
        <<external>>
        +get_tier()
    }

    class FeaturesAPI {
        <<external>>
        +check_feature_for_user()
    }

    class FeatureFlagsAPI {
        <<external>>
        +is_feature_enabled()
    }

    class PluginsStateAPI {
        <<external>>
        +is_enabled()
    }

    class TimeLocalAPI {
        <<external>>
        +timelocal()
    }

    %% Main inheritance hierarchy - vertical flow
    Rules --|> Base

    %% Logical operators inherit from Base
    Base <|-- And
    Base <|-- Or
    Base <|-- Not

    %% Boolean rules inherit from Base
    Base <|-- True
    Base <|-- False

    %% System rules inherit from Base
    Base <|-- CompanyId
    Base <|-- CpanelVersion
    Base <|-- CompareVersion
    Base <|-- Distributions
    Base <|-- DnsOnly
    Base <|-- Tiers

    %% Feature rules inherit from Base
    Base <|-- FeatureEnabled
    Base <|-- FeatureFlag
    Base <|-- PluginEnabled
    Base <|-- IsBeta

    %% Specialized rules inherit from Base
    Base <|-- DateRange
    Base <|-- Personalization
    Base <|-- Filter
    Base <|-- Operator

    %% Filter inheritance
    Filter <|-- Random

    %% Utility dependencies - vertical connections
    Base --|> Normalize
    And --|> FilterUtil
    And --|> FindStartDate
    Or --|> FilterUtil
    Or --|> FindStartDate
    Not --|> NVData
    FindStartDate --|> NVData
    FilterUtil --|> NVData
    IsBeta --|> Rules

    %% External API dependencies - vertical connections
    Personalization --|> PersonalizationAPI
    CompanyId --|> CompanyIDAPI
    CpanelVersion --|> VersionAPI
    CompareVersion --|> VersionAPI
    Distributions --|> OSAPI
    DnsOnly --|> ServerTypeAPI
    Tiers --|> UpdateConfigAPI
    FeatureEnabled --|> FeaturesAPI
    FeatureFlag --|> FeatureFlagsAPI
    PluginEnabled --|> PluginsStateAPI
    DateRange --|> TimeLocalAPI
