$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, 'message' => __( 'Fewer than three sections, so there is no emphasis pattern to read.', 'acrossai-abilities-manager' ), ); } $weights = array_map( static fn( array $r ): int => (int) $r['widget_count'], $rows ); $max = max( $weights ); $min = min( $weights ); $mean = array_sum( $weights ) / count( $weights ); $findings = array(); // Every section within one element of every other: nothing leads. if ( $max - $min <= 1 && $mean >= 1 ) { $findings[] = array( 'type' => 'flat_emphasis', 'weights' => $weights, 'severity' => 'medium', 'message' => sprintf( /* translators: %d: number of sections */ __( 'All %d sections carry almost identical weight, so none of them reads as the main one.', 'acrossai-abilities-manager' ), count( $rows ) ), ); } return array( 'findings' => $findings, 'recommendations' => array() === $findings ? array() : array( array( 'suggestion' => __( 'Let one section be clearly the largest — more space, fewer competing elements — so the page has somewhere to start.', 'acrossai-abilities-manager' ) ), ), 'score' => array() === $findings ? 100 : 70, 'extras' => array( 'section_weights' => $weights, 'mean_weight' => round( $mean, 2 ) ), ); } }