<?php
/**
 * @package Hafenstudios\Wellenbrecher
 */

namespace Hafenstudios\Wellenbrecher\Rules;

use Hafenstudios\Wellenbrecher\Engine\Context;
use Hafenstudios\Wellenbrecher\Engine\RuleResult;

defined( 'ABSPATH' ) || exit;

/**
 * Leerer User-Agent: kein Browser laesst den Header weg.
 */
class UaEmptyRule extends AbstractRule {

	public const ID             = 'ua_empty';
	public const DEFAULT_POINTS = 25;

	public function __construct( int $points = self::DEFAULT_POINTS ) {
		parent::__construct( $points );
	}

	public function id(): string {
		return self::ID;
	}

	public function stage(): int {
		return 1;
	}

	public function evaluate( Context $context ): RuleResult {
		return '' === trim( $context->server( 'user_agent' ) ) ? $this->hit() : $this->miss();
	}
}
