Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encapsulate the facet distribution and facet stats in our own objects #60

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions src/Engine/FacetDistribution.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?php

declare(strict_types=1);

namespace Setono\SyliusMeilisearchPlugin\Engine;

use Webmozart\Assert\Assert;

/**
* @implements \IteratorAggregate<string, FacetValues>
* @implements \ArrayAccess<string, FacetValues>
*/
final class FacetDistribution implements \Countable, \IteratorAggregate, \ArrayAccess
{
/** @var array<string, FacetValues> */
private array $facetValues = [];

/**
* @param array<string, mixed> $facetDistribution
*/
public function __construct(array $facetDistribution)

Check warning on line 21 in src/Engine/FacetDistribution.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetDistribution.php#L21

Added line #L21 was not covered by tests
{
foreach ($facetDistribution as $facet => $facetValues) {
Assert::isArray($facetValues);

Check warning on line 24 in src/Engine/FacetDistribution.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetDistribution.php#L23-L24

Added lines #L23 - L24 were not covered by tests

$this->facetValues[$facet] = new FacetValues($facet, $facetValues);

Check warning on line 26 in src/Engine/FacetDistribution.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetDistribution.php#L26

Added line #L26 was not covered by tests
}
}

/**
* @psalm-assert-if-true FacetValues $this->facetValues[$facet]
*/
public function has(string $facet): bool

Check warning on line 33 in src/Engine/FacetDistribution.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetDistribution.php#L33

Added line #L33 was not covered by tests
{
return isset($this->facetValues[$facet]);

Check warning on line 35 in src/Engine/FacetDistribution.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetDistribution.php#L35

Added line #L35 was not covered by tests
}

public function get(string $facet): FacetValues

Check warning on line 38 in src/Engine/FacetDistribution.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetDistribution.php#L38

Added line #L38 was not covered by tests
{
if (!$this->has($facet)) {
throw new \InvalidArgumentException(sprintf('Facet "%s" does not exist', $facet));

Check warning on line 41 in src/Engine/FacetDistribution.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetDistribution.php#L40-L41

Added lines #L40 - L41 were not covered by tests
}

return $this->facetValues[$facet];

Check warning on line 44 in src/Engine/FacetDistribution.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetDistribution.php#L44

Added line #L44 was not covered by tests
}

/**
* @return \ArrayIterator<string, FacetValues>
*/
public function getIterator(): \ArrayIterator

Check warning on line 50 in src/Engine/FacetDistribution.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetDistribution.php#L50

Added line #L50 was not covered by tests
{
return new \ArrayIterator($this->facetValues);

Check warning on line 52 in src/Engine/FacetDistribution.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetDistribution.php#L52

Added line #L52 was not covered by tests
}

public function count(): int

Check warning on line 55 in src/Engine/FacetDistribution.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetDistribution.php#L55

Added line #L55 was not covered by tests
{
return count($this->facetValues);

Check warning on line 57 in src/Engine/FacetDistribution.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetDistribution.php#L57

Added line #L57 was not covered by tests
}

public function isEmpty(): bool

Check warning on line 60 in src/Engine/FacetDistribution.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetDistribution.php#L60

Added line #L60 was not covered by tests
{
return [] === $this->facetValues;

Check warning on line 62 in src/Engine/FacetDistribution.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetDistribution.php#L62

Added line #L62 was not covered by tests
}

public function offsetExists(mixed $offset): bool

Check warning on line 65 in src/Engine/FacetDistribution.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetDistribution.php#L65

Added line #L65 was not covered by tests
{
return $this->has($offset);

Check warning on line 67 in src/Engine/FacetDistribution.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetDistribution.php#L67

Added line #L67 was not covered by tests
}

public function offsetGet(mixed $offset): FacetValues

Check warning on line 70 in src/Engine/FacetDistribution.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetDistribution.php#L70

Added line #L70 was not covered by tests
{
return $this->get($offset);

Check warning on line 72 in src/Engine/FacetDistribution.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetDistribution.php#L72

Added line #L72 was not covered by tests
}

public function offsetSet(mixed $offset, mixed $value): void

Check warning on line 75 in src/Engine/FacetDistribution.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetDistribution.php#L75

Added line #L75 was not covered by tests
{
throw new \LogicException('You cannot set an offset');

Check warning on line 77 in src/Engine/FacetDistribution.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetDistribution.php#L77

Added line #L77 was not covered by tests
}

public function offsetUnset(mixed $offset): void

Check warning on line 80 in src/Engine/FacetDistribution.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetDistribution.php#L80

Added line #L80 was not covered by tests
{
throw new \LogicException('You cannot unset an offset');

Check warning on line 82 in src/Engine/FacetDistribution.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetDistribution.php#L82

Added line #L82 was not covered by tests
}
}
28 changes: 28 additions & 0 deletions src/Engine/FacetStat.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Setono\SyliusMeilisearchPlugin\Engine;

