Hydration
9 months ago
TopologicalSort
9 months ago
CriteriaOrderings.php
9 months ago
HydrationCompleteHandler.php
9 months ago
SQLResultCasing.php
9 months ago
StronglyConnectedComponents.php
9 months ago
TopologicalSort.php
9 months ago
index.php
9 months ago
CriteriaOrderings.php
33 lines
| 1 | <?php |
| 2 | declare (strict_types=1); |
| 3 | namespace MailPoetVendor\Doctrine\ORM\Internal; |
| 4 | if (!defined('ABSPATH')) exit; |
| 5 | use MailPoetVendor\Doctrine\Common\Collections\Criteria; |
| 6 | use MailPoetVendor\Doctrine\Common\Collections\Order; |
| 7 | use function array_map; |
| 8 | use function class_exists; |
| 9 | use function method_exists; |
| 10 | use function strtoupper; |
| 11 | trait CriteriaOrderings |
| 12 | { |
| 13 | private static function getCriteriaOrderings(Criteria $criteria) : array |
| 14 | { |
| 15 | if (!method_exists(Criteria::class, 'orderings')) { |
| 16 | // @phpstan-ignore method.deprecated |
| 17 | return $criteria->getOrderings(); |
| 18 | } |
| 19 | return array_map(static function (Order $order) : string { |
| 20 | return $order->value; |
| 21 | }, $criteria->orderings()); |
| 22 | } |
| 23 | private static function mapToOrderEnumIfAvailable(array $orderings) : array |
| 24 | { |
| 25 | if (!class_exists(Order::class)) { |
| 26 | return $orderings; |
| 27 | } |
| 28 | return array_map(static function (string $order) : Order { |
| 29 | return Order::from(strtoupper($order)); |
| 30 | }, $orderings); |
| 31 | } |
| 32 | } |
| 33 |