$model * @param int $post_id * @param string $subtree_id * @return array */ protected function analyze( array $model, int $post_id, string $subtree_id ): array { $rows = $model['rows']; if ( count( $rows ) < 3 ) { return array( 'findings' => array(), 'score' => 100 ); } $weights = array_map( static fn( array $r ): int => (int) $r['widget_count'], $rows ); $mean = array_sum( $weights ) / max( 1, count( $weights ) ); $rivals = array_values( array_filter( $rows, static fn( array $r ): bool => ! empty( $r['has_background'] ) && (int) $r['widget_count'] >= $mean ) ); $findings = array(); if ( count( $rivals ) >= 3 ) { $findings[] = array( 'type' => 'competing_climaxes', 'rows' => array_map( static fn( array $r ): string => (string) $r['id'], $rivals ), 'severity' => count( $rivals ) >= 5 ? 'medium' : 'low', 'message' => sprintf( /* translators: %d: number of sections */ __( '%d sections are both backgrounded and above average weight, so several are competing to be the focal point.', 'acrossai-abilities-manager' ), count( $rivals ) ), ); } return array( 'findings' => $findings, 'recommendations' => array() === $findings ? array() : array( array( 'suggestion' => __( 'Let the quieter sections be quiet. Dropping the background on two of these gives the remaining one somewhere to stand out from.', 'acrossai-abilities-manager' ) ), ), 'score' => max( 0, 100 - max( 0, count( $rivals ) - 2 ) * 12 ), ); } }