$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 ) < 2 ) { return array( 'findings' => array(), 'score' => null, 'message' => __( 'Too few sections to score distinctiveness. A null score means not assessed.', 'acrossai-abilities-manager' ), ); } $shapes = array_map( static fn( array $r ): string => $r['ratio'] . ':' . $r['lane_count'], $rows ); $shape_variety = count( array_unique( $shapes ) ) / count( $shapes ); $ratios = array_values( array_filter( array_map( static fn( array $r ): string => (string) $r['ratio'], $rows ) ) ); $ratio_variety = array() === $ratios ? 1.0 : count( array_unique( $ratios ) ) / count( $ratios ); $types = (array) $model['widget_types']; $furniture = 0; foreach ( Design_Model::FURNITURE_WIDGETS as $widget ) { $furniture += (int) ( $types[ $widget ] ?? 0 ); } $total = max( 1, (int) $model['widget_count'] ); $density = min( 1.0, $furniture / $total ); $components = array( 'shape_variety' => round( $shape_variety, 3 ), 'ratio_variety' => round( $ratio_variety, 3 ), 'furniture_density' => round( $density, 3 ), ); $score = (int) round( ( $shape_variety * 45 ) + ( $ratio_variety * 35 ) + ( ( 1 - $density ) * 20 ) ); return array( 'findings' => array(), 'score' => max( 0, min( 100, $score ) ), 'recommendations' => $score >= 70 ? array() : array( array( 'suggestion' => __( 'The page repeats a small number of structural shapes. Varying one section\u2019s composition raises this more than any amount of restyling.', 'acrossai-abilities-manager' ) ), ), 'extras' => array( 'components' => $components, 'basis' => __( 'Structural signals only — this cannot see colour, typography, imagery or copy.', 'acrossai-abilities-manager' ), ), ); } }