final class FacetStat
{
public readonly float|int $min;

public readonly float|int $max;

public function __construct(

Check warning on line 13 in src/Engine/FacetStat.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetStat.php#L13

Added line #L13 was not covered by tests
public readonly string $name,
array $values,
) {
if (!isset($values['min'], $values['max'])) {
throw new \InvalidArgumentException('The $values must contain a min and a max key');

Check warning on line 18 in src/Engine/FacetStat.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetStat.php#L17-L18

Added lines #L17 - L18 were not covered by tests
}

if (!is_numeric($values['min']) || !is_numeric($values['max'])) {
throw new \InvalidArgumentException('The $values must contain numeric values');

Check warning on line 22 in src/Engine/FacetStat.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetStat.php#L21-L22

Added lines #L21 - L22 were not covered by tests
}

$this->min = $values['min'] + 0;
$this->max = $values['max'] + 0;

Check warning on line 26 in src/Engine/FacetStat.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetStat.php#L25-L26

Added lines #L25 - L26 were not covered by tests
}
}
84 changes: 84 additions & 0 deletions src/Engine/FacetStats.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?php

declare(strict_types=1);

namespace Setono\SyliusMeilisearchPlugin\Engine;

use Webmozart\Assert\Assert;

/**
* @implements \IteratorAggregate<string, FacetStat>
* @implements \ArrayAccess<string, FacetStat>
*/
final class FacetStats implements \Countable, \IteratorAggregate, \ArrayAccess
{
/** @var array<string, FacetStat> */
private array $facetStats = [];

/**
* @param array<string, mixed> $facetStats
*/
public function __construct(array $facetStats)

Check warning on line 21 in src/Engine/FacetStats.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetStats.php#L21

Added line #L21 was not covered by tests
{
foreach ($facetStats as $facet => $facetStat) {
Assert::isArray($facetStat);

Check warning on line 24 in src/Engine/FacetStats.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetStats.php#L23-L24

Added lines #L23 - L24 were not covered by tests

$this->facetStats[$facet] = new FacetStat($facet, $facetStat);

Check warning on line 26 in src/Engine/FacetStats.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetStats.php#L26

Added line #L26 was not covered by tests
}
}

/**
* @psalm-assert-if-true FacetStat $this->facetStats[$facet]
*/
public function has(string $facet): bool

Check warning on line 33 in src/Engine/FacetStats.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetStats.php#L33

Added line #L33 was not covered by tests
{
return isset($this->facetStats[$facet]);

Check warning on line 35 in src/Engine/FacetStats.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetStats.php#L35

Added line #L35 was not covered by tests
}

public function get(string $facet): FacetStat

Check warning on line 38 in src/Engine/FacetStats.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetStats.php#L38

Added line #L38 was not covered by tests
{
if (!$this->has($facet)) {
throw new \InvalidArgumentException(sprintf('Facet "%s" does not exist', $facet));

Check warning on line 41 in src/Engine/FacetStats.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetStats.php#L40-L41

Added lines #L40 - L41 were not covered by tests
}

return $this->facetStats[$facet];

Check warning on line 44 in src/Engine/FacetStats.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetStats.php#L44

Added line #L44 was not covered by tests
}

/**
* @return \ArrayIterator<string, FacetStat>
*/
public function getIterator(): \ArrayIterator

Check warning on line 50 in src/Engine/FacetStats.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetStats.php#L50

Added line #L50 was not covered by tests
{
return new \ArrayIterator($this->facetStats);

Check warning on line 52 in src/Engine/FacetStats.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetStats.php#L52

Added line #L52 was not covered by tests
}

public function count(): int

Check warning on line 55 in src/Engine/FacetStats.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetStats.php#L55

Added line #L55 was not covered by tests
{
return count($this->facetStats);

Check warning on line 57 in src/Engine/FacetStats.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetStats.php#L57

Added line #L57 was not covered by tests
}

public function isEmpty(): bool

Check warning on line 60 in src/Engine/FacetStats.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetStats.php#L60

Added line #L60 was not covered by tests
{
return [] === $this->facetStats;

Check warning on line 62 in src/Engine/FacetStats.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetStats.php#L62

Added line #L62 was not covered by tests
}

public function offsetExists(mixed $offset): bool

Check warning on line 65 in src/Engine/FacetStats.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetStats.php#L65

Added line #L65 was not covered by tests
{
return $this->has($offset);

Check warning on line 67 in src/Engine/FacetStats.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetStats.php#L67

Added line #L67 was not covered by tests
}

public function offsetGet(mixed $offset): FacetStat

Check warning on line 70 in src/Engine/FacetStats.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetStats.php#L70

Added line #L70 was not covered by tests
{
return $this->get($offset);

Check warning on line 72 in src/Engine/FacetStats.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetStats.php#L72

Added line #L72 was not covered by tests
}

public function offsetSet(mixed $offset, mixed $value): void

Check warning on line 75 in src/Engine/FacetStats.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetStats.php#L75

Added line #L75 was not covered by tests
{
throw new \LogicException('You cannot set an offset');

Check warning on line 77 in src/Engine/FacetStats.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetStats.php#L77

Added line #L77 was not covered by tests
}

public function offsetUnset(mixed $offset): void

Check warning on line 80 in src/Engine/FacetStats.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetStats.php#L80

Added line #L80 was not covered by tests
{
throw new \LogicException('You cannot unset an offset');

Check warning on line 82 in src/Engine/FacetStats.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetStats.php#L82

Added line #L82 was not covered by tests
}
}
121 changes: 121 additions & 0 deletions src/Engine/FacetValues.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<?php

