$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']; $total = count( $rows ); if ( $total < 3 ) { return array( 'findings' => array(), 'score' => 100 ); } $surfaced = array_values( array_filter( $rows, static fn( array $r ): bool => ! empty( $r['has_background'] ) ) ); $share = count( $surfaced ) / $total; $findings = array(); if ( $share >= 0.75 ) { $findings[] = array( 'type' => 'surface_overuse', 'rows' => array_map( static fn( array $r ): string => (string) $r['id'], $surfaced ), 'share' => round( $share, 2 ), 'severity' => 'low', 'message' => sprintf( /* translators: 1: backgrounded sections, 2: total sections */ __( '%1$d of %2$d sections carry a background, so the treatment no longer separates anything.', 'acrossai-abilities-manager' ), count( $surfaced ), $total ), ); } return array( 'findings' => $findings, 'recommendations' => array() === $findings ? array() : array( array( 'suggestion' => __( 'Return some sections to the page background. A panel only reads as a panel when something next to it is not one.', 'acrossai-abilities-manager' ) ), ), 'score' => (int) round( 100 - max( 0, $share - 0.6 ) * 100 ), 'extras' => array( 'backgrounded' => count( $surfaced ), 'sections' => $total ), ); } }