diff --git a/src/contracts/Repository/Values/Content/Query/Criterion/Image.php b/src/contracts/Repository/Values/Content/Query/Criterion/Image.php index 5dc965b06f..ce64e7faa5 100644 --- a/src/contracts/Repository/Values/Content/Query/Criterion/Image.php +++ b/src/contracts/Repository/Values/Content/Query/Criterion/Image.php @@ -8,7 +8,7 @@ namespace Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; -use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Image\AbstractImageCompositeCriterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Image\FileSize; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Image\Height; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Image\MimeType; @@ -28,7 +28,7 @@ * * @template-extends \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Image\AbstractImageCompositeCriterion */ -final class Image extends Criterion\Image\AbstractImageCompositeCriterion +final class Image extends AbstractImageCompositeCriterion { public const IMAGE_SEARCH_CRITERIA = [ 'mimeTypes', @@ -44,7 +44,7 @@ protected function getSupportedCriteria(): array } /** - * @phpstan-param ImageCriteria $data + * @phpstan-param ImageCriteria $imageCriteriaData * * @return array<\Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion> * @@ -52,19 +52,19 @@ protected function getSupportedCriteria(): array */ protected function buildCriteria( string $fieldDefIdentifier, - array $data + array $imageCriteriaData ): array { $criteria = []; - if (isset($data['mimeTypes'])) { + if (isset($imageCriteriaData['mimeTypes'])) { $criteria[] = new MimeType( $fieldDefIdentifier, - $data['mimeTypes'] + $imageCriteriaData['mimeTypes'] ); } - if (isset($data['size'])) { - $size = $data['size']; + if (isset($imageCriteriaData['size'])) { + $size = $imageCriteriaData['size']; $criteria[] = new FileSize( $fieldDefIdentifier, $this->getMinValue($size), @@ -72,8 +72,8 @@ protected function buildCriteria( ); } - if (isset($data['width'])) { - $width = $data['width']; + if (isset($imageCriteriaData['width'])) { + $width = $imageCriteriaData['width']; $criteria[] = new Width( $fieldDefIdentifier, $this->getMinValue($width), @@ -81,8 +81,8 @@ protected function buildCriteria( ); } - if (isset($data['height'])) { - $height = $data['height']; + if (isset($imageCriteriaData['height'])) { + $height = $imageCriteriaData['height']; $criteria[] = new Height( $fieldDefIdentifier, $this->getMinValue($height), @@ -90,10 +90,10 @@ protected function buildCriteria( ); } - if (isset($data['orientation'])) { + if (isset($imageCriteriaData['orientation'])) { $criteria[] = new Orientation( $fieldDefIdentifier, - $data['orientation'] + $imageCriteriaData['orientation'] ); } diff --git a/src/contracts/Repository/Values/Content/Query/Criterion/Image/AbstractImageCompositeCriterion.php b/src/contracts/Repository/Values/Content/Query/Criterion/Image/AbstractImageCompositeCriterion.php index 4baf235d00..47066404f6 100644 --- a/src/contracts/Repository/Values/Content/Query/Criterion/Image/AbstractImageCompositeCriterion.php +++ b/src/contracts/Repository/Values/Content/Query/Criterion/Image/AbstractImageCompositeCriterion.php @@ -23,29 +23,29 @@ abstract class AbstractImageCompositeCriterion extends CompositeCriterion { /** - * @phpstan-param TImageCriteria $data + * @phpstan-param TImageCriteria $imageCriteriaData * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException */ public function __construct( string $fieldDefIdentifier, - array $data + array $imageCriteriaData ) { - $this->validate($data, $this->getSupportedCriteria()); + $this->validate($imageCriteriaData, $this->getSupportedCriteria()); $criteria = new Criterion\LogicalAnd( - $this->buildCriteria($fieldDefIdentifier, $data) + $this->buildCriteria($fieldDefIdentifier, $imageCriteriaData) ); parent::__construct($criteria); } /** - * @phpstan-param TImageCriteria $data + * @phpstan-param TImageCriteria $imageCriteriaData * * @return array<\Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion> */ - abstract protected function buildCriteria(string $fieldDefIdentifier, array $data): array; + abstract protected function buildCriteria(string $fieldDefIdentifier, array $imageCriteriaData): array; /** * @return array @@ -53,17 +53,17 @@ abstract protected function buildCriteria(string $fieldDefIdentifier, array $dat abstract protected function getSupportedCriteria(): array; /** - * @phpstan-param TImageCriteria $data + * @phpstan-param TImageCriteria $imageCriteriaData * * @param array $supportedCriteria * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException */ protected function validate( - array $data, + array $imageCriteriaData, array $supportedCriteria ): void { - if (empty($data)) { + if (empty($imageCriteriaData)) { throw new InvalidArgumentException( '$data', sprintf( @@ -74,7 +74,7 @@ protected function validate( } $notSupportedCriteria = array_diff( - array_keys($data), + array_keys($imageCriteriaData), $supportedCriteria ); diff --git a/src/contracts/Repository/Values/Content/Query/Criterion/Image/Dimensions.php b/src/contracts/Repository/Values/Content/Query/Criterion/Image/Dimensions.php index d8cc57cf0c..c3179ef09c 100644 --- a/src/contracts/Repository/Values/Content/Query/Criterion/Image/Dimensions.php +++ b/src/contracts/Repository/Values/Content/Query/Criterion/Image/Dimensions.php @@ -34,7 +34,7 @@ protected function getSupportedCriteria(): array } /** - * @phpstan-param ImageCriteria $data + * @phpstan-param ImageCriteria $imageCriteriaData * * @return array<\Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion> * @@ -42,12 +42,12 @@ protected function getSupportedCriteria(): array */ protected function buildCriteria( string $fieldDefIdentifier, - array $data + array $imageCriteriaData ): array { $criteria = []; - if (isset($data['width'])) { - $width = $data['width']; + if (isset($imageCriteriaData['width'])) { + $width = $imageCriteriaData['width']; $criteria[] = new Width( $fieldDefIdentifier, $this->getMinValue($width), @@ -55,8 +55,8 @@ protected function buildCriteria( ); } - if (isset($data['height'])) { - $height = $data['height']; + if (isset($imageCriteriaData['height'])) { + $height = $imageCriteriaData['height']; $criteria[] = new Height( $fieldDefIdentifier, $this->getMinValue($height), diff --git a/src/contracts/Repository/Values/Content/Query/Criterion/Image/FileSize.php b/src/contracts/Repository/Values/Content/Query/Criterion/Image/FileSize.php index f3f7f2db41..9ca824e6e4 100644 --- a/src/contracts/Repository/Values/Content/Query/Criterion/Image/FileSize.php +++ b/src/contracts/Repository/Values/Content/Query/Criterion/Image/FileSize.php @@ -10,29 +10,23 @@ final class FileSize extends AbstractImageRangeCriterion { - /** - * @param numeric $minFileSize - * @param numeric|null $maxFileSize - * - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException - */ public function __construct( string $fieldDefIdentifier, - $minFileSize = 0, - $maxFileSize = null + $minValue = 0, + $maxValue = null ) { - if ($minFileSize > 0) { - $minFileSize *= 1024 * 1024; + if ($minValue > 0) { + $minValue *= 1024 * 1024; } - if ($maxFileSize > 0) { - $maxFileSize *= 1024 * 1024; + if ($maxValue > 0) { + $maxValue *= 1024 * 1024; } parent::__construct( $fieldDefIdentifier, - $minFileSize, - $maxFileSize + $minValue, + $maxValue ); } }