From d17cacea56114ef5053711f9fc04c893a2eaffee Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 8 Oct 2024 16:00:13 -0700 Subject: [PATCH] Remove now-unused method to get element minimum hights --- .../class-od-url-metric-group-collection.php | 43 ------------------- ...-class-od-url-metrics-group-collection.php | 23 ---------- 2 files changed, 66 deletions(-) diff --git a/plugins/optimization-detective/class-od-url-metric-group-collection.php b/plugins/optimization-detective/class-od-url-metric-group-collection.php index 7c4d042d1..aec416e44 100644 --- a/plugins/optimization-detective/class-od-url-metric-group-collection.php +++ b/plugins/optimization-detective/class-od-url-metric-group-collection.php @@ -81,7 +81,6 @@ final class OD_URL_Metric_Group_Collection implements Countable, IteratorAggrega * get_groups_by_lcp_element?: array, * get_common_lcp_element?: ElementData|null, * get_all_element_max_intersection_ratios?: array, - * get_all_element_minimum_heights?: array, * get_all_denormalized_elements?: array>, * } */ @@ -459,36 +458,6 @@ public function get_all_element_max_intersection_ratios(): array { return $result; } - /** - * Gets the minimum heights of all elements across all groups and their captured URL metrics. - * - * @since n.e.x.t - * - * @return array Keys are XPaths and values are the minimum heights. - */ - public function get_all_element_minimum_heights(): array { - if ( array_key_exists( __FUNCTION__, $this->result_cache ) ) { - return $this->result_cache[ __FUNCTION__ ]; - } - - $result = ( function () { - $elements_min_heights = array(); - foreach ( $this->get_all_denormalized_elements() as $xpath => $denormalized_elements ) { - $element_min_heights = array(); - foreach ( $denormalized_elements as list( $group, $url_metric, $element ) ) { - $element_min_heights[] = $element['boundingClientRect']['height']; - } - $elements_min_heights[ $xpath ] = count( $element_min_heights ) > 1 - ? (float) min( ...$element_min_heights ) - : $element_min_heights[0]; - } - return $elements_min_heights; - } )(); - - $this->result_cache[ __FUNCTION__ ] = $result; - return $result; - } - /** * Gets the max intersection ratio of an element across all groups and their captured URL metrics. * @@ -499,18 +468,6 @@ public function get_element_max_intersection_ratio( string $xpath ): ?float { return $this->get_all_element_max_intersection_ratios()[ $xpath ] ?? null; } - /** - * Gets the minimum height of an element across all groups and their captured URL metrics. - * - * @since n.e.x.t - * - * @param string $xpath XPath for the element. - * @return float Minimum height in pixels. - */ - public function get_element_minimum_height( string $xpath ): ?float { - return $this->get_all_element_minimum_heights()[ $xpath ] ?? null; - } - /** * Gets URL metrics from all groups flattened into one list. * diff --git a/plugins/optimization-detective/tests/test-class-od-url-metrics-group-collection.php b/plugins/optimization-detective/tests/test-class-od-url-metrics-group-collection.php index 8c2bac8df..c405a590c 100644 --- a/plugins/optimization-detective/tests/test-class-od-url-metrics-group-collection.php +++ b/plugins/optimization-detective/tests/test-class-od-url-metrics-group-collection.php @@ -788,29 +788,6 @@ public function data_provider_element_minimum_heights(): array { ); } - /** - * Test get_all_element_max_intersection_ratios() and get_element_max_intersection_ratio(). - * - * @covers ::get_all_element_minimum_heights - * @covers ::get_element_minimum_height - * - * @dataProvider data_provider_element_minimum_heights - * - * @param array $url_metrics URL metrics. - * @param array $expected Expected. - */ - public function test_get_all_element_minimum_heights( array $url_metrics, array $expected ): void { - $breakpoints = array( 480, 600, 782 ); - $sample_size = 3; - $group_collection = new OD_URL_Metric_Group_Collection( $url_metrics, $breakpoints, $sample_size, 0 ); - $actual = $group_collection->get_all_element_minimum_heights(); - $this->assertSame( $actual, $group_collection->get_all_element_minimum_heights(), 'Cached result is identical.' ); - $this->assertSame( $expected, $actual ); - foreach ( $expected as $expected_xpath => $expected_max_ratio ) { - $this->assertSame( $expected_max_ratio, $group_collection->get_element_minimum_height( $expected_xpath ) ); - } - } - /** * Test get_flattened_url_metrics(). *