declare(strict_types=1);

namespace Setono\SyliusMeilisearchPlugin\Engine;

use Webmozart\Assert\Assert;

/**
* @implements \ArrayAccess<string, int>
* @implements \IteratorAggregate<string, int>
*/
final class FacetValues implements \Countable, \IteratorAggregate, \ArrayAccess
{
/**
* This holds the facet values for the respective facet and search results. Examples for $values include:
*
* [
* "Celsius Small" => 3
* "Date & Banana" => 2
* "Modern Wear" => 6
* "You are breathtaking" => 10
* ]
*
* [
* "false" => 16
* "true" => 5
* ]
*
* [
* "1.74" => 1
* "12.21" => 1
* "16.52" => 1
* "21.06" => 1
* "22.49" => 1
* "24.19" => 1
* ]
*
* @var array<string, int>
*/
private array $values = [];

public function __construct(

Check warning on line 43 in src/Engine/FacetValues.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetValues.php#L43

Added line #L43 was not covered by tests
public readonly string $name,
array $values,
) {
foreach ($values as $key => $value) {
if (!is_string($key) || !is_int($value)) {
throw new \InvalidArgumentException(sprintf(
'The $values array must be an array of strings and integers. Input was: %s',
json_encode($values, \JSON_THROW_ON_ERROR),
));

Check warning on line 52 in src/Engine/FacetValues.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetValues.php#L47-L52

Added lines #L47 - L52 were not covered by tests
}

$this->values[$key] = $value;

Check warning on line 55 in src/Engine/FacetValues.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetValues.php#L55

Added line #L55 was not covered by tests
}
}

/**
* @return list<string>
*/
public function getValues(): array

Check warning on line 62 in src/Engine/FacetValues.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetValues.php#L62

Added line #L62 was not covered by tests
{
return array_keys($this->values);

Check warning on line 64 in src/Engine/FacetValues.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetValues.php#L64

Added line #L64 was not covered by tests
}

public function getValueCount(string $value): int

Check warning on line 67 in src/Engine/FacetValues.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetValues.php#L67

Added line #L67 was not covered by tests
{
if (!$this->has($value)) {
throw new \InvalidArgumentException(sprintf('Facet value "%s" does not exist', $value));

Check warning on line 70 in src/Engine/FacetValues.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetValues.php#L69-L70

Added lines #L69 - L70 were not covered by tests
}

return $this->values[$value];

Check warning on line 73 in src/Engine/FacetValues.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetValues.php#L73

Added line #L73 was not covered by tests
}

/**
* @psalm-assert-if-true int $this->values[$value]
*/
public function has(string $value): bool

Check warning on line 79 in src/Engine/FacetValues.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetValues.php#L79

Added line #L79 was not covered by tests
{
return isset($this->values[$value]);

Check warning on line 81 in src/Engine/FacetValues.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetValues.php#L81

Added line #L81 was not covered by tests
}

/**
* @return \ArrayIterator<string, int>
*/
public function getIterator(): \ArrayIterator

Check warning on line 87 in src/Engine/FacetValues.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetValues.php#L87

Added line #L87 was not covered by tests
{
return new \ArrayIterator($this->values);

Check warning on line 89 in src/Engine/FacetValues.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetValues.php#L89

Added line #L89 was not covered by tests
}

public function offsetExists(mixed $offset): bool

Check warning on line 92 in src/Engine/FacetValues.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetValues.php#L92

Added line #L92 was not covered by tests
{
return $this->has($offset);

Check warning on line 94 in src/Engine/FacetValues.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetValues.php#L94

Added line #L94 was not covered by tests
}

public function offsetGet(mixed $offset): int

Check warning on line 97 in src/Engine/FacetValues.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetValues.php#L97

Added line #L97 was not covered by tests
{
return $this->values[$offset];

Check warning on line 99 in src/Engine/FacetValues.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetValues.php#L99

Added line #L99 was not covered by tests
}

public function offsetSet(mixed $offset, mixed $value): void

Check warning on line 102 in src/Engine/FacetValues.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetValues.php#L102

Added line #L102 was not covered by tests
{
throw new \LogicException('You cannot set an offset');

Check warning on line 104 in src/Engine/FacetValues.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetValues.php#L104

Added line #L104 was not covered by tests
}

public function offsetUnset(mixed $offset): void

Check warning on line 107 in src/Engine/FacetValues.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetValues.php#L107

Added line #L107 was not covered by tests
{
throw new \LogicException('You cannot unset an offset');

Check warning on line 109 in src/Engine/FacetValues.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetValues.php#L109

Added line #L109 was not covered by tests
}

public function count(): int

Check warning on line 112 in src/Engine/FacetValues.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetValues.php#L112

Added line #L112 was not covered by tests
{
return count($this->values);

Check warning on line 114 in src/Engine/FacetValues.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetValues.php#L114

Added line #L114 was not covered by tests
}

public function isEmpty(): bool

Check warning on line 117 in src/Engine/FacetValues.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetValues.php#L117

Added line #L117 was not covered by tests
{
return [] === $this->values;

Check warning on line 119 in src/Engine/FacetValues.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/FacetValues.php#L119

Added line #L119 was not covered by tests
}
}
12 changes: 4 additions & 8 deletions src/Engine/SearchResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

