engine = new ABDS_SEO_Rules_Engine( $keywords ); } /** * Analyzes a parsed block tree and returns per-block recommendations. * * @param array $blocks parse_blocks() output. * @param string $focus_keyword Focus keyword (or phrase); keyword-dependent checks are skipped when empty. * @return array */ public function analyze( array $blocks, string $focus_keyword ): array { $units = ABDS_SEO_Block_Content_Adapter::units_from_blocks( $blocks ); $findings = $this->engine->evaluate( $units, $focus_keyword ); return array_map( array( $this, 'translate_finding' ), $findings ); } /** * Translates one of the engine's source-agnostic findings back into * this class's existing, block-specific return shape. `block_ref` was * `block_path` (an int[] position) until Priority 3.3 — renamed * because its value is now ABDS_SEO_Content_Ref::of(), a content hash, * and calling a hash a "path" would be misleading. The one JS consumer * (src/sidebar.js's findMatchingClientId()) was updated in the same * change. * * @param array{ref:string, kind:string, source_type:string, content_snippet:string, issue:string, severity:string} $finding Engine finding. * @return array{block_ref:string, block_type:string, content_snippet:string, issue:string, severity:string} */ protected function translate_finding( array $finding ): array { return array( 'block_ref' => $finding['ref'], 'block_type' => $finding['source_type'], 'content_snippet' => $finding['content_snippet'], 'issue' => $finding['issue'], 'severity' => $finding['severity'], ); } }