@@ -51,7 +51,7 @@ final class OD_URL_Metric_Group_Collection implements Countable, IteratorAggrega
51
51
* value of 1, and the breakpoints are used as the maximum viewport widths for the viewport groups, with the addition of
52
52
* a final viewport group which has a maximum viewport width of infinity.
53
53
*
54
- * This array may be empty in which case there are no responsive breakpoints and all URL Metrics are collected in a
54
+ * This array may be empty, in which case there are no responsive breakpoints, and all URL Metrics are collected in a
55
55
* single group.
56
56
*
57
57
* @since 0.1.0
@@ -153,7 +153,7 @@ public function __construct( array $url_metrics, string $current_etag, array $br
153
153
*/
154
154
$ this ->breakpoints = $ breakpoints ;
155
155
156
- // Set sample size.
156
+ // Set the sample size.
157
157
if ( $ sample_size <= 0 ) {
158
158
throw new InvalidArgumentException (
159
159
esc_html (
@@ -211,7 +211,7 @@ public function get_sample_size(): int {
211
211
}
212
212
213
213
/**
214
- * Gets the freshness age (TTL) for a given URL Metric..
214
+ * Gets the freshness age (TTL) for a given URL Metric.
215
215
*
216
216
* @since 1.0.0
217
217
*
@@ -224,7 +224,7 @@ public function get_freshness_ttl(): int {
224
224
/**
225
225
* Gets the first URL Metric group (with the lowest minimum viewport width, e.g. for mobile).
226
226
*
227
- * This group normally represents viewports for mobile devices. This group always has a minimum viewport width of 0
227
+ * This group normally represents viewports for mobile devices. This group always has a minimum viewport width of 0,
228
228
* and the maximum viewport width corresponds to the smallest defined breakpoint returned by
229
229
* {@see od_get_breakpoint_max_widths()}.
230
230
*
@@ -241,7 +241,7 @@ public function get_first_group(): OD_URL_Metric_Group {
241
241
*
242
242
* This group normally represents viewports for desktop devices. This group always has a minimum viewport width
243
243
* defined as one greater than the largest breakpoint returned by {@see od_get_breakpoint_max_widths()}.
244
- * The maximum viewport width of this group is always `null`, or in other words it is unbounded.
244
+ * The maximum viewport width of this group is always `null`, or in other words, it is unbounded.
245
245
*
246
246
* @since 0.7.0
247
247
*
@@ -404,7 +404,7 @@ public function is_every_group_populated(): bool {
404
404
/**
405
405
* Checks whether every group is complete (full sample of non-stale URL Metrics).
406
406
*
407
- * Completeness means the full sample size of URL Metrics has been collected,
407
+ * Completeness means the full sample size of URL Metrics has been collected;
408
408
* none of the collected URL Metrics are stale (with a mismatching ETag or a
409
409
* timestamp older than the freshness TTL).
410
410
*
@@ -520,9 +520,9 @@ public function get_common_lcp_element(): ?OD_Element {
520
520
/**
521
521
* Gets all elements from all URL Metrics from all groups keyed by the elements' XPaths.
522
522
*
523
- * This is an O(n^3) function so its results must be cached. This being said, the number of groups should be 4 (one
524
- * more than the default number of breakpoints) and the number of URL Metrics for each group should be 3
525
- * (the default sample size). Therefore, given the number (n) of visited elements on the page this will only
523
+ * This is an O(n^3) function, so its results must be cached. This being said, the number of groups should be 4 (one
524
+ * more than the default number of breakpoints), and the number of URL Metrics for each group should be 3
525
+ * (the default sample size). Therefore, given the number (n) of visited elements on the page, this will only
526
526
* end up running n*4*3 times.
527
527
*
528
528
* @since 0.7.0
@@ -584,8 +584,8 @@ public function get_all_element_max_intersection_ratios(): array {
584
584
*
585
585
* An element is positioned in the initial viewport if its `boundingClientRect.top` is less than the
586
586
* `viewport.height` for any of its recorded URL Metrics. Note that even though the element may be positioned in the
587
- * initial viewport, it may not actually be visible. It could be occluded as a latter slide in a carousel in which
588
- * case it will have intersectionRatio of 0. Or the element may not be visible due to it or an ancestor having the
587
+ * initial viewport, it may not actually be visible. It could be occluded as a latter slide in a carousel, in which
588
+ * case it will have an intersectionRatio of 0. Or the element may not be visible due to it or an ancestor having the
589
589
* `visibility:hidden` style, such as in the case of a dropdown navigation menu. When, for example, an IMG element
590
590
* is positioned in any initial viewport, it should not get `loading=lazy` but rather `fetchpriority=low`.
591
591
* Furthermore, the element may be positioned _above_ the initial viewport or to the left or right of the viewport,
@@ -624,7 +624,7 @@ public function get_all_elements_positioned_in_any_initial_viewport(): array {
624
624
* @since 0.3.0
625
625
*
626
626
* @param string $xpath XPath for the element.
627
- * @return float|null Max intersection ratio of null if tag is unknown (not captured).
627
+ * @return float|null Max intersection ratio or null if the tag is unknown (not captured).
628
628
*/
629
629
public function get_element_max_intersection_ratio ( string $ xpath ): ?float {
630
630
return $ this ->get_all_element_max_intersection_ratios ()[ $ xpath ] ?? null ;
@@ -636,7 +636,7 @@ public function get_element_max_intersection_ratio( string $xpath ): ?float {
636
636
* @since 0.7.0
637
637
*
638
638
* @param string $xpath XPath for the element.
639
- * @return bool|null Whether element is positioned in any initial viewport of null if unknown.
639
+ * @return bool|null Whether an element is positioned in any initial viewport or null if unknown.
640
640
*/
641
641
public function is_element_positioned_in_any_initial_viewport ( string $ xpath ): ?bool {
642
642
return $ this ->get_all_elements_positioned_in_any_initial_viewport ()[ $ xpath ] ?? null ;
@@ -651,8 +651,8 @@ public function is_element_positioned_in_any_initial_viewport( string $xpath ):
651
651
*/
652
652
public function get_flattened_url_metrics (): array {
653
653
// The duplication of iterator_to_array is not a mistake. This collection is an
654
- // iterator and the collection contains iterator instances. So to flatten the
655
- // two levels of iterators we need to nest calls to iterator_to_array().
654
+ // iterator, and the collection contains iterator instances. So to flatten the
655
+ // two levels of iterators, we need to nest calls to iterator_to_array().
656
656
return array_merge (
657
657
...array_map (
658
658
'iterator_to_array ' ,
0 commit comments