Skip to content

Commit 5458c3f

Browse files
committed
MAGE-1258 Add PHPDoc to clarify method intent
1 parent 5c5e37f commit 5458c3f

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

Service/Product/FacetBuilder.php

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ public function __construct(
3434
{}
3535

3636
/**
37-
* @param int $storeId
37+
* Return the configuration to be used for the store product index `attributesForFaceting`
38+
* @param int $storeId - The store ID for the index to be configured
3839
* @return string[]
3940
* @throws LocalizedException
4041
* @throws NoSuchEntityException
@@ -50,7 +51,8 @@ function($facet) {
5051
}
5152

5253
/**
53-
* @param int $storeId
54+
* Return the configuration to be used for the store product index `renderingContent`
55+
* @param int $storeId - The store ID for the index to be configured
5456
* @return array<string, array>|null
5557
* @throws LocalizedException
5658
* @throws NoSuchEntityException
@@ -73,6 +75,8 @@ public function getRenderingContent(int $storeId): ?array
7375
}
7476

7577
/**
78+
* For an array of facet data, return an array of attribute names only
79+
*
7680
* @param array<array<string, mixed>> $facets
7781
* @return string[]
7882
*/
@@ -87,8 +91,9 @@ function($facet) {
8791
}
8892

8993
/**
94+
* Format the facet data to be : renderingContent > facetOrdering > values
9095
* @param string[] $attributes
91-
* @return array<string, array>
96+
* @return array<string, array> - Array key is the attribute name and the value is an object containing a `sortRemainingBy` value
9297
*/
9398
protected function getRenderingContentValues(array $attributes): array
9499
{
@@ -99,6 +104,7 @@ protected function getRenderingContentValues(array $attributes): array
99104
}
100105

101106
/**
107+
* Take raw facet (common) attributes and convert to include attributes specifically needed for `renderingContent`
102108
* @param string[] $facets
103109
* @return string[]
104110
*/
@@ -128,9 +134,11 @@ protected function getCategoryAttributeNameForRenderingContent(): string
128134
}
129135

130136
/**
137+
* Return an associative array for an attribute that mimics the minimum structure used by the Magento configuration
138+
*
131139
* @param string $attribute
132140
* @param bool $searchable
133-
* @return array<string, string>
141+
* @return array{attribute: string, searchable: string}
134142
*/
135143
protected function getRawFacet(string $attribute, bool $searchable = false): array
136144
{
@@ -141,7 +149,7 @@ protected function getRawFacet(string $attribute, bool $searchable = false): arr
141149
}
142150

143151
/**
144-
* Generates common data to be used for both attributesForFaceting and renderingContent
152+
* Generates common data to be used for both `attributesForFaceting` and `renderingContent`
145153
*
146154
* @return array<array<string, mixed>>
147155
* @throws NoSuchEntityException
@@ -174,6 +182,8 @@ function(string $attribute) {
174182
}
175183

176184
/**
185+
* Does a given array of facets include a category facet?
186+
*
177187
* @param array<array<string, mixed>> $facets
178188
* @return bool
179189
*/
@@ -186,7 +196,7 @@ protected function hasCategoryFacet(array $facets): bool
186196

187197
/**
188198
* Applies the category facet if not manually configured but necessary for category functionality
189-
* (The presence of the category facet drives logic for attributesForFaceting and renderingContent)
199+
* (The presence of the category facet drives logic for `attributesForFaceting` and `renderingContent`)
190200
*
191201
* @param int $storeId
192202
* @param array<array<string, mixed>> $facets
@@ -204,7 +214,7 @@ protected function assertCategoryFacet(int $storeId, array $facets): array
204214
}
205215

206216
/**
207-
* Add merchandising facets as needed for attributesForFaceting
217+
* Add merchandising facets as needed for `attributesForFaceting`
208218
*
209219
* @param int $storeId
210220
* @param array<array<string, mixed>> $facets
@@ -228,6 +238,8 @@ protected function addMerchandisingFacets(int $storeId, array $facets): array
228238
}
229239

230240
/**
241+
* Get an array of pricing attribute names based on currency and customer group configuration
242+
*
231243
* @param int $storeId
232244
* @return string[]
233245
* @throws NoSuchEntityException
@@ -246,6 +258,8 @@ protected function getPricingAttributes(int $storeId): array
246258
}
247259

248260
/**
261+
* Get an array of pricing attribute names based on customer group configuration
262+
*
249263
* @param int $storeId
250264
* @param string $currencyCode
251265
* @return string[]
@@ -271,6 +285,8 @@ protected function getGroupPricingAttributes(int $storeId, string $currencyCode)
271285

272286

273287
/**
288+
* Format the `attributesForFaceting` values based on modifiers defined at:
289+
* https://www.algolia.com/doc/api-reference/api-parameters/attributesForFaceting/#modifiers
274290
* @param array<string, string|int> $facet
275291
* @return string
276292
*/

0 commit comments

Comments
 (0)