# betterdocs/3.8.9/includes/Admin/Builder/Rule.php

BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ &amp; Chatbot, version 3.8.9. 48 lines.

- Page: https://pluginprobe.com/plugins/betterdocs/3.8.9/code/includes/Admin/Builder/Rule.php
- Raw: https://pluginprobe.com/plugins/betterdocs/3.8.9/raw/includes/Admin/Builder/Rule.php
- Modified: 2024-12-09T12:10:16+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/betterdocs/3.8.9/code/includes/Admin/Builder/Rule.php#L10-L20`.

```php
<?php

namespace WPDeveloper\BetterDocs\Admin\Builder;

use JsonSerializable;

class Rule implements JsonSerializable {
	public $condition;
	public $name;
	public $value;
	public function __construct( $condition, $name, $value ) {
		$this->condition = $condition;
		$this->name      = $name;
		$this->value     = $value;
	}

	public function add_value( $value ) {
		if ( ! is_array( $this->value ) ) {
			$this->value = [ $this->value ];
		}
		if ( is_a( $value, 'NotificationX\Core\Rule' ) ) {
			$value = $value->value;
		}
		if ( is_array( $value ) ) {
			$this->value = array_merge( $this->value, $value );
		} else {
			$this->value[] = $value;
		}
		$this->value = array_values( array_unique( $this->value ) );
	}

	public function can_add( $rule ) {
		if ( $this->condition == 'includes' && $this->condition == $rule->condition && $this->name == $rule->name ) {
			return true;
		}
		return false;
	}

	#[\ReturnTypeWillChange]
	public function jsonSerialize() {
		return [
			$this->condition,
			$this->name,
			$this->value
		];
	}
}

```
