Automattic\WooCommerce\Internal\Api
QueryComplexityRule::add_saturating
Add two complexity scores, saturating at {@see self::COMPLEXITY_CEILING}.
Method of the class: QueryComplexityRule{}
No Hooks.
Returns
int. The saturated sum.
Usage
// private - for code of main (parent) class only $result = $this->add_saturating( $a, $b ): int;
- $a(int) (required)
- First score.
- $b(int) (required)
- Second score.
QueryComplexityRule::add_saturating() QueryComplexityRule::add saturating code WC 11.1.2
private function add_saturating( int $a, int $b ): int {
$sum = $a + $b;
// An int overflow turns the sum into a float, which is also above the ceiling.
return $sum > self::COMPLEXITY_CEILING ? self::COMPLEXITY_CEILING : (int) $sum;
}