Issues (590)

src/Query/Contract/Orderable.php (3 issues)

1
<?php
2
3
namespace Bdf\Prime\Query\Contract;
4
5
use Bdf\Prime\Query\Expression\ExpressionInterface;
6
7
/**
8
 * Interface for sortable (order) queries
9
 */
10
interface Orderable
11
{
12
    public const ORDER_ASC = 'ASC';
13
    public const ORDER_DESC = 'DESC';
14
15
    /**
16
     * Specifies an ordering for the query results.
17
     * Replaces any previously specified orderings, if any.
18
     *
19
     * <code>
20
     *     $query->order('u.id'); // ORDER BY u.id ASC
21
     *     $query->order(['u.id', 'name']); // ORDER BY u.id ASC, name ASC
22
     *     $query->order(['u.id' => 'asc', 'name' => 'desc']); // ORDER BY u.id asc, name desc
23
     * </code>
24
     *
25
     * @param string|array<string,Orderable::ORDER_*>|ExpressionInterface $sort The ordering expression.
0 ignored issues
show
Documentation Bug introduced by
The doc comment string|array<string,Orde..._*>|ExpressionInterface at position 6 could not be parsed: Expected '>' at position 6, but found 'Orderable'.
Loading history...
26
     * @param Orderable::ORDER_*|null $order The ordering direction.
27
     *
28
     * @return $this This Query instance.
29
     */
30
    public function order($sort, ?string $order = null);
31
32
    /**
33
     * Adds an ordering for the query results.
34
     * Replaces any previously specified orderings, if any.
35
     *
36
     * <code>
37
     *     $query->addOrder('id'); // ORDER BY id ASC
38
     *     $query->addOrder('date', 'name'); // GROUP BY id ASC, date ASC, name ASC
39
     * </code>
40
     *
41
     * @param string|array<string,Orderable::ORDER_*>|ExpressionInterface $sort The ordering expression.
0 ignored issues
show
Documentation Bug introduced by
The doc comment string|array<string,Orde..._*>|ExpressionInterface at position 6 could not be parsed: Expected '>' at position 6, but found 'Orderable'.
Loading history...
42
     * @param Orderable::ORDER_*|null $order The ordering direction.
43
     *
44
     * @return $this This Query instance.
45
     */
46
    public function addOrder($sort, ?string $order = null);
47
48
    /**
49
     * Get orders
50
     *
51
     * @return array<string, Orderable::ORDER_*>
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<string, Orderable::ORDER_*> at position 4 could not be parsed: Expected '>' at position 4, but found 'Orderable'.
Loading history...
52
     */
53
    public function getOrders(): array;
54
}
55