final class SearchResult
{
public function __construct(

Check failure on line 13 in src/Engine/SearchResult.php

View workflow job for this annotation

GitHub Actions / Backwards Compatibility Check

The parameter $facetStats of Setono\SyliusMeilisearchPlugin\Engine\SearchResult#__construct() changed from array to a non-contravariant Setono\SyliusMeilisearchPlugin\Engine\FacetStats

Check failure on line 13 in src/Engine/SearchResult.php

View workflow job for this annotation

GitHub Actions / Backwards Compatibility Check

The parameter $facetDistribution of Setono\SyliusMeilisearchPlugin\Engine\SearchResult#__construct() changed from array to a non-contravariant Setono\SyliusMeilisearchPlugin\Engine\FacetDistribution
/** The index that was queried */
public readonly Index $index,

Expand All @@ -20,12 +20,8 @@
public readonly int $page,
public readonly int $pageSize,
public readonly int $totalPages,

/** @var array<string, mixed> $facetStats */
public readonly array $facetStats,

/** @var array<string, mixed> $facetDistribution */
public readonly array $facetDistribution,
public readonly FacetStats $facetStats,

Check failure on line 23 in src/Engine/SearchResult.php

View workflow job for this annotation

GitHub Actions / Backwards Compatibility Check

Type of property Setono\SyliusMeilisearchPlugin\Engine\SearchResult#$facetStats changed from array to Setono\SyliusMeilisearchPlugin\Engine\FacetStats
public readonly FacetDistribution $facetDistribution,

Check failure on line 24 in src/Engine/SearchResult.php

View workflow job for this annotation

GitHub Actions / Backwards Compatibility Check

Type of property Setono\SyliusMeilisearchPlugin\Engine\SearchResult#$facetDistribution changed from array to Setono\SyliusMeilisearchPlugin\Engine\FacetDistribution
) {
}

Expand Down Expand Up @@ -54,8 +50,8 @@
$page,
$pageSize,
$totalPages,
$meilisearchSearchResult->getFacetStats(),
$meilisearchSearchResult->getFacetDistribution(),
new FacetStats($meilisearchSearchResult->getFacetStats()),
new FacetDistribution($meilisearchSearchResult->getFacetDistribution()),

Check warning on line 54 in src/Engine/SearchResult.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/SearchResult.php#L53-L54

Added lines #L53 - L54 were not covered by tests
);
}
}
6 changes: 4 additions & 2 deletions src/Form/Builder/CheckboxFilterFormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
namespace Setono\SyliusMeilisearchPlugin\Form\Builder;

use Setono\SyliusMeilisearchPlugin\Document\Metadata\Facet;
use Setono\SyliusMeilisearchPlugin\Engine\FacetStat;
use Setono\SyliusMeilisearchPlugin\Engine\FacetValues;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\FormBuilderInterface;
use function Symfony\Component\String\u;

final class CheckboxFilterFormBuilder implements FilterFormBuilderInterface
{
public function build(FormBuilderInterface $builder, Facet $facet, array $values, array $stats = null): void
public function build(FormBuilderInterface $builder, Facet $facet, FacetValues $values, FacetStat $stats = null): void

Check warning on line 16 in src/Form/Builder/CheckboxFilterFormBuilder.php

View check run for this annotation

Codecov / codecov/patch

src/Form/Builder/CheckboxFilterFormBuilder.php#L16

Added line #L16 was not covered by tests
{
$builder->add($facet->name, CheckboxType::class, [
'label' => sprintf('setono_sylius_meilisearch.form.search.facet.%s', u($facet->name)->snake()),
Expand All @@ -24,7 +26,7 @@
]);
}

public function supports(Facet $facet, array $values, array $stats = null): bool
public function supports(Facet $facet, FacetValues $values, FacetStat $stats = null): bool

Check warning on line 29 in src/Form/Builder/CheckboxFilterFormBuilder.php

View check run for this annotation

Codecov / codecov/patch

src/Form/Builder/CheckboxFilterFormBuilder.php#L29

Added line #L29 was not covered by tests
{
return $facet->type === 'bool' && match (count($values)) {
1 => isset($values['true']),
Expand Down
Loading
Loading