initial checkin
[m6w6/hikke] / lib / hikke / Event / Priority.php
1 <?php
2
3 /**
4 * Hikke
5 *
6 * @author Michael Wallner <mike@php.net>
7 */
8 namespace hikke\Event;
9
10 /**
11 * Priority
12 *
13 * @package hikke\Event
14 */
15 abstract class Priority implements Prioritized
16 {
17 /**
18 * Compare an instance of a prioritzed object ot another
19 * @param \hikke\Event\Prioritized $other
20 * @return int
21 */
22 public function compareTo(Prioritized $other) {
23 return static::compare($this, $other);
24 }
25
26 /**
27 * Comparator
28 * @param \hikke\Event\Prioritized $a
29 * @param \hikke\Event\Prioritized $b
30 * @return int
31 */
32 public static function compare(Prioritized $a, Prioritized $b) {
33 if ($a->getPriority() < $b->getPriority()) {
34 return -1;
35 } elseif ($b->getPriority() < $a->getPriority()) {
36 return 1;
37 } else {
38 // @codeCoverageIgnoreStart
39 return 0;
40 // @codeCoverageIgnoreEnd
41 }
42 }
43
44 }