ILIAS  release_7 Revision v7.30-3-g800a261c036
ILIAS\Data\Order Class Reference

Both the subject and the direction need to be specified when expressing an order. More...

+ Collaboration diagram for ILIAS\Data\Order:

Public Member Functions

 __construct (string $subject, $direction)
 
 append (string $subject, $direction)
 
 get ()
 
 join ($init, callable $fn)
 

Data Fields

const ASC = 'ASC'
 
const DESC = 'DESC'
 

Protected Member Functions

 checkSubject (string $subject)
 
 checkDirection ($direction)
 

Protected Attributes

 $order = []
 

Detailed Description

Both the subject and the direction need to be specified when expressing an order.

Author
Nils Haagen nils..nosp@m.haag.nosp@m.en@co.nosp@m.ncep.nosp@m.ts-an.nosp@m.d-tr.nosp@m.ainin.nosp@m.g.de

Definition at line 10 of file Order.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Data\Order::__construct ( string  $subject,
  $direction 
)

Definition at line 20 of file Order.php.

21 {
22 $this->checkDirection($direction);
23 $this->order[$subject] = $direction;
24 }
checkDirection($direction)
Definition: Order.php:33

References ILIAS\Data\Order\checkDirection().

+ Here is the call graph for this function:

Member Function Documentation

◆ append()

ILIAS\Data\Order::append ( string  $subject,
  $direction 
)

Definition at line 40 of file Order.php.

40 : Order
41 {
42 $this->checkSubject($subject);
43 $this->checkDirection($direction);
44 $clone = clone $this;
45 $clone->order[$subject] = $direction;
46 return $clone;
47 }
checkSubject(string $subject)
Definition: Order.php:26

References ILIAS\Data\Order\checkDirection(), and ILIAS\Data\Order\checkSubject().

Referenced by orderTest\testAppend(), orderTest\testInvalidDirection(), and orderTest\testInvalidSubject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkDirection()

ILIAS\Data\Order::checkDirection (   $direction)
protected

Definition at line 33 of file Order.php.

34 {
35 if ($direction !== self::ASC && $direction !== self::DESC) {
36 throw new \InvalidArgumentException("Direction bust be Order::ASC or Order::DESC.", 1);
37 }
38 }

Referenced by ILIAS\Data\Order\__construct(), and ILIAS\Data\Order\append().

+ Here is the caller graph for this function:

◆ checkSubject()

ILIAS\Data\Order::checkSubject ( string  $subject)
protected

Definition at line 26 of file Order.php.

27 {
28 if (array_key_exists($subject, $this->order)) {
29 throw new \InvalidArgumentException("already sorted by subject '$subject'", 1);
30 }
31 }

Referenced by ILIAS\Data\Order\append().

+ Here is the caller graph for this function:

◆ get()

ILIAS\Data\Order::get ( )

Definition at line 49 of file Order.php.

49 : array
50 {
51 return $this->order;
52 }

References ILIAS\Data\Order\$order.

Referenced by orderTest\testAppend(), and orderTest\testValues().

+ Here is the caller graph for this function:

◆ join()

ILIAS\Data\Order::join (   $init,
callable  $fn 
)

Definition at line 54 of file Order.php.

55 {
56 $ret = $init;
57 foreach ($this->order as $key => $value) {
58 $ret = $fn($ret, $key, $value);
59 }
60 return $ret;
61 }
$ret
Definition: parser.php:6

References $ret.

Referenced by orderTest\testJoinMore(), and orderTest\testJoinOne().

+ Here is the caller graph for this function:

Field Documentation

◆ $order

ILIAS\Data\Order::$order = []
protected

Definition at line 18 of file Order.php.

Referenced by ILIAS\Data\Order\get().

◆ ASC

const ILIAS\Data\Order::ASC = 'ASC'

Definition at line 12 of file Order.php.

◆ DESC

const ILIAS\Data\Order::DESC = 'DESC'

Definition at line 13 of file Order.php.


The documentation for this class was generated from the following file: