1: <?php
2:
3: namespace Charcoal\Ui;
4:
5: use InvalidArgumentException;
6:
7: /**
8: * Provides an implementation of {@see \Charcoal\Ui\UiGroupingInterface}.
9: */
10: trait UiGroupingTrait
11: {
12: /**
13: * The group's identifier.
14: *
15: * @var string
16: */
17: private $ident;
18:
19: /**
20: * The group's priority.
21: *
22: * @var integer
23: */
24: private $priority;
25:
26: /**
27: * Set the identifier of the group.
28: *
29: * @param string $ident The group identifier.
30: * @return self
31: */
32: public function setIdent($ident)
33: {
34: $this->ident = $ident;
35:
36: return $this;
37: }
38:
39: /**
40: * Retrieve the idenfitier of the group.
41: *
42: * @return string
43: */
44: public function ident()
45: {
46: return $this->ident;
47: }
48:
49: /**
50: * Set the group's priority or sorting index.
51: *
52: * @param integer $priority An index, for sorting.
53: * @throws InvalidArgumentException If the priority is not an integer.
54: * @return self
55: */
56: public function setPriority($priority)
57: {
58: if (!is_numeric($priority)) {
59: throw new InvalidArgumentException(
60: 'Priority must be an integer'
61: );
62: }
63:
64: $this->priority = intval($priority);
65:
66: return $this;
67: }
68:
69: /**
70: * Retrieve the group's priority or sorting index.
71: *
72: * @return integer
73: */
74: public function priority()
75: {
76: return $this->priority;
77: }
78: }
79: