#                                     Copyright 2025 WebPros International, LLC
#                                                           All rights Reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

# BEGIN AUGMENT GENERATED CODE
package Cpanel::Plugins::Components::Rules::False;
use cPstrict;

use Moo;
extends 'Cpanel::Plugins::Components::Rules::Base';

=head1 MODULE

C<Cpanel::Plugins::Components::Rules::False>

=head1 DESCRIPTION

A rule that always evaluates to false. This rule is useful for testing purposes,
default deny conditions, or as a placeholder in rule configurations where
unconditional access should be denied.

This class is used when a rule includes a 'false' entry in the configuration.

=head1 SYNOPSIS

Always deny access regardless of any conditions:

  use Cpanel::Plugins::Components::Rules::False;
  my $return = Cpanel::Plugins::Components::Rules::False->new()->is_allowed();
  # $return will always be 0 (false)

When using the declarative JSON syntax:

  {
    "false": 1
  }

Or in array format:

  [
    "false", 1
  ]

The False rule ignores any configuration parameters and always returns false.
This makes it useful for:
- Testing rule evaluation systems
- Providing default deny behavior
- Temporarily disabling features during development or maintenance
- Creating explicit deny conditions in complex rule hierarchies

=cut

=head1 METHODS

=over

=item * is_allowed -- Always returns false

    RETURNS
        0 - Always returns false, regardless of configuration or context

    NOTES
        This rule is designed to always fail. It can be used with any
        configuration value, but the configuration is ignored.

=back

=cut

around BUILDARGS => sub {
    my ( $orig, $class, @args ) = @_;

    return { config => 1 }
      if @args == 0 || @args == 1 && ( !ref $args[0] || ref $args[0] ne 'HASH' );

    return { config => $args[0] }
      if @args == 1 && ref $args[0] eq 'HASH';

      my %args = @args;
    return $class->$orig(%args);
};

=head2 is_allowed

Always returns false (0). This method ignores all configuration parameters
and context, making it suitable for unconditional deny scenarios.

The False rule is particularly useful in rule systems where you need:
- A guaranteed negative result for testing
- Default deny behavior when other conditions are not met
- Temporary disabling of features during maintenance
- Explicit deny conditions in rule hierarchies

=cut

sub is_allowed ($self) {

    # Always return false - this rule always fails
    # The !!0 ensures we return a proper boolean false value
    return !!0;
}

1;

# END AUGMENT GENERATED CODE
