Automattic\WooCommerce\Internal\Api

QueryComplexityRule::fieldComplexity │ protected │ WC 1.0

Sum the complexity of a selection set's selections, saturating at {@see self::COMPLEXITY_CEILING}.

Method of the class: QueryComplexityRule{}

No Hooks.

Returns

int. The (possibly saturated) complexity.

Usage

// protected - for code of main (parent) or child class
$result = $this->fieldComplexity( $selection_set ): int;
$selection_set(SelectionSetNode) (required)
The selection set to score.

QueryComplexityRule::fieldComplexity() code WC 11.1.2

protected function fieldComplexity( SelectionSetNode $selection_set ): int {
	$complexity = 0;

	foreach ( $selection_set->selections as $selection ) {
		$complexity = $this->add_saturating( $complexity, $this->nodeComplexity( $selection ) );
	}

	return $complexity